diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..ecb98a6 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,9 @@ +.git +node_modules +docker-compose.yml +Dockerfile +.prettierrc +.gitignore +.eslintrc.js +README.md +API.md diff --git a/Dockerfile b/Dockerfile index 44b9d45..08032da 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,24 +2,32 @@ FROM node:18-alpine AS pnpm RUN npm i -g pnpm +FROM pnpm AS depends + +WORKDIR "/app" + +COPY package.json pnpm-lock.yaml . + +RUN pnpm install + FROM pnpm AS builder WORKDIR "/app" COPY . . -RUN pnpm i +COPY --from=depends /app/node_modules ./node_modules RUN pnpm build -RUN pnpm prune --production +RUN pnpm prune --prod -FROM builder AS prod +FROM node:18-alpine AS prod WORKDIR "/app" -COPY --from=builder /app/package.json ./package.json -COPY --from=builder /app/pnpm-lock.yaml ./pnpm-lock.yaml +#COPY --from=builder /app/package.json ./package.json +#COPY --from=builder /app/pnpm-lock.yaml ./pnpm-lock.yaml COPY --from=builder /app/dist ./dist COPY --from=builder /app/node_modules ./node_modules @@ -31,6 +39,6 @@ ENV DB_NAME mx ENV JWT_SECRET secret ENV JWT_EXPIRY 1h -CMD ["sh", "-c", "DB_HOST=${DB_HOST} DB_PORT=${DB_PORT} DB_USER=${DB_USER} DB_PASS=${DB_PASS} DB_NAME=${DB_NAME} JWT_SECRET=${JWT_SECRET} JWT_EXPIRY=${JWT_EXPIRY} node dist/main --host 0.0.0.0"] +CMD ["sh", "-c", "DB_HOST=${DB_HOST} DB_PORT=${DB_PORT} DB_USER=${DB_USER} DB_PASS=${DB_PASS} DB_NAME=${DB_NAME} JWT_SECRET=${JWT_SECRET} JWT_EXPIRY=${JWT_EXPIRY} node dist/main.js --host 0.0.0.0"] EXPOSE 3000