Last active
April 17, 2024 09:44
-
-
Save wanderer20/4e3b847f04ac8c4ff6104d9e651359a2 to your computer and use it in GitHub Desktop.
[test] docker + pm2 + nuxt
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
ARG NODE_VERSION=node:21.7.3-alpine | |
ARG NGINX_VERSION=nginx:1.25.4-alpine | |
FROM $NODE_VERSION AS production-base | |
WORKDIR /usr/src/app | |
COPY ./../app/package*.json ./../app/pnpm-*.yaml ./ | |
RUN apk update | |
RUN apk add \ | |
--update \ | |
--no-cache \ | |
--upgrade \ | |
bash \ | |
grep \ | |
vim \ | |
nano \ | |
mc \ | |
npm \ | |
git | |
RUN npm install -g pnpm | |
RUN NODE_ENV=production pnpm install \ | |
--prefer-offline \ | |
--frozen-lockfile \ | |
--prod=true \ | |
2> >(grep -v warning 1>&2) | |
RUN pnpm build | |
FROM $NGINX_VERSION AS production | |
WORKDIR /var/www/app | |
COPY ./../docker/default.conf /etc/nginx/conf.d | |
COPY ./../docker/ecosystem.config.cjs ./ | |
COPY --from=production-base /usr/src/app/.output ./output | |
RUN apk update | |
RUN apk add \ | |
--update \ | |
--no-cache \ | |
--upgrade \ | |
bash \ | |
grep \ | |
vim \ | |
nano \ | |
mc \ | |
npm \ | |
git | |
RUN npm install -g pm2 | |
CMD pm2 start ecosystem.config.cjs --only nuxt-prod && nginx -g 'daemon off;' |
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
module.exports = { | |
apps: [ | |
{ | |
name: 'nuxt-prod', | |
port: '3000', | |
exec_mode: 'cluster', | |
instances: 'max', | |
script: './output/server/index.mjs' | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment