Files
web/server/Dockerfile

22 lines
941 B
Docker
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 需在项目根目录构建: docker build -f server/Dockerfile .
# 使用 vendor 构建,无需在构建时访问 proxy.golang.org服务器无外网时也能 build
# 国内默认走镜像;海外可 --build-arg REGISTRY_MIRROR= 直连
ARG REGISTRY_MIRROR=docker.m.daocloud.io/library/
FROM ${REGISTRY_MIRROR}golang:1.21-alpine AS builder
WORKDIR /build
COPY server/ ./
# 构建参数:脚本可传 GOPROXY避免 proxy.golang.org 超时;有 vendor 时主要用 -mod=vendor 离线构建
ARG GOPROXY=https://goproxy.cn,direct
ENV GOPROXY=$GOPROXY
RUN CGO_ENABLED=0 go build -mod=vendor -o /app/server .
ARG REGISTRY_MIRROR=docker.m.daocloud.io/library/
FROM ${REGISTRY_MIRROR}alpine:3.19
WORKDIR /app
# 产品视频 .mov → .mp4 服务端转码handlers/promotion_transcode.go
RUN apk add --no-cache ca-certificates tzdata ffmpeg
ENV TZ=Asia/Shanghai
COPY --from=builder /app/server .
EXPOSE 8088
ENTRYPOINT ["./server"]