mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-25 11:21:02 +00:00
Multiarch build cli docker images (#634)
This commit is contained in:
parent
bed69f9f72
commit
c2b0c1d73e
5 changed files with 62 additions and 35 deletions
|
@ -25,6 +25,8 @@ pipeline:
|
|||
image: golang:1.16
|
||||
commands:
|
||||
- make release-cli
|
||||
when:
|
||||
event: tag
|
||||
|
||||
build-deb-rpm:
|
||||
group: bundle
|
||||
|
@ -100,13 +102,26 @@ pipeline:
|
|||
branch: ${CI_REPO_DEFAULT_BRANCH}
|
||||
event: push
|
||||
|
||||
publish-cli-dryrun:
|
||||
group: docker
|
||||
image: woodpeckerci/plugin-docker-buildx
|
||||
settings:
|
||||
dry_run: true
|
||||
repo: woodpeckerci/woodpecker-cli
|
||||
dockerfile: docker/Dockerfile.cli.multiarch
|
||||
platforms: linux/arm/v7,linux/arm64/v8,linux/amd64,linux/ppc64le,windows/amd64,darwin/amd64,darwin/arm64
|
||||
tag: test
|
||||
when:
|
||||
event: pull_request
|
||||
|
||||
publish-cli:
|
||||
group: docker
|
||||
image: plugins/docker
|
||||
image: woodpeckerci/plugin-docker-buildx
|
||||
secrets: [docker_username, docker_password]
|
||||
settings:
|
||||
repo: woodpeckerci/woodpecker-cli
|
||||
dockerfile: docker/Dockerfile.cli
|
||||
dockerfile: docker/Dockerfile.cli.multiarch
|
||||
platforms: linux/arm/v7,linux/arm64/v8,linux/amd64,linux/ppc64le,windows/amd64,darwin/amd64,darwin/arm64
|
||||
tag: next
|
||||
when:
|
||||
branch: ${CI_REPO_DEFAULT_BRANCH}
|
||||
|
@ -114,11 +129,12 @@ pipeline:
|
|||
|
||||
publish-cli-alpine:
|
||||
group: docker
|
||||
image: plugins/docker
|
||||
image: woodpeckerci/plugin-docker-buildx
|
||||
secrets: [ docker_username, docker_password ]
|
||||
settings:
|
||||
repo: woodpeckerci/woodpecker-cli
|
||||
dockerfile: docker/Dockerfile.cli.alpine
|
||||
dockerfile: docker/Dockerfile.cli.alpine.multiarch
|
||||
platforms: linux/arm/v7,linux/arm64/v8,linux/amd64,linux/ppc64le
|
||||
tag: next-alpine
|
||||
when:
|
||||
branch: ${CI_REPO_DEFAULT_BRANCH}
|
||||
|
@ -172,22 +188,24 @@ pipeline:
|
|||
|
||||
release-cli:
|
||||
group: docker
|
||||
image: plugins/docker
|
||||
image: woodpeckerci/plugin-docker-buildx
|
||||
secrets: [docker_username, docker_password]
|
||||
settings:
|
||||
repo: woodpeckerci/woodpecker-cli
|
||||
dockerfile: docker/Dockerfile.cli
|
||||
dockerfile: docker/Dockerfile.cli.multiarch
|
||||
platforms: linux/arm/v7,linux/arm64/v8,linux/amd64,linux/ppc64le,windows/amd64,darwin/amd64,darwin/arm64
|
||||
tag: [latest, "${CI_COMMIT_TAG}"]
|
||||
when:
|
||||
event: tag
|
||||
|
||||
release-cli-alpine:
|
||||
group: docker
|
||||
image: plugins/docker
|
||||
image: woodpeckerci/plugin-docker-buildx
|
||||
secrets: [ docker_username, docker_password ]
|
||||
settings:
|
||||
repo: woodpeckerci/woodpecker-cli
|
||||
dockerfile: docker/Dockerfile.cli.alpine
|
||||
dockerfile: docker/Dockerfile.cli.alpine.multiarch
|
||||
platforms: linux/arm/v7,linux/arm64/v8,linux/amd64,linux/ppc64le
|
||||
tag: [latest-alpine, "${CI_COMMIT_TAG}-alpine"]
|
||||
when:
|
||||
event: tag
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
# docker build --rm -f docker/Dockerfile.cli -t woodpeckerci/woodpecker-cli .
|
||||
|
||||
# use golang image to copy ssl certs later
|
||||
FROM golang:1.16
|
||||
|
||||
FROM scratch
|
||||
|
||||
# copy certs from golang:1.16 image
|
||||
COPY --from=0 /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
||||
|
||||
ENV GODEBUG=netdns=go
|
||||
ADD dist/cli/linux_amd64/woodpecker-cli /bin/
|
||||
|
||||
HEALTHCHECK CMD ["/bin/woodpecker-cli", "ping"]
|
||||
|
||||
ENTRYPOINT ["/bin/woodpecker-cli"]
|
|
@ -1,11 +0,0 @@
|
|||
# docker build --rm -f docker/Dockerfile.cli.alpine -t woodpeckerci/woodpecker-cli .
|
||||
|
||||
FROM alpine:3.14
|
||||
RUN apk add -U --no-cache ca-certificates
|
||||
|
||||
ENV GODEBUG=netdns=go
|
||||
ADD dist/cli/linux_amd64/woodpecker-cli /bin/
|
||||
|
||||
HEALTHCHECK CMD ["/bin/woodpecker-cli", "ping"]
|
||||
|
||||
ENTRYPOINT ["/bin/woodpecker-cli"]
|
17
docker/Dockerfile.cli.alpine.multiarch
Normal file
17
docker/Dockerfile.cli.alpine.multiarch
Normal file
|
@ -0,0 +1,17 @@
|
|||
FROM --platform=$BUILDPLATFORM golang:1.16 AS build
|
||||
|
||||
WORKDIR /src
|
||||
COPY . .
|
||||
ARG TARGETOS TARGETARCH
|
||||
RUN --mount=type=cache,target=/root/.cache/go-build \
|
||||
--mount=type=cache,target=/go/pkg \
|
||||
make build-cli
|
||||
|
||||
FROM alpine:3.14
|
||||
RUN apk add -U --no-cache ca-certificates
|
||||
ENV GODEBUG=netdns=go
|
||||
|
||||
COPY --from=build src/dist/woodpecker-cli /bin/
|
||||
|
||||
HEALTHCHECK CMD ["/bin/woodpecker-cli", "ping"]
|
||||
ENTRYPOINT ["/bin/woodpecker-cli"]
|
19
docker/Dockerfile.cli.multiarch
Normal file
19
docker/Dockerfile.cli.multiarch
Normal file
|
@ -0,0 +1,19 @@
|
|||
FROM --platform=$BUILDPLATFORM golang:1.16 AS build
|
||||
|
||||
WORKDIR /src
|
||||
COPY . .
|
||||
ARG TARGETOS TARGETARCH
|
||||
RUN --mount=type=cache,target=/root/.cache/go-build \
|
||||
--mount=type=cache,target=/go/pkg \
|
||||
make build-cli
|
||||
|
||||
FROM scratch
|
||||
ENV GODEBUG=netdns=go
|
||||
|
||||
# copy certs from golang:1.16 image
|
||||
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
||||
# copy cli binary
|
||||
COPY --from=build src/dist/woodpecker-cli /bin/
|
||||
|
||||
HEALTHCHECK CMD ["/bin/woodpecker-cli", "ping"]
|
||||
ENTRYPOINT ["/bin/woodpecker-cli"]
|
Loading…
Reference in a new issue