1
This commit is contained in:
@@ -1,11 +1,14 @@
|
|||||||
FROM node:20-alpine AS builder
|
# 国内服务器可设 REGISTRY_MIRROR 拉取镜像,例: docker.m.daocloud.io/library/
|
||||||
|
ARG REGISTRY_MIRROR=
|
||||||
|
FROM ${REGISTRY_MIRROR}node:20-alpine AS builder
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY package.json package-lock.json* ./
|
COPY package.json package-lock.json* ./
|
||||||
RUN npm ci --legacy-peer-deps 2>/dev/null || npm install --legacy-peer-deps
|
RUN npm ci --legacy-peer-deps 2>/dev/null || npm install --legacy-peer-deps
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
FROM nginx:alpine
|
ARG REGISTRY_MIRROR=
|
||||||
|
FROM ${REGISTRY_MIRROR}nginx:alpine
|
||||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||||
RUN echo 'server { listen 80; location /admin/ { alias /usr/share/nginx/html/; try_files $uri $uri/ /admin/index.html; } }' > /etc/nginx/conf.d/default.conf
|
RUN echo 'server { listen 80; location /admin/ { alias /usr/share/nginx/html/; try_files $uri $uri/ /admin/index.html; } }' > /etc/nginx/conf.d/default.conf
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
# 复制为 .env 后按需修改(一键脚本会在缺失时自动复制)
|
# 复制为 .env 后按需修改(一键脚本会在缺失时自动复制)
|
||||||
# Docker 部署时 MONGODB_URI 使用 mongo:27017(compose 服务名)
|
# 本地开发:先启动 MongoDB,改为 mongodb://localhost:27017
|
||||||
|
# Docker 部署:保持 mongodb://mongo:27017(compose 服务名)
|
||||||
|
|
||||||
MONGODB_URI=mongodb://mongo:27017
|
MONGODB_URI=mongodb://mongo:27017
|
||||||
MONGODB_DB=yxd-agent-testing
|
MONGODB_DB=yxd-agent-testing
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
# 需在项目根目录构建: docker build -f server/Dockerfile .
|
# 需在项目根目录构建: docker build -f server/Dockerfile .
|
||||||
# 使用 vendor 构建,无需在构建时访问 proxy.golang.org(服务器无外网时也能 build)
|
# 使用 vendor 构建,无需在构建时访问 proxy.golang.org(服务器无外网时也能 build)
|
||||||
FROM golang:1.21-alpine AS builder
|
# 国内服务器可设 REGISTRY_MIRROR 拉取镜像,例: docker.m.daocloud.io/library/
|
||||||
|
ARG REGISTRY_MIRROR=
|
||||||
|
FROM ${REGISTRY_MIRROR}golang:1.21-alpine AS builder
|
||||||
WORKDIR /build
|
WORKDIR /build
|
||||||
COPY server/ ./
|
COPY server/ ./
|
||||||
# 构建参数:脚本可传 GOPROXY,避免 proxy.golang.org 超时;有 vendor 时主要用 -mod=vendor 离线构建
|
# 构建参数:脚本可传 GOPROXY,避免 proxy.golang.org 超时;有 vendor 时主要用 -mod=vendor 离线构建
|
||||||
@@ -8,7 +10,8 @@ ARG GOPROXY=https://goproxy.cn,direct
|
|||||||
ENV GOPROXY=$GOPROXY
|
ENV GOPROXY=$GOPROXY
|
||||||
RUN CGO_ENABLED=0 go build -mod=vendor -o /app/server .
|
RUN CGO_ENABLED=0 go build -mod=vendor -o /app/server .
|
||||||
|
|
||||||
FROM alpine:3.19
|
ARG REGISTRY_MIRROR=
|
||||||
|
FROM ${REGISTRY_MIRROR}alpine:3.19
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN apk add --no-cache ca-certificates tzdata
|
RUN apk add --no-cache ca-certificates tzdata
|
||||||
ENV TZ=Asia/Shanghai
|
ENV TZ=Asia/Shanghai
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
FROM node:20-alpine AS builder
|
# 国内服务器可设 REGISTRY_MIRROR 拉取镜像,例: docker.m.daocloud.io
|
||||||
|
ARG REGISTRY_MIRROR=
|
||||||
|
FROM ${REGISTRY_MIRROR}node:20-alpine AS builder
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY package.json package-lock.json* ./
|
COPY package.json package-lock.json* ./
|
||||||
RUN npm ci --legacy-peer-deps 2>/dev/null || npm install --legacy-peer-deps
|
RUN npm ci --legacy-peer-deps 2>/dev/null || npm install --legacy-peer-deps
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
FROM nginx:alpine
|
ARG REGISTRY_MIRROR=
|
||||||
|
FROM ${REGISTRY_MIRROR}nginx:alpine
|
||||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||||
RUN echo 'server { listen 80; root /usr/share/nginx/html; index index.html; location / { try_files $uri $uri/ /index.html; } }' > /etc/nginx/conf.d/default.conf
|
RUN echo 'server { listen 80; root /usr/share/nginx/html; index index.html; location / { try_files $uri $uri/ /index.html; } }' > /etc/nginx/conf.d/default.conf
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|||||||
Reference in New Issue
Block a user