nex_music/Dockerfile

38 lines
990 B
Docker
Raw Normal View History

2026-01-18 10:23:41 +00:00
# Stage 1: Build the application
2026-01-18 10:57:56 +00:00
FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/node:20-alpine as builder
2026-01-18 10:23:41 +00:00
WORKDIR /app
2026-01-18 10:57:56 +00:00
# Config Aliyun Mirror for Alpine and Yarn
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && \
yarn config set registry https://registry.npmmirror.com
2026-01-18 10:23:41 +00:00
# Copy package files
COPY package.json yarn.lock ./
# Install dependencies
RUN yarn install
# Copy source code
COPY . .
# Build the application
# Note: Vite embeds VITE_ env vars at build time.
# Ensure .env is present or args are passed if dynamic config is needed.
RUN yarn build
# Stage 2: Serve with Nginx
2026-01-18 10:57:56 +00:00
FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/nginx:alpine
2026-01-18 10:23:41 +00:00
# Remove default nginx static assets
RUN rm -rf /usr/share/nginx/html/*
# Copy built assets from builder stage
COPY --from=builder /app/dist /usr/share/nginx/html
# Copy custom nginx config
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]