Files
video-factory/Dockerfile
T
2026-08-04 15:25:11 +08:00

41 lines
1.7 KiB
Docker
Raw 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.
# ==================== 前端构建(ui-src ====================
FROM node:20-alpine AS ui-builder
RUN apk add --no-cache git
WORKDIR /build-ui
COPY video-factory/ui-src/package.json video-factory/ui-src/package-lock.json ./
RUN npm ci --registry=https://registry.npmmirror.com
COPY video-factory/ui-src/ ./
RUN npm run build
# ==================== 后端构建 ====================
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
WORKDIR /build
COPY video-factory/ .
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
WORKDIR /app
COPY --from=builder /build/config.yml .
COPY --from=builder /build/prompt.md .
COPY --from=builder /build/negative_prompt.md .
COPY --from=builder /build/default_first_frame.png .
COPY --from=builder /build/main .
COPY --from=ui-builder /build-ui/dist ./ui-src/dist
RUN mkdir -p /app/data \
&& printf '#!/bin/sh\nfor db in business.db system.db finance.db; do\n if [ -d /app/data/$db ]; then rm -rf /app/data/$db; fi\n touch /app/data/$db 2>/dev/null || true\ndone\nexec ./main\n' > /app/entrypoint.sh && chmod +x /app/entrypoint.sh
EXPOSE 3006
ENTRYPOINT ["/app/entrypoint.sh"]