-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Use node 20 "slim" - install pnpm and pm2 using npm
- Loading branch information
1 parent
1a8e51e
commit fcd0cfb
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules/ | ||
.git/ | ||
.github/ | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |