docker compose updated

This commit is contained in:
jhpin2 2025-04-10 15:54:40 +06:00
parent 1f629192e2
commit 9c1dfadbf0
2 changed files with 14 additions and 36 deletions

View file

@ -1,24 +1,15 @@
# Install dependencies only when needed # Step 1: Build
FROM node:18-alpine AS deps
WORKDIR /app
COPY package.json package-lock.json* ./
RUN npm install
# Build the app
FROM node:18-alpine AS builder FROM node:18-alpine AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules WORKDIR /app
COPY . . COPY . .
RUN npm install
RUN npm run build RUN npm run build
# Run the app # Step 2: Run
FROM node:18-alpine AS runner FROM node:18-alpine
WORKDIR /app
ENV NODE_ENV production WORKDIR /app
ENV PORT 3000
COPY --from=builder /app/public ./public COPY --from=builder /app/public ./public
COPY --from=builder /app/.next ./.next COPY --from=builder /app/.next ./.next

View file

@ -2,31 +2,18 @@ version: "3.8"
services: services:
webapp: webapp:
container_name: webapp
build: build:
context: . context: .
dockerfile: Dockerfile dockerfile: Dockerfile
expose: restart: always
- "3000" ports:
labels: - "3000:3000"
- "traefik.enable=true"
- "traefik.http.routers.webapp-http.rule=Host(`planpostai.com`) || Host(`www.planpostai.com`)"
- "traefik.http.routers.webapp-http.entrypoints=http"
- "traefik.http.routers.webapp-http.middlewares=redirect-to-https"
- "traefik.http.routers.webapp-https.rule=Host(`planpostai.com`) || Host(`www.planpostai.com`)"
- "traefik.http.routers.webapp-https.entrypoints=https"
- "traefik.http.routers.webapp-https.tls=true"
- "traefik.http.routers.webapp-https.tls.certresolver=letsencrypt"
- "traefik.http.routers.webapp-https.middlewares=redirect-to-www,gzip"
- "traefik.http.services.webapp-service.loadbalancer.server.port=3000"
- "traefik.http.routers.webapp-https.service=webapp-service"
- "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
- "traefik.http.middlewares.redirect-to-www.redirectregex.regex=^https?://(?:www\\.)?(.+)"
- "traefik.http.middlewares.redirect-to-www.redirectregex.replacement=https://www.$${1}"
- "traefik.http.middlewares.redirect-to-www.redirectregex.permanent=true"
- "traefik.http.middlewares.gzip.compress=true"
networks: networks:
- web - coolify
environment:
- NODE_ENV=production
networks: networks:
web: coolify:
external: true external: true