From 71fe8cb6972f0055693868fcc392f7d6d5379560 Mon Sep 17 00:00:00 2001 From: faisolavolut Date: Tue, 21 Oct 2025 14:47:18 +0700 Subject: [PATCH] chore: add initial Docker setup with Dockerfile and docker-compose.yml --- .dockerignore | 11 +++++++++++ Dockerfile | 35 +++++++++++++++++++++++++++++++++++ docker-compose.yml | 14 ++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..8fe9015 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,11 @@ +node_modules +.next +.git +.gitignore +Dockerfile* +docker-compose* +npm-debug.log* +yarn-debug.log* +yarn-error.log* +.env* +.DS_Store diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..caff9be --- /dev/null +++ b/Dockerfile @@ -0,0 +1,35 @@ +# Multi-stage Dockerfile for Next.js app (production) +FROM node:20-alpine AS deps +WORKDIR /app + +# Install dependencies +COPY package*.json ./ +RUN if [ -f package-lock.json ]; then npm ci; else npm install; fi + +# Build stage +FROM node:20-alpine AS builder +WORKDIR /app +ENV NEXT_TELEMETRY_DISABLED=1 + +COPY --from=deps /app/node_modules ./node_modules +COPY . . +RUN npm run build + +# Runtime stage +FROM node:20-alpine AS runner +WORKDIR /app +ENV NODE_ENV=production +ENV NEXT_TELEMETRY_DISABLED=1 +ENV PORT=3001 + +# Install prod deps only for runtime +COPY package*.json ./ +RUN if [ -f package-lock.json ]; then npm ci --omit=dev; else npm install --omit=dev; fi + +# Copy build artifacts +COPY --from=builder /app/.next ./.next +COPY --from=builder /app/public ./public +COPY --from=builder /app/next.config.* ./ + +EXPOSE 3001 +CMD ["npm", "start"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..d790627 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,14 @@ +version: "3.9" + +services: + frontend: + build: + context: . + dockerfile: Dockerfile + image: ibank-frontend:latest + environment: + - NODE_ENV=production + - PORT=3001 + ports: + - "3001:3001" + restart: unless-stopped