From d282e2e5e66c44fe7fea7f530837aeeffa5c4b40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Skyler=20M=C3=A4ntysaari?= Date: Wed, 1 Sep 2021 03:16:01 +0300 Subject: [PATCH 1/9] CI: Login to Docker Hub and other tweaks --- .github/workflows/main.yml | 71 ++++++++++++++++++++++++++++++++++++++ Makefile | 1 - image/Dockerfile | 2 +- 3 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..f1a0910 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,71 @@ +name: Release + +on: + workflow_dispatch: + push: + branches: + - move-to-github-actions + + +jobs: + build: + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, '[ci-skip]')" + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Prepare + id: prep + run: | + DOCKER_IMAGE=${{ secrets.DOCKER_USERNAME }}/${GITHUB_REPOSITORY#*/} + VERSION=latest + SHORTREF=${GITHUB_SHA::8} + + # If this is git tag, use the tag name as a docker tag + if [[ $GITHUB_REF == refs/tags/* ]]; then + VERSION=${GITHUB_REF#refs/tags/v} + fi + TAGS="${DOCKER_IMAGE}:${VERSION},${DOCKER_IMAGE}:${SHORTREF}" + + # If the VERSION looks like a version number, assume that + # this is the most recent version of the image and also + # tag it 'latest'. + if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then + TAGS="$TAGS,${DOCKER_IMAGE}:latest" + fi + + # Set output parameters. + + echo ::set-output name=tags::${TAGS} + echo ::set-output name=docker_image::${DOCKER_IMAGE} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + with: + platforms: amd64,arm64 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + with: + install: true + version: latest + driver-opts: image=moby/buildkit:latest + + - name: Login to Docker Hub + if: github.event_name != 'pull_request' + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and Push + uses: docker/build-push-action@v2 + with: + build-args: VERSION=focal-1.0.0-test + builder: ${{ steps.buildx.outputs.name }} + context: image + platforms: amd64,arm64 + push: true + tags: ${{ steps.prep.outputs.tags }} diff --git a/Makefile b/Makefile index 0a78cec..fe24996 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,6 @@ VERSION_ARG ?= $(VERSION) all: build build: - ./build.sh docker build --no-cache -t $(NAME):$(VERSION_ARG) $(BUILD_ARG) --build-arg QEMU_ARCH=$(QEMU_ARCH) --platform $(PLATFORM) --rm image build_multiarch: diff --git a/image/Dockerfile b/image/Dockerfile index 7e074d5..b800988 100644 --- a/image/Dockerfile +++ b/image/Dockerfile @@ -2,7 +2,7 @@ ARG BASE_IMAGE=ubuntu:20.04 FROM $BASE_IMAGE ARG QEMU_ARCH -ADD x86_64_qemu-${QEMU_ARCH}-static.tar.gz /usr/bin +#ADD x86_64_qemu-${QEMU_ARCH}-static.tar.gz /usr/bin COPY . /bd_build From 2a65ac4630b750956f8c181284d7184bc49b683d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Skyler=20M=C3=A4ntysaari?= Date: Thu, 2 Sep 2021 01:36:16 +0300 Subject: [PATCH 2/9] CI: Remember to mimic the Makefile [ci-skip] --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f1a0910..d3c6c40 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,7 +18,7 @@ jobs: - name: Prepare id: prep run: | - DOCKER_IMAGE=${{ secrets.DOCKER_USERNAME }}/${GITHUB_REPOSITORY#*/} + DOCKER_IMAGE=${{ secrets.DOCKER_USERNAME }}/baseimage VERSION=latest SHORTREF=${GITHUB_SHA::8} From a81d149a76b6bcc032fa8d3f4a373cd8e6f3d669 Mon Sep 17 00:00:00 2001 From: Travis Rowland Date: Thu, 2 Sep 2021 11:54:46 -0600 Subject: [PATCH 3/9] Update GHA file --- .github/workflows/main.yml | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d3c6c40..331efac 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,22 +18,9 @@ jobs: - name: Prepare id: prep run: | - DOCKER_IMAGE=${{ secrets.DOCKER_USERNAME }}/baseimage - VERSION=latest - SHORTREF=${GITHUB_SHA::8} - - # If this is git tag, use the tag name as a docker tag - if [[ $GITHUB_REF == refs/tags/* ]]; then - VERSION=${GITHUB_REF#refs/tags/v} - fi - TAGS="${DOCKER_IMAGE}:${VERSION},${DOCKER_IMAGE}:${SHORTREF}" - - # If the VERSION looks like a version number, assume that - # this is the most recent version of the image and also - # tag it 'latest'. - if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then - TAGS="$TAGS,${DOCKER_IMAGE}:latest" - fi + DOCKER_IMAGE=phusion/baseimage + + TAGS="${DOCKER_IMAGE}:${GITHUB_REF}" # Set output parameters. From 18c6aeeafa45017b7a70ccc3c99c5ed8290b6cb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Skyler=20M=C3=A4ntysaari?= Date: Thu, 2 Sep 2021 21:04:44 +0300 Subject: [PATCH 4/9] Update Github Action --- .github/workflows/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 331efac..0b30a32 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,8 +19,9 @@ jobs: id: prep run: | DOCKER_IMAGE=phusion/baseimage + VERSION=focal-test - TAGS="${DOCKER_IMAGE}:${GITHUB_REF}" + TAGS="${DOCKER_IMAGE}:${VERSION},${DOCKER_IMAGE}:${SHORTREF}" # Set output parameters. From 227465e2d6dcbfbf1d7e361ccb8e6d277d34b436 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Skyler=20M=C3=A4ntysaari?= Date: Thu, 2 Sep 2021 21:09:37 +0300 Subject: [PATCH 5/9] CI: Figuring out the branch to image name --- .github/workflows/main.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0b30a32..af2f517 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,12 +20,13 @@ jobs: run: | DOCKER_IMAGE=phusion/baseimage VERSION=focal-test - - TAGS="${DOCKER_IMAGE}:${VERSION},${DOCKER_IMAGE}:${SHORTREF}" + GIT_BRANCH=${GITHUB_REF##*/} + TAGS="${DOCKER_IMAGE}:${GIT_BRANCH}" # Set output parameters. echo ::set-output name=tags::${TAGS} + echo ::set-output name=branch::${GIT_BRANCH} echo ::set-output name=docker_image::${DOCKER_IMAGE} - name: Set up QEMU From 157deafb0eb12f26c971ffc425a5b9073fdf41ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Skyler=20M=C3=A4ntysaari?= Date: Thu, 2 Sep 2021 21:40:33 +0300 Subject: [PATCH 6/9] CI: Github Container Registry too --- .github/workflows/main.yml | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index af2f517..5d36475 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,20 +19,31 @@ jobs: id: prep run: | DOCKER_IMAGE=phusion/baseimage - VERSION=focal-test GIT_BRANCH=${GITHUB_REF##*/} - TAGS="${DOCKER_IMAGE}:${GIT_BRANCH}" + TAGS="${DOCKER_IMAGE}:${GIT_BRANCH}, ghcr.io/${{ github.repository_owner }}/baseimage:${GIT_BRANCH}" # Set output parameters. - echo ::set-output name=tags::${TAGS} - echo ::set-output name=branch::${GIT_BRANCH} - echo ::set-output name=docker_image::${DOCKER_IMAGE} - + if [ "${{github.event_name}}" == "pull_request" ]; then + echo ::set-output name=push::false + else + echo ::set-output name=tags::${TAGS} + echo ::set-output name=branch::${GIT_BRANCH} + echo ::set-output name=docker_image::${DOCKER_IMAGE} + fi + - name: Set up QEMU uses: docker/setup-qemu-action@v1 with: platforms: amd64,arm64 + + - name: Login to GHCR (Github Container Registry) + uses: docker/login-action@v1 + if: github.event_name != 'pull_request' + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Set up Docker Buildx id: buildx @@ -41,6 +52,7 @@ jobs: install: true version: latest driver-opts: image=moby/buildkit:latest + - name: Login to Docker Hub if: github.event_name != 'pull_request' @@ -52,9 +64,8 @@ jobs: - name: Build and Push uses: docker/build-push-action@v2 with: - build-args: VERSION=focal-1.0.0-test builder: ${{ steps.buildx.outputs.name }} context: image platforms: amd64,arm64 - push: true + push: ${{ steps.prep.outputs.push }} tags: ${{ steps.prep.outputs.tags }} From 8e9a043cd2a104f79cc5f7300aaaa5a17adfafbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Skyler=20M=C3=A4ntysaari?= Date: Thu, 2 Sep 2021 21:42:40 +0300 Subject: [PATCH 7/9] CI: Fix typo --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5d36475..d094e8d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -27,6 +27,7 @@ jobs: if [ "${{github.event_name}}" == "pull_request" ]; then echo ::set-output name=push::false else + echo ::set-output name=push::true echo ::set-output name=tags::${TAGS} echo ::set-output name=branch::${GIT_BRANCH} echo ::set-output name=docker_image::${DOCKER_IMAGE} From 2edaaf9cd4db8660d4fee388575ae61e7485da13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Skyler=20M=C3=A4ntysaari?= Date: Thu, 2 Sep 2021 22:03:10 +0300 Subject: [PATCH 8/9] CI: Update the README and branch to execute on. [ci-skip] --- .circleci/config.yml | 21 --------------- .github/workflows/main.yml | 4 +-- .travis.yml | 53 -------------------------------------- README.md | 3 +-- 4 files changed, 3 insertions(+), 78 deletions(-) delete mode 100644 .circleci/config.yml delete mode 100644 .travis.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index a2ed39c..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,21 +0,0 @@ -version: 2 -jobs: - build: - machine: true - steps: - - checkout - #- run: - # name : Getting docker - # command: curl https://get.docker.com | sh - - run: - name: Enabling qemu - command: docker run --rm --privileged multiarch/qemu-user-static:register --reset - - run: - name: Building arm based image. - command: docker build -t arm-test . - - run: - name: Listing built images - command: docker images - # - run: - # name: Running arm based image. - # command: docker run --rm arm-test \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d094e8d..252502c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,8 +4,8 @@ on: workflow_dispatch: push: branches: - - move-to-github-actions - + - focal-1.1.0 + - master jobs: build: diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 64c33bb..0000000 --- a/.travis.yml +++ /dev/null @@ -1,53 +0,0 @@ -os: linux - -dist: focal - -language: c - -services: - - docker - -addons: - apt: - packages: - - docker-ce - - qemu-user-static - -env: - global: - # - VERSION=${TRAVIS_TAG} - - VERSION=${TRAVIS_BRANCH} - - DOCKER_CLI_EXPERIMENTAL=enabled - - QEMU_VERSION=v6.1.0-1 - - matrix: - # PLATFORM = Base image architecture to be used - # QEMU_ARCH = qemu binary to be downloaded from https://github.com/multiarch/qemu-user-static/releases - # TAG_ARCH = Tag to be applied to the image when upload to DockerHub -# - PLATFORM=amd64 QEMU_ARCH=i386 TAG_ARCH=386 - - PLATFORM=amd64 QEMU_ARCH=amd64 TAG_ARCH=amd64 - - PLATFORM=arm64 QEMU_ARCH=aarch64 TAG_ARCH=arm64 -# - PLATFORM=arm QEMU_ARCH=arm TAG_ARCH=arm -# - PLATFORM=ppc64le QEMU_ARCH=ppc64le TAG_ARCH=ppc64le -# - PLATFORM=s390x QEMU_ARCH=s390x TAG_ARCH=s390x - -before_script: - - echo '{"experimental":true}' | sudo tee /etc/docker/daemon.json - - sudo service docker restart - -script: - - make build test - - if [[ $TRAVIS_PULL_REQUEST == 'false' ]]; then - docker login -u "${DOCKER_USERNAME}" -p "${DOCKER_PASSWORD}"; - make release; - fi - -jobs: - include: - - stage: deploy - env: - - ARCHS="amd64 arm64" - script: - - echo $NAME:$VERSION_TAG - - echo "$DOCKER_PASSWORD" | docker login --username "$DOCKER_USERNAME" --password-stdin - - make build_multiarch diff --git a/README.md b/README.md index 92055aa..2f4b64b 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # A minimal Ubuntu base image modified for Docker-friendliness -[![](https://badge.imagelayers.io/phusion/baseimage:latest.svg)](https://imagelayers.io/?images=phusion/baseimage:latest 'Get your own badge on imagelayers.io') -[![Travis](https://img.shields.io/travis/phusion/baseimage-docker.svg)](https://travis-ci.org/phusion/baseimage-docker) +[![Release](https://github.com/phusion/baseimage-docker/actions/workflows/main.yml/badge.svg?branch=focal-1.1.0)](https://github.com/phusion/baseimage-docker/actions/workflows/main.yml) _Baseimage-docker only consumes 8.3 MB RAM and is much more powerful than Busybox or Alpine. See why below._ From 107a17dd85272063d63a5a00742fa4ff4bd8843f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Skyler=20M=C3=A4ntysaari?= Date: Thu, 2 Sep 2021 22:30:20 +0300 Subject: [PATCH 9/9] CI: Add arm platform too. Fixes: #518 --- .github/workflows/main.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 252502c..86eb8ae 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,6 +20,8 @@ jobs: run: | DOCKER_IMAGE=phusion/baseimage GIT_BRANCH=${GITHUB_REF##*/} + # Set the platforms to build for here and thus reduce duplicating it. + PLATFORMS=amd64,arm,arm64 TAGS="${DOCKER_IMAGE}:${GIT_BRANCH}, ghcr.io/${{ github.repository_owner }}/baseimage:${GIT_BRANCH}" # Set output parameters. @@ -32,11 +34,13 @@ jobs: echo ::set-output name=branch::${GIT_BRANCH} echo ::set-output name=docker_image::${DOCKER_IMAGE} fi - + echo ::set-output name=platforms::${PLATFORMS} + + - name: Set up QEMU uses: docker/setup-qemu-action@v1 with: - platforms: amd64,arm64 + platforms: ${{ steps.prep.outputs.platforms }} - name: Login to GHCR (Github Container Registry) uses: docker/login-action@v1 @@ -67,6 +71,6 @@ jobs: with: builder: ${{ steps.buildx.outputs.name }} context: image - platforms: amd64,arm64 + platforms: ${{ steps.prep.outputs.platforms }} push: ${{ steps.prep.outputs.push }} tags: ${{ steps.prep.outputs.tags }}