diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..a24a978 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,76 @@ +name: Build Multi Stage Docker Image +on: + push: + branches-ignore: + - 'dependabot/**' + schedule: + - cron: '0 5 * * *' + +jobs: + GHRC: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2.3.4 + + - uses: FranzDiebold/github-env-vars-action@v2.3.0 + - name: Print environment variables + run: | + echo "CI_REPOSITORY_NAME=$CI_REPOSITORY_NAME" + + - name: Prepare GHRC.io + id: prep + run: | + REPO=$CI_REPOSITORY_NAME + DOCKER_IMAGE=${{ github.repository_owner }}/${REPO} + if [ "$CI_REF_NAME" == "master" ];then VERSION=latest;fi + if [ "$CI_REF_NAME" == "dev" ];then VERSION=mightly;fi + if [ "$CI_REF_NAME" == "dockserver" ];then VERSION=dockserver;fi + TAGS="${DOCKER_IMAGE}:${VERSION}" + echo ::set-output name=tags::${TAGS} + echo ::set-output name=title::${GITHUB_REPOSITORY} + echo ::set-output name=version::${VERSION} + echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ') + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + with: + platforms: linux/amd64,linux/armhf,linux/arm64 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1.3.0 + + - name: Cache Docker layers + uses: actions/cache@v2.1.6 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Login to GitHub Container Registry + if: github.event_name != 'pull_request' + uses: docker/login-action@v1.9.0 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.CR_PAT }} + + - name: Build and push GHRC.io + id: docker_build + uses: docker/build-push-action@v2.5.0 + with: + builder: ${{ steps.buildx.outputs.name }} + context: . + file: ./Dockerfile + platforms: linux/amd64,linux/armhf,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ghcr.io/${{ steps.prep.outputs.tags }} + labels: | + org.opencontainers.image.title=${{ steps.prep.outputs.title }} + org.opencontainers.image.version=${{ steps.prep.outputs.version }} + org.opencontainers.image.created=${{ steps.prep.outputs.created }} + + - name: Image digest + run: echo ${{ steps.docker_build.outputs.digest }} diff --git a/Dockerfile b/Dockerfile index aa71ed8..49ecdef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ FROM python:3-alpine +LABEL org.opencontainers.image.source https://github.com/Red5d/docker-autocompose WORKDIR /usr/src/app