Skip to content

Commit

Permalink
Fix production docker build by doing esbuild for docker
Browse files Browse the repository at this point in the history
  • Loading branch information
Francis Duvivier committed Jan 5, 2025
1 parent b684b00 commit 7ede800
Show file tree
Hide file tree
Showing 5 changed files with 785 additions and 613 deletions.
26 changes: 17 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
# Build Stage
FROM node:22-bookworm-slim AS build

WORKDIR /home/node/app

COPY package*.json ./
RUN npm ci --ignore-scripts
COPY . .
RUN npm run build

# Prod stage
FROM node:22-bookworm-slim

WORKDIR /home/node/app
ENV NODE_ENV=production

# Copy only needed files
COPY --chown=node:node ./package*.json .
COPY --chown=node:node --from=build /home/node/app/dist ./dist
COPY --chown=node:node --from=build /home/node/app/database.json ./database.json
COPY --chown=node:node --from=build /home/node/app/migrations ./migrations
COPY --chown=node:node --from=build /home/node/app/public ./public
COPY --chown=node:node --from=build /home/node/app/package*.json ./

RUN npm ci --only=production --ignore-scripts

COPY --chown=node:node process.json .
COPY process.json .
RUN mkdir -p /home/node/.pm2 /home/node/app/logs /home/node/app/pids && chown -R node:node /home/node/.pm2 /home/node/app/logs

# db-migrate stuff
COPY --chown=node:node migrations ./migrations
COPY --chown=node:node database.json .

COPY --chown=node:node ./public ./public
COPY --chown=node:node ./src ./src

USER node
EXPOSE 8081
CMD ["./node_modules/pm2/bin/pm2-runtime", "process.json"]
7 changes: 0 additions & 7 deletions docker-compose.production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ services:
- .env.prod
depends_on:
- db
networks:
- badgehub_network

pgadmin:
image: dpage/pgadmin4
Expand All @@ -39,8 +37,3 @@ services:
volumes:
postgres_data:
pgadmin_data:

networks:
badgehub_network:
name: badgehub_network
external: true
Loading

0 comments on commit 7ede800

Please sign in to comment.