chore: add initial Docker setup with Dockerfile and docker-compose.yml

This commit is contained in:
faisolavolut 2025-10-21 14:47:18 +07:00
parent 0176565dd2
commit 71fe8cb697
3 changed files with 60 additions and 0 deletions

11
.dockerignore Normal file
View File

@ -0,0 +1,11 @@
node_modules
.next
.git
.gitignore
Dockerfile*
docker-compose*
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.env*
.DS_Store

35
Dockerfile Normal file
View File

@ -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"]

14
docker-compose.yml Normal file
View File

@ -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