diff --git a/docker-compose.base.yml b/docker-compose.base.yml new file mode 100644 index 0000000..15a7fa5 --- /dev/null +++ b/docker-compose.base.yml @@ -0,0 +1,23 @@ +services: + golang-builder: + build: + dockerfile_inline: | + FROM golang:alpine + RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \ + && apk add --no-cache git ca-certificates tzdata + ENV TZ=Asia/Shanghai + ENV GO111MODULE=on + ENV GOPROXY=https://goproxy.cn,direct + ENV CGO_ENABLED=0 + ENV GOTOOLCHAIN=auto + image: video-factory-builder:base + + alpine-runtime: + build: + dockerfile_inline: | + FROM alpine:3.19 + RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \ + && apk add --no-cache ca-certificates tzdata ffmpeg + ENV TZ=Asia/Shanghai + RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + image: video-factory-runtime:base diff --git a/docker-compose.yml b/docker-compose.yml index 7490547..0820a31 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,24 +2,13 @@ services: video-factory: build: dockerfile_inline: | - FROM golang:alpine AS builder - RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \ - && apk add --no-cache git ca-certificates tzdata - ENV TZ=Asia/Shanghai - ENV GO111MODULE=on - ENV GOPROXY=https://goproxy.cn,direct - ENV CGO_ENABLED=0 - ENV GOTOOLCHAIN=auto + FROM video-factory-builder:base AS builder WORKDIR /build COPY . . RUN go mod download && go mod tidy RUN go build -ldflags="-s -w" -o main ./main.go - FROM alpine:3.19 - RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \ - && apk add --no-cache ca-certificates tzdata ffmpeg - ENV TZ=Asia/Shanghai - RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + FROM video-factory-runtime:base WORKDIR /app COPY --from=builder /build/config.yml . COPY --from=builder /build/prompt.md .