dockerfile for web

This commit is contained in:
Nate Kelley 2025-01-07 15:35:18 -07:00
parent 11b4b929c0
commit 5f612fbcf7
3 changed files with 54 additions and 2 deletions

View File

@ -32,7 +32,9 @@ services:
ports:
- "3000:3000"
environment:
API_URL: http://api:3001
- NODE_ENV=production
env_file:
- ./web/.env
depends_on:
- api

50
web/Dockerfile Normal file
View File

@ -0,0 +1,50 @@
# Build stage
FROM node:20-alpine AS builder
WORKDIR /app
# Copy package files
COPY package*.json ./
# Copy environment variables for build
COPY .env ./
COPY next.config.mjs ./
# Install dependencies
RUN npm ci
# Copy source code
COPY . .
# Build the Next.js application
RUN npm run build
# Production stage
FROM node:20-alpine AS runner
WORKDIR /app
# Set to production environment
ENV NODE_ENV=production
# Copy necessary files from builder
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/next.config.mjs ./
# Copy environment files
COPY --from=builder /app/.env ./
# Expose the port your app runs on
EXPOSE 3000
# Add tini for proper signal handling
RUN apk add --no-cache tini
# Use tini as entrypoint
ENTRYPOINT ["/sbin/tini", "--"]
# Start the application
CMD ["npm", "start"]

View File

@ -10,7 +10,7 @@
"cy:run": "npx cypress run --browser chrome"
},
"engines": {
"node": ">=22.0.0"
"node": ">=20.0.0"
},
"dependencies": {
"@ant-design/nextjs-registry": "^1.0.2",