feat(03-04): Dockerfile SSR multi-stage + docker-compose Traefik port 3000
- Rewrite Dockerfile: node:22-alpine build + runtime, copy .output/, node server - Add .dockerignore excluding node_modules, .nuxt, .output, src, .git, .planning - Update docker-compose loadbalancer port from 80 to 3000 - Add SMTP and GA4 environment variables to docker-compose
This commit is contained in:
+12
-27
@@ -1,32 +1,17 @@
|
||||
# Stage 1: Build the Vue.js application
|
||||
FROM node:22-alpine AS build-stage
|
||||
|
||||
# Stage 1: Build
|
||||
FROM node:22-alpine AS builder
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package.json and package-lock.json (or yarn.lock)
|
||||
COPY package*.json ./
|
||||
|
||||
# Install dependencies
|
||||
RUN npm install
|
||||
|
||||
# Copy the rest of your application's source code
|
||||
RUN npm ci
|
||||
COPY . .
|
||||
|
||||
# Build the application
|
||||
# The command is taken from your "scripts" in package.json
|
||||
RUN npm run build
|
||||
|
||||
# Stage 2: Serve the application with a lightweight web server
|
||||
FROM nginx:stable-alpine AS production-stage
|
||||
|
||||
# Copy the built files from the build stage
|
||||
COPY --from=build-stage /app/dist /usr/share/nginx/html
|
||||
|
||||
# Copy the nginx configuration file
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
# Expose port 80 to the outside world
|
||||
EXPOSE 80
|
||||
|
||||
# Command to run nginx in the foreground
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
# Stage 2: Runtime
|
||||
FROM node:22-alpine AS runner
|
||||
ENV NODE_ENV=production
|
||||
ENV HOST=0.0.0.0
|
||||
ENV PORT=3000
|
||||
WORKDIR /app
|
||||
COPY --from=builder /app/.output /app/.output
|
||||
EXPOSE 3000
|
||||
CMD ["node", "/app/.output/server/index.mjs"]
|
||||
|
||||
Reference in New Issue
Block a user