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:
@@ -0,0 +1,8 @@
|
|||||||
|
node_modules
|
||||||
|
.nuxt
|
||||||
|
.output
|
||||||
|
dist
|
||||||
|
src
|
||||||
|
.git
|
||||||
|
*.md
|
||||||
|
.planning
|
||||||
+12
-27
@@ -1,32 +1,17 @@
|
|||||||
# Stage 1: Build the Vue.js application
|
# Stage 1: Build
|
||||||
FROM node:22-alpine AS build-stage
|
FROM node:22-alpine AS builder
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy package.json and package-lock.json (or yarn.lock)
|
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
|
RUN npm ci
|
||||||
# Install dependencies
|
|
||||||
RUN npm install
|
|
||||||
|
|
||||||
# Copy the rest of your application's source code
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Build the application
|
|
||||||
# The command is taken from your "scripts" in package.json
|
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
# Stage 2: Serve the application with a lightweight web server
|
# Stage 2: Runtime
|
||||||
FROM nginx:stable-alpine AS production-stage
|
FROM node:22-alpine AS runner
|
||||||
|
ENV NODE_ENV=production
|
||||||
# Copy the built files from the build stage
|
ENV HOST=0.0.0.0
|
||||||
COPY --from=build-stage /app/dist /usr/share/nginx/html
|
ENV PORT=3000
|
||||||
|
WORKDIR /app
|
||||||
# Copy the nginx configuration file
|
COPY --from=builder /app/.output /app/.output
|
||||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
EXPOSE 3000
|
||||||
|
CMD ["node", "/app/.output/server/index.mjs"]
|
||||||
# Expose port 80 to the outside world
|
|
||||||
EXPOSE 80
|
|
||||||
|
|
||||||
# Command to run nginx in the foreground
|
|
||||||
CMD ["nginx", "-g", "daemon off;"]
|
|
||||||
|
|||||||
+6
-1
@@ -5,12 +5,17 @@ services:
|
|||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
- TZ=Europe/Paris
|
- TZ=Europe/Paris
|
||||||
|
- NUXT_SMTP_HOST=${NUXT_SMTP_HOST}
|
||||||
|
- NUXT_SMTP_USER=${NUXT_SMTP_USER}
|
||||||
|
- NUXT_SMTP_PASS=${NUXT_SMTP_PASS}
|
||||||
|
- NUXT_SMTP_TO=${NUXT_SMTP_TO}
|
||||||
|
- NUXT_PUBLIC_GTAG_ID=${NUXT_PUBLIC_GTAG_ID}
|
||||||
networks:
|
networks:
|
||||||
- public
|
- public
|
||||||
labels:
|
labels:
|
||||||
- 'traefik.enable=true'
|
- 'traefik.enable=true'
|
||||||
- 'com.centurylinklabs.watchtower.enable=false'
|
- 'com.centurylinklabs.watchtower.enable=false'
|
||||||
- 'traefik.http.services.portfolio.loadbalancer.server.port=80'
|
- 'traefik.http.services.portfolio.loadbalancer.server.port=3000'
|
||||||
# Main router (non-www)
|
# Main router (non-www)
|
||||||
- 'traefik.http.routers.portfolio.rule=Host(`${PORTFOLIO_URL}`)'
|
- 'traefik.http.routers.portfolio.rule=Host(`${PORTFOLIO_URL}`)'
|
||||||
- 'traefik.http.routers.portfolio.entrypoints=websecure'
|
- 'traefik.http.routers.portfolio.entrypoints=websecure'
|
||||||
|
|||||||
Reference in New Issue
Block a user