CHORE(app): init

This commit is contained in:
2025-11-30 10:44:12 +09:00
commit b4ce36ba3b
19 changed files with 1123 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
# trunk-ignore-all(checkov/CKV_DOCKER_3)
FROM node:20-alpine AS base
# Install dependencies for development
RUN apk add --no-cache libc6-compat curl
WORKDIR /app
# Copy package files
COPY package.json package-lock.json* ./
# Install all dependencies (including dev dependencies)
RUN npm ci
# Copy source code
COPY . .
# Generate Prisma Client
RUN npx prisma generate
# Expose port
EXPOSE 3000
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:3000/api/health || exit 1
# Default command (can be overridden in docker-compose)
CMD ["npm", "run", "dev"]

View File

@@ -0,0 +1,65 @@
# Multi-stage build for Next.js application
FROM node:20-alpine AS base
# Install dependencies only when needed
FROM base AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app
# Install dependencies based on the preferred package manager
COPY package.json package-lock.json* ./
RUN npm ci
# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Generate Prisma Client
# Build-time DATABASE_URL (not persisted in final image)
ARG DATABASE_URL="mysql://build:build@localhost:3306/build"
RUN npx prisma generate
# Build the application
ENV NEXT_TELEMETRY_DISABLED=1
RUN npm run build
# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app
RUN apk add --no-cache curl
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
RUN addgroup --system --gid 1001 nodejs && adduser --system --uid 1001 nextjs
# Copy built application
COPY --from=builder /app/public ./public
# Set the correct permission for prerender cache
RUN mkdir .next && chown nextjs:nodejs .next
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
# Copy Prisma files
COPY --from=builder /app/prisma ./prisma
USER nextjs
EXPOSE 3000
ENV PORT=3000
ENV HOSTNAME=0.0.0.0
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:3000/api/health || exit 1
CMD ["node", "server.js"]

View File

@@ -0,0 +1,64 @@
services:
# Next.js Application (Development) - Using External Database
app:
image: jaejadle-app-dev
build:
context: ../../services/nextjs
dockerfile: ../../deploy/docker/Dockerfile.dev
container_name: jaejadle-app-dev
restart: unless-stopped
labels:
kompose.namespace: jaejadle-dev
ports:
- "3004:3000"
env_file:
- ../../.env
environment:
- NODE_ENV=development
networks:
- jaejadle-network-dev
volumes:
- ../../services/nextjs:/app
- /app/node_modules
- /app/.next
- app_logs_dev:/app/logs
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/api/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
command: >
sh -lc "npx prisma generate && npx prisma db push && npm run dev"
# Prisma Studio - Connects to External Database
prisma-studio:
image: jaejadle-app-dev
container_name: jaejadle-prisma-studio
restart: unless-stopped
labels:
kompose.namespace: jaejadle-dev
ports:
- "5557:5555"
env_file:
- ../../.env
environment:
- NODE_ENV=development
networks:
- jaejadle-network-dev
volumes:
- ../../services/nextjs:/app
- /app/node_modules
command: npx prisma studio --port 5555 --hostname 0.0.0.0
volumes:
# Named volumes for data persistence
app_logs_dev:
driver: local
networks:
jaejadle-network-dev:
driver: bridge
ipam:
config:
- subnet: 172.25.0.0/16

View File

@@ -0,0 +1,39 @@
services:
# Next.js Application - Using External Database
app:
image: jaejadle-app
build:
context: ../../services/nextjs
dockerfile: ../../deploy/docker/Dockerfile.prod
container_name: jaejadle-app
restart: unless-stopped
labels:
kompose.namespace: jaejadle
ports:
- 3004:3000
env_file:
- ../../.env
environment:
- NODE_ENV=production
networks:
- jaejadle-network
volumes:
- app_logs:/app/logs
healthcheck:
test: [CMD, curl, -f, http://localhost:3000/api/health]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
volumes:
# Named volumes for data persistence
app_logs:
driver: local
networks:
jaejadle-network:
driver: bridge
ipam:
config:
- subnet: 172.24.0.0/16