From 0738a30ad5e162c124ef04f514871e638806d9e3 Mon Sep 17 00:00:00 2001 From: Robert Resch Date: Fri, 8 Apr 2022 23:02:13 +0200 Subject: [PATCH] use python 3.10 and only build image after tests succeeded --- .github/workflows/ci.yml | 47 +++++++++++++++++++++++++---- .github/workflows/docker-images.yml | 43 -------------------------- Dockerfile | 4 +-- 3 files changed, 43 insertions(+), 51 deletions(-) delete mode 100644 .github/workflows/docker-images.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c3ad92e..896f314 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,14 +2,9 @@ name: CI on: push: - branches: - - dev - pull_request: - branches: - - dev env: - DEFAULT_PYTHON: 3.9 + DEFAULT_PYTHON: 3.10 jobs: code-quality: @@ -56,3 +51,43 @@ jobs: uses: codecov/codecov-action@v2 with: fail_ci_if_error: true + + build: + runs-on: ubuntu-latest + permissions: + packages: write + needs: + - tests + steps: + - name: checkout code + uses: actions/checkout@v2 + + - name: Get tag name + shell: bash + run: | + BRANCH=$(echo ${GITHUB_REF#refs/heads/}); + if [ -z $BRANCH ]; then + exit 1; + elif [ $BRANCH == "master" ]; then + BRANCH=latest; + fi + + echo "##[set-output name=tag;]$(echo $BRANCH)" + id: tag_name + + # https://github.com/docker/setup-qemu-action + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + # https://github.com/docker/setup-buildx-action + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to docker hub + run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin + + - name: Build the image + run: | + docker buildx build --push \ + --tag ghcr.io/edenhaus/bumper:${{ steps.tag_name.outputs.tag }} \ + --platform linux/amd64,linux/arm/v7,linux/arm64 . diff --git a/.github/workflows/docker-images.yml b/.github/workflows/docker-images.yml deleted file mode 100644 index 8c48521..0000000 --- a/.github/workflows/docker-images.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: Build docker images - -on: - push: - -jobs: - build: - runs-on: ubuntu-latest - permissions: - packages: write - steps: - - name: checkout code - uses: actions/checkout@v2 - - - name: Get tag name - shell: bash - run: | - BRANCH=$(echo ${GITHUB_REF#refs/heads/}); - if [ -z $BRANCH ]; then - exit 1; - elif [ $BRANCH == "master" ]; then - BRANCH=latest; - fi - - echo "##[set-output name=tag;]$(echo $BRANCH)" - id: tag_name - - # https://github.com/docker/setup-qemu-action - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - # https://github.com/docker/setup-buildx-action - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Login to docker hub - run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin - - - name: Build the image - run: | - docker buildx build --push \ - --tag ghcr.io/edenhaus/bumper:${{ steps.tag_name.outputs.tag }} \ - --platform linux/amd64,linux/arm/v7,linux/arm64 . diff --git a/Dockerfile b/Dockerfile index fe29be4..d09f2f4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ ARG ARCH=amd64 -FROM $ARCH/python:3.9-alpine +FROM $ARCH/python:3.10-alpine EXPOSE 443 EXPOSE 5223 @@ -10,7 +10,7 @@ EXPOSE 8883 COPY requirements.txt /requirements.txt # install required python packages -RUN pip3 install -r requirements.txt +RUN apk add git && pip3 install -r requirements.txt WORKDIR /bumper