Skip to content

Docker Deploy (NuxtPro Admin)

Step 1: Update docker-compose.yml

Fill in values based on your environment.

Example:

bash
services:
  duoge-website:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: nuxtpro-admin
    restart: unless-stopped
    ports:
      - "3002:3002"
    environment:
      PORT: 3002
      DATABASE_URL: "mysql://username:password@ip:port/nuxtpro"
      BETTER_AUTH_SECRET: B3E4q0JYr5pRpQRwvxo9jfOLz48TKrJL # random 32-byte secret
      BETTER_AUTH_URL: http://localhost:3002
      NUXT_RESEND_API_KEY: # your resend api key
    healthcheck:
      test: ["CMD", "wget", "--no-verbose", "--tries:1", "--spider", "http://localhost:3002"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s
    networks:
      - app-network

networks:
  app-network:
    driver: bridge

Step 2: Update the Dockerfile port

Make sure EXPOSE and PORT match docker-compose.yml.

bash
# Multi-stage build
FROM node:20-alpine AS builder

WORKDIR /app

COPY package.json pnpm-lock.yaml ./
RUN npm install -g pnpm && pnpm install --frozen-lockfile

COPY . .
RUN pnpm run build:prod

FROM node:20-alpine AS runner
WORKDIR /app
COPY --from=builder /app/.output ./.output

EXPOSE 3002
ENV NODE_ENV=production
ENV PORT=3002
CMD ["node", ".output/server/index.mjs"]

Step 3: Build and start

bash
docker-compose up -d --build

Step 4: View logs

bash
docker-compose logs -f

Stop / restart

bash
docker-compose down
bash
docker-compose restart