From f44bcd3ad0aedb1b532d1c769ba6c7349ac9692a Mon Sep 17 00:00:00 2001 From: mrjvs Date: Wed, 9 Apr 2025 13:42:39 +0200 Subject: [PATCH] feat: update dockerfile to work with nuxt --- .dockerignore | 5 +++++ Dockerfile | 13 +++++++------ package.json | 3 ++- 3 files changed, 14 insertions(+), 7 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..470519d --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +.git/ +node_modules/ +.env +.nuxt +.output diff --git a/Dockerfile b/Dockerfile index 98cc289..151a9f9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ ARG app_dir="/home/node/app" # * Base Node.js image -FROM node:20-alpine AS base +FROM node:22-alpine AS base ARG app_dir WORKDIR ${app_dir} @@ -35,14 +35,15 @@ RUN npm run build FROM base AS final ARG app_dir -RUN mkdir -p ${app_dir}/logs && chown node:node ${app_dir}/logs - -ENV NODE_ENV=production USER node +ENV NODE_ENV=production +ENV NITRO_HOST=0.0.0.0 +ENV NITRO_PORT=8080 +EXPOSE 8080 COPY package.json . COPY --from=dependencies ${app_dir}/node_modules ${app_dir}/node_modules -COPY --from=build ${app_dir} ${app_dir} +COPY --from=build ${app_dir}/.output ${app_dir}/.output -CMD ["node", "."] +CMD ["node", "--enable-source-maps", ".output/server/index.mjs"] diff --git a/package.json b/package.json index 2c049db..a221170 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,9 @@ "license": "AGPL-3.0-only", "type": "module", "scripts": { - "start": "node --enable-source-maps .", + "start": "node --enable-source-maps .output/server/index.mjs", "build": "nuxt build", + "prepare": "nuxt prepare", "dev": "nuxt dev", "lint": "eslint .", "lint:fix": "eslint . --fix"