nex_music/Dockerfile

38 lines
990 B
Docker

# Stage 1: Build the application
FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/node:20-alpine as builder
WORKDIR /app
# 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
# 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
FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/nginx:alpine
# 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;"]