diff --git a/Dockerfile b/Dockerfile index c23ab74..3ba7e8c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,34 @@ -FROM node:20-alpine +# Build Stage 1 +FROM node:22-alpine AS build WORKDIR /app -COPY package*.json ./ -RUN npm install -COPY . . +RUN corepack enable -COPY entrypoint.sh /app/entrypoint.sh -RUN chmod +x /app/entrypoint.sh +# Copy package.json and your lockfile, here we add pnpm-lock.yaml for illustration +COPY package.json pnpm-lock.yaml .npmrc ./ -EXPOSE 1337 \ No newline at end of file +# Install dependencies +RUN pnpm i + +# Copy the entire project +COPY . ./ + +# Build the project +RUN pnpm run build + +# Build Stage 2 + +FROM node:22-alpine +WORKDIR /app + +# Only `.output` folder is needed from the build stage +COPY --from=build /app/.output/ ./ + +# Change the port and host +ENV PORT=80 +ENV HOST=0.0.0.0 + +EXPOSE 80 + +CMD ["node", "/app/server/index.mjs"] \ No newline at end of file