From 20ab50963c7477af4c8be885115d54e087808828 Mon Sep 17 00:00:00 2001 From: yamashita-kenngo Date: Fri, 3 May 2024 17:07:00 +0900 Subject: [PATCH] chore: add dockerfile --- Dockerfile | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..30c66db --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +FROM node:22-alpine AS base + +FROM base AS builder + +RUN apk add --no-cache libc6-compat +WORKDIR /backend + +COPY package*.json tsconfig.json src ./ + +RUN npm ci && \ + npm run build && \ + npm prune --production + +FROM base AS runner +WORKDIR /backend + +RUN addgroup --system --gid 1001 nodejs +RUN adduser --system --uid 1001 autonomy + +COPY --from=builder --chown=autonomy:nodejs /backend/node_modules /backend/node_modules +COPY --from=builder --chown=autonomy:nodejs /backend/dist /backend/dist +COPY --from=builder --chown=autonomy:nodejs /backend/package.json /backend/package.json + +USER autonomy +EXPOSE 3000 + +CMD ["node", "/backend/dist/index.js"]