Skip to content

Commit

Permalink
Update dockerfile to produce a more specific prod image
Browse files Browse the repository at this point in the history
  • Loading branch information
jsphpl committed May 9, 2024
1 parent dfa70d5 commit a6b15d1
Show file tree
Hide file tree
Showing 7 changed files with 12,487 additions and 11,286 deletions.
7 changes: 0 additions & 7 deletions .env.example

This file was deleted.

112 changes: 1 addition & 111 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,114 +1,4 @@
############################
# OS X
############################

.DS_Store
.AppleDouble
.LSOverride
Icon
.Spotlight-V100
.Trashes
._*


############################
# Linux
############################

*~


############################
# Windows
############################

Thumbs.db
ehthumbs.db
Desktop.ini
$RECYCLE.BIN/
*.cab
*.msi
*.msm
*.msp


############################
# Packages
############################

*.7z
*.csv
*.dat
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
*.com
*.class
*.dll
*.exe
*.o
*.seed
*.so
*.swo
*.swp
*.swn
*.swm
*.out
*.pid


############################
# Logs and databases
############################

.tmp
*.log
*.sql
*.sqlite
*.sqlite3


############################
# Misc.
############################

*#
ssl
.idea
nbproject
public/uploads/*
!public/uploads/.gitkeep

############################
# Node.js
############################

lib-cov
lcov.info
pids
logs
results
node_modules
.node_history

############################
# Tests
############################

coverage

############################
# Strapi
############################

.env
license.txt
exports
.strapi
dist
build
.strapi
.strapi-updater.json
38 changes: 25 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
FROM node:18-alpine
RUN apk update && apk add --no-cache build-base gcc autoconf automake zlib-dev libpng-dev nasm bash vips-dev git
ARG NODE_ENV=production
ENV NODE_ENV=${NODE_ENV}
# -|----------------------------------------------------------------------------
# | Intermediate image for building the application.
# -|----------------------------------------------------------------------------
FROM node:20-alpine AS builder
WORKDIR /app

WORKDIR /opt/
RUN npm install -g node-gyp
COPY package.json package-lock.json ./
RUN npm install
ENV PATH /opt/node_modules/.bin:$PATH
RUN npm ci

WORKDIR /opt/app
COPY . .
RUN chown -R node:node /opt/app
USER node
COPY tsconfig.json ./
COPY src ./src
RUN npm run build

# -|----------------------------------------------------------------------------
# | Final image containing only the files required to run in production.
# -|----------------------------------------------------------------------------
FROM node:20-alpine AS production
RUN apk add --no-cache vips-dev

WORKDIR /app
USER node
ENV NODE_ENV=production

COPY --from=builder --chown=node:node /app/package.json .
COPY --from=builder --chown=node:node /app/dist dist
COPY --from=builder --chown=node:node /app/node_modules node_modules
COPY --chown=node:node public ./public

EXPOSE 1337
CMD ["npm", "run", "start"]
ENTRYPOINT [ "npm", "run", "start" ]
Empty file removed database/migrations/.gitkeep
Empty file.
Loading

0 comments on commit a6b15d1

Please sign in to comment.