Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload API Prep Part 4: Fix prod #41

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# Useless and heavy folders
**/build
**/dist
data
[...]
**/.next
**/.vercel
Expand All @@ -16,4 +17,4 @@
# Other useless files in the image
.git/
.github/
[...]
[...]
24 changes: 9 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,23 @@
# Build Stage
FROM node:22-bookworm-slim AS build

WORKDIR /home/node/app

COPY package*.json ./
RUN npm install
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 --from=build /home/node/app/dist ./dist
COPY --chown=node:node --from=build /home/node/app/public ./public
COPY --chown=node:node --from=build /home/node/app/package*.json ./
COPY --chown=node:node ./package*.json .

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

COPY process.json .
COPY --chown=node:node 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"]
2 changes: 1 addition & 1 deletion docker-compose-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ volumes:
networks:
badgehub_network:
name: badgehub_network
external: true
external: true
Loading
Loading