Skip to content

Commit

Permalink
[feature] Dorcker file
Browse files Browse the repository at this point in the history
- Use node 20 "slim"
- install pnpm and pm2 using npm
  • Loading branch information
ponsfrilus committed Jan 13, 2024
1 parent 1a8e51e commit fcd0cfb
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/
.git/
.github/
.vscode/
31 changes: 31 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# https://expressjs.com/en/advanced/best-practice-performance.html
# https://javascript.plainenglish.io/build-a-production-ready-node-express-api-with-docker-9a45443427a0
# https://pm2.keymetrics.io/docs/usage/docker-pm2-nodejs/

# docker build -t epflsi/startpage .
# docker run -it epflsi/startpage bash
# docker run -e PORT=1337 -p 3000:1337 epflsi/startpage -d

FROM node:20-slim

# RUN apt-get -qq update && apt-get -qq -y --no-install-recommends install curl
# RUN apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false
RUN npm install -g pnpm pm2

RUN mkdir -p /home/node/app/src
WORKDIR /home/node/app

COPY package*.json ./
RUN pnpm i --only=production
COPY ./src ./src

# Set internal port
ENV PORT=1337
# Open desired port
EXPOSE 3000

# It's a production Docker
ENV NODE_ENV=production

# Use pm2 to run the application
ENTRYPOINT ["pm2-runtime", "./src/server.js"]

0 comments on commit fcd0cfb

Please sign in to comment.