ci: build CLI artifacts with Docker
Build and Deploy / deploy (push) Successful in 10m13s

This commit is contained in:
loveuer
2026-09-21 03:02:08 -07:00
parent 557ace6150
commit f1411aaeae
3 changed files with 37 additions and 4 deletions
+1
View File
@@ -1,5 +1,6 @@
.git/ .git/
data/ data/
dist/
ufile ufile
frontend/node_modules/ frontend/node_modules/
frontend/dist/ frontend/dist/
+17 -4
View File
@@ -12,11 +12,24 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Build CLI binaries - name: Build CLI artifact image
run: ./scripts/build-cli.sh run: |
docker build \
--target cli-artifacts \
--build-arg GOPROXY=https://goproxy.cn,direct \
--build-arg VERSION=${{ github.sha }} \
--build-arg COMMIT=${{ github.sha }} \
-t ufile-cli-artifacts:latest .
- name: Verify CLI checksums - name: Extract CLI binaries
run: cd dist && sha256sum -c checksums.txt run: |
container="ufile-cli-artifacts-$$"
docker run -d --name "$container" ufile-cli-artifacts:latest
trap 'docker rm -f "$container" >/dev/null 2>&1 || true' EXIT
mkdir -p dist
docker cp "$container:/dist/." dist/
cd dist
sha256sum -c checksums.txt
- name: Build image - name: Build image
run: docker build --build-arg GOPROXY=https://goproxy.cn,direct -t ufile:latest . run: docker build --build-arg GOPROXY=https://goproxy.cn,direct -t ufile:latest .
+19
View File
@@ -18,6 +18,25 @@ COPY *.go ./
COPY --from=frontend /src/frontend/dist ./frontend/dist COPY --from=frontend /src/frontend/dist ./frontend/dist
RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" -o /ufile . RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" -o /ufile .
FROM golang:1.24-alpine AS cli-builder
ARG GOPROXY=https://proxy.golang.org,direct
ARG VERSION=dev
ARG COMMIT=unknown
ENV GOPROXY=${GOPROXY}
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY cmd/ufile-cli/ ./cmd/ufile-cli/
COPY scripts/build-cli.sh ./scripts/build-cli.sh
RUN VERSION="${VERSION}" COMMIT="${COMMIT}" ./scripts/build-cli.sh
FROM alpine:3.22 AS cli-artifacts
COPY --from=cli-builder /src/dist /dist
CMD ["sh", "-c", "while :; do sleep 3600; done"]
FROM alpine:3.22 FROM alpine:3.22
RUN addgroup -S -g 10001 ufile \ RUN addgroup -S -g 10001 ufile \