add dockerfile

This commit is contained in:
nicwands
2026-05-27 14:08:06 -04:00
parent 409b926a52
commit 35cf8eddbc
3 changed files with 44 additions and 1 deletions

15
.dockerignore Normal file
View File

@@ -0,0 +1,15 @@
node_modules
npm-debug.log
.git
.gitignore
README.md
.env
.nyc_output
coverage
.sass-cache
.cache
.tmp
.DS_Store
*.log
dist
.strapi-updater.json

29
Dockerfile Normal file
View File

@@ -0,0 +1,29 @@
# Creating multi-stage build for production
FROM node:24-alpine as build
RUN apk update && apk add --no-cache build-base gcc autoconf automake zlib-dev libpng-dev vips-dev > /dev/null 2>&1
ARG NODE_ENV=production
ENV NODE_ENV=${NODE_ENV}
WORKDIR /opt/
COPY package.json package-lock.json ./
RUN npm config set fetch-retry-maxtimeout 600000 -g && npm install --only=production
ENV PATH=/opt/node_modules/.bin:$PATH
WORKDIR /opt/app
COPY . .
RUN npm run build
# Creating final production image
FROM node:24-alpine
RUN apk add --no-cache vips-dev
ARG NODE_ENV=production
ENV NODE_ENV=${NODE_ENV}
WORKDIR /opt/
COPY --from=build /opt/node_modules ./node_modules
WORKDIR /opt/app
COPY --from=build /opt/app ./
ENV PATH=/opt/node_modules/.bin:$PATH
RUN chown -R node:node /opt/app
USER node
EXPOSE 1337
CMD ["npm", "run", "start"]

View File

@@ -3,7 +3,6 @@ services:
container_name: takerofnotes
build:
context: .
dockerfile: Dockerfile.prod
image: takerofnotes-cms:latest
restart: unless-stopped
env_file: .env