1
This commit is contained in:
27
Dockerfile
27
Dockerfile
@@ -1,21 +1,24 @@
|
|||||||
# 前端 + API 一体化镜像
|
# 仅后端 API 镜像(前端自行部署)
|
||||||
# 国内服务器拉取慢时,可加 --build-arg REGISTRY=docker.m.daocloud.io/library
|
# 国内服务器拉取慢时,可加 --build-arg REGISTRY=docker.m.daocloud.io/library
|
||||||
ARG REGISTRY=
|
ARG REGISTRY=
|
||||||
FROM ${REGISTRY}node:20-alpine AS frontend-builder
|
FROM ${REGISTRY}node:20-slim
|
||||||
WORKDIR /app
|
|
||||||
ARG VITE_MAPBOX_ACCESS_TOKEN
|
RUN npm config set registry https://registry.npmmirror.com
|
||||||
ENV VITE_MAPBOX_ACCESS_TOKEN=${VITE_MAPBOX_ACCESS_TOKEN}
|
|
||||||
RUN apk add --no-cache python3 make g++
|
# Debian 12 使用 sources.list.d,改为国内源避免 build 时连接超时
|
||||||
COPY package*.json ./
|
RUN rm -f /etc/apt/sources.list.d/debian.sources && \
|
||||||
RUN npm ci
|
echo 'deb http://mirrors.aliyun.com/debian bookworm main' > /etc/apt/sources.list && \
|
||||||
COPY . .
|
echo 'deb http://mirrors.aliyun.com/debian bookworm-updates main' >> /etc/apt/sources.list && \
|
||||||
RUN npm run build
|
echo 'deb http://mirrors.aliyun.com/debian-security bookworm-security main' >> /etc/apt/sources.list && \
|
||||||
|
apt-get update && apt-get install -y --no-install-recommends python3 make g++ && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
|
||||||
FROM ${REGISTRY}node:20-alpine
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
RUN npm ci --omit=dev
|
RUN npm ci --omit=dev
|
||||||
COPY --from=frontend-builder /app/dist ./dist
|
|
||||||
COPY server ./server
|
COPY server ./server
|
||||||
|
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
|
|||||||
Reference in New Issue
Block a user