45 lines
1.1 KiB
Docker
45 lines
1.1 KiB
Docker
# 阶段1: 构建
|
||
FROM golang:alpine AS builder
|
||
|
||
RUN apk add --no-cache git ca-certificates tzdata
|
||
|
||
ENV TZ=Asia/Shanghai
|
||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||
|
||
ENV GO111MODULE=on
|
||
ENV GOPROXY=https://goproxy.cn,direct
|
||
ENV CGO_ENABLED=0
|
||
ENV GOTOOLCHAIN=auto
|
||
WORKDIR /build
|
||
|
||
COPY . .
|
||
|
||
RUN go mod download && go mod tidy
|
||
|
||
RUN go build -ldflags="-s -w" -o main ./main.go
|
||
|
||
|
||
# 阶段2: 运行时(预装 FFmpeg + Node.js + HyperFrames)
|
||
FROM alpine:3.19
|
||
|
||
# nodejs/npm 在 community 仓库,需启用
|
||
RUN echo "https://dl-cdn.alpinelinux.org/alpine/v3.19/community" >> /etc/apk/repositories \
|
||
&& apk add --no-cache ca-certificates tzdata ffmpeg nodejs npm
|
||
|
||
ENV TZ=Asia/Shanghai
|
||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||
|
||
# 预装 HyperFrames(全局安装)
|
||
RUN npm install -g hyperframes
|
||
|
||
WORKDIR /app
|
||
|
||
# 复制二进制和运行时必需的文件
|
||
COPY --from=builder /build/main .
|
||
COPY --from=builder /build/config.yml .
|
||
COPY --from=builder /build/scripts ./scripts
|
||
|
||
EXPOSE 3010
|
||
|
||
CMD ["./main"]
|