Publish alpine container (#398)

* Enable build & publish of alpine docker container
 * Delete outdated BUILD file
 * Move Dockerfiles into subdir "docker"
 * Update & format Dockerfiles
 * Introduce "next" tag

Co-authored-by: Anbraten <anton@ju60.de>
This commit is contained in:
6543 2021-10-04 17:09:22 +02:00 committed by GitHub
parent 3837e03866
commit e3354e440f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 98 additions and 94 deletions

View file

@ -1,4 +0,0 @@
*
!release/*
.env

View file

@ -50,16 +50,6 @@ pipeline:
- (cd web/; go generate ./...)
- make release
# publish-server-alpine:
# image: plugins/docker
# repo: woodpeckerci/woodpecker-server
# dockerfile: Dockerfile.alpine
# secrets: [ docker_username, docker_password ]
# tag: [ alpine ]
# when:
# branch: master
# event: push
build-cli:
image: golang:1.16
commands: make release-cli
@ -67,8 +57,21 @@ pipeline:
publish-server:
image: plugins/docker
repo: woodpeckerci/woodpecker-server
dockerfile: docker/Dockerfile.server
secrets: [docker_username, docker_password]
tag: [latest]
# TODO: only release as next after 0.15.0 got released
tag: [next, latest]
when:
branch: master
event: push
publish-server-alpine:
image: plugins/docker
repo: woodpeckerci/woodpecker-server
dockerfile: docker/Dockerfile.server.alpine
secrets: [ docker_username, docker_password ]
# TODO: only release as next-alpine after 0.15.0 got released
tag: [next-alpine, latest-alpine]
when:
branch: master
event: push
@ -76,55 +79,58 @@ pipeline:
publish-agent:
image: plugins/docker
repo: woodpeckerci/woodpecker-agent
dockerfile: Dockerfile.agent
dockerfile: docker/Dockerfile.agent
secrets: [docker_username, docker_password]
tag: [latest]
# TODO: only release as next after 0.15.0 got released
tag: [next, latest]
when:
branch: master
event: push
# publish-agent-alpine:
# image: plugins/docker
# repo: woodpeckerci/woodpecker-agent
# dockerfile: Dockerfile.agent.alpine
# secrets: [ docker_username, docker_password ]
# tag: [ alpine ]
# when:
# branch: master
# event: push
# release-server-alpine:
# image: plugins/docker
# repo: woodpeckerci/woodpecker-server
# dockerfile: Dockerfile.alpine
# secrets: [ docker_username, docker_password ]
# tag: "${DRONE_TAG}-alpine"
# when:
# event: tag
#
# release-agent-alpine:
# image: plugins/docker
# repo: woodpeckerci/woodpecker-agent
# dockerfile: Dockerfile.agent.alpine
# secrets: [ docker_username, docker_password ]
# tag: "${DRONE_TAG}-alpine"
# when:
# event: tag
publish-agent-alpine:
image: plugins/docker
repo: woodpeckerci/woodpecker-agent
dockerfile: docker/Dockerfile.agent.alpine
secrets: [ docker_username, docker_password ]
# TODO: only release as next-alpine after 0.15.0 got released
tag: [next-alpine, latest-alpine]
when:
branch: master
event: push
release-server:
image: plugins/docker
repo: woodpeckerci/woodpecker-server
dockerfile: docker/Dockerfile.server
secrets: [docker_username, docker_password]
tag: ${DRONE_TAG}
tag: [latest, "${DRONE_TAG}"]
when:
event: tag
release-server-alpine:
image: plugins/docker
repo: woodpeckerci/woodpecker-server
dockerfile: docker/Dockerfile.server.alpine
secrets: [ docker_username, docker_password ]
tag: [latest-alpine, "${DRONE_TAG}-alpine"]
when:
event: tag
release-agent:
image: plugins/docker
repo: woodpeckerci/woodpecker-agent
dockerfile: Dockerfile.agent
dockerfile: docker/Dockerfile.agent
secrets: [docker_username, docker_password]
tag: ${DRONE_TAG}
tag: [latest, "${DRONE_TAG}"]
when:
event: tag
release-agent-alpine:
image: plugins/docker
repo: woodpeckerci/woodpecker-agent
dockerfile: docker/Dockerfile.agent.alpine
secrets: [ docker_username, docker_password ]
tag: [latest-alpine, "${DRONE_TAG}-alpine"]
when:
event: tag

View file

@ -1,19 +0,0 @@
1. Install go 1.9 or later
2. Execute `make install` to compile project and install binaries to `GOPATH`
---
0. To generate SQL files
go get github.com/vektra/mockery/.../
export download_url=$(curl -s https://api.github.com/repos/go-swagger/go-swagger/releases/latest | \
jq -r '.assets[] | select(.name | contains("'"$(uname | tr '[:upper:]' '[:lower:]')"'_amd64")) | .browser_download_url')
curl -o swagger -L'#' "$download_url"
chmod +x swagger
sudo mv swagger /usr/local/bin
go get github.com/woodpecker-ci/togo
go generate

View file

@ -1,13 +0,0 @@
# docker build --rm -t woodpeckerci/woodpecker-server .
FROM drone/ca-certs
EXPOSE 8000 9000 80 443
ENV GODEBUG=netdns=go
ENV WOODPECKER_DATABASE_DATASOURCE=/var/lib/drone/drone.sqlite
ENV WOODPECKER_DATABASE_DRIVER=sqlite3
ENV XDG_CACHE_HOME=/var/lib/drone
ADD release/woodpecker-server /bin/
ENTRYPOINT ["/bin/woodpecker-server"]

View file

@ -1,10 +0,0 @@
# docker build --rm -f Dockerfile.agent -t woodpeckerci/woodpecker-agent .
FROM drone/ca-certs
ENV GODEBUG=netdns=go
ADD release/woodpecker-agent /bin/
EXPOSE 3000
HEALTHCHECK CMD ["/bin/woodpecker-agent", "ping"]
ENTRYPOINT ["/bin/woodpecker-agent"]

17
docker/Dockerfile.agent Normal file
View file

@ -0,0 +1,17 @@
# docker build --rm -f docker/Dockerfile.agent -t woodpeckerci/woodpecker-agent .
# 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 release/woodpecker-agent /bin/
EXPOSE 3000
HEALTHCHECK CMD ["/bin/woodpecker-agent", "ping"]
ENTRYPOINT ["/bin/woodpecker-agent"]

View file

@ -1,5 +1,6 @@
FROM alpine:3.9.4
# docker build --rm -f docker/Dockerfile.agent.alpine -t woodpeckerci/woodpecker-agent .
FROM alpine:3.14
RUN apk add -U --no-cache ca-certificates
ENV GODEBUG=netdns=go
@ -9,4 +10,3 @@ EXPOSE 3000
HEALTHCHECK CMD ["/bin/woodpecker-agent", "ping"]
ENTRYPOINT ["/bin/woodpecker-agent"]

20
docker/Dockerfile.server Normal file
View file

@ -0,0 +1,20 @@
# docker build --rm -f docker/Dockerfile.server -t woodpeckerci/woodpecker-server .
# 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
EXPOSE 8000 9000 80 443
ENV GODEBUG=netdns=go
ENV WOODPECKER_DATABASE_DATASOURCE=/var/lib/drone/drone.sqlite
ENV WOODPECKER_DATABASE_DRIVER=sqlite3
ENV XDG_CACHE_HOME=/var/lib/drone
ADD release/woodpecker-server /bin/
ENTRYPOINT ["/bin/woodpecker-server"]

View file

@ -1,8 +1,10 @@
FROM alpine:3.9.4
EXPOSE 8000 9000 80 443
# docker build --rm -f docker/Dockerfile.server.alpine -t woodpeckerci/woodpecker-server .
FROM alpine:3.14
RUN apk add -U --no-cache ca-certificates
EXPOSE 8000 9000 80 443
ENV GODEBUG=netdns=go
ENV WOODPECKER_DATABASE_DATASOURCE=/var/lib/drone/drone.sqlite
ENV WOODPECKER_DATABASE_DRIVER=sqlite3

View file

@ -6,6 +6,11 @@
## Docker images
Image variants:
* The `next` version is based on the current master branch
* The `latest` is same as next (will change after v0.15.0 release to be latest stable release)
* The `x.x.x` version images are stable releases
``` bash
# server
docker pull woodpeckerci/woodpecker-server:latest
@ -15,7 +20,7 @@ docker pull woodpeckerci/woodpecker-server:latest-alpine
docker pull woodpeckerci/woodpecker-agent:latest
docker pull woodpeckerci/woodpecker-agent:latest-alpine
# cli
# TODO: cli
docker pull woodpeckerci/woodpecker-cli:latest
docker pull woodpeckerci/woodpecker-cli:latest-alpine
```