diff --git a/.drone.yml b/.drone.yml index 9fb403f..a65fd87 100644 --- a/.drone.yml +++ b/.drone.yml @@ -2,29 +2,7 @@ kind: pipeline type: docker name: 构建 Goose -workspace: - path: /drone/src - steps: - - name: 构建 Goose 二进制包 - image: golang:latest - environment: - USERNAME: - from_secret: USERNAME - PASSWORD: - from_secret: API_KEY - volumes: - - name: place-goose - path: /place-goose - commands: - - git clone https://github.com/pressly/goose.git - - cd goose - - go build -tags='no_mysql no_ydb no_vertica no_mssql no_libsql no_sqlite3 no_clickhouse' -o goose ./cmd/goose - - mv goose ../goose-bin - - cd .. - - curl --user $USERNAME:$PASSWORD --upload-file ./goose-bin https://gitea.service.jazzwhom.top/api/packages/kagami-public/generic/goose/$DRONE_BUILD_NUMBER/goose - - mv ./goose-bin /place-goose/goose - - name: 构建 Goose Docker 包 image: docker:latest privileged: true @@ -39,11 +17,8 @@ steps: volumes: - name: docker-socket path: /var/run/docker.sock - - name: place-goose - path: /place-goose commands: - - mv /place-goose/goose /drone/src/goose-bin - echo "$PASSWORD" | docker login -u "$USERNAME" --password-stdin "$DOCKER_REGISTRY" - docker build -t "$DOCKER_REGISTRY/$DOCKER_ORGANIZATION/$DOCKER_APPLICATION:$DRONE_BUILD_NUMBER" . - docker build -t "$DOCKER_REGISTRY/$DOCKER_ORGANIZATION/$DOCKER_APPLICATION:latest" . @@ -53,6 +28,4 @@ steps: volumes: - name: docker-socket host: - path: /var/run/docker.sock - - name: place-goose - temp: {} \ No newline at end of file + path: /var/run/docker.sock \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 61f4049..a7e2acb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,17 @@ -FROM scratch -COPY goose-bin /goose -WORKDIR / -RUN chmod +x /goose -ENTRYPOINT ["/goose"] \ No newline at end of file +FROM alpine:3.19 AS downloader +WORKDIR /app + +ARG GOOSE_VERSION="v3.24.3" +ARG GOOSE_ARCH="linux_x86_64" +ARG GOOSE_FILENAME="goose_${GOOSE_ARCH}" +ARG DOWNLOAD_URL="https://github.com/pressly/goose/releases/download/${GOOSE_VERSION}/${GOOSE_FILENAME}" + +RUN apk add --no-cache curl +RUN curl -L -o /app/goose "${DOWNLOAD_URL}" +RUN chmod +x /app/goose + +FROM scratch AS final +WORKDIR /usr/local/bin +COPY --from=downloader /app/goose . +ENTRYPOINT ["/usr/local/bin/goose"] +CMD ["--help"] \ No newline at end of file