Add docker github action

This commit is contained in:
Chocobozzz 2021-11-30 16:00:59 +01:00
parent b202d007cc
commit f3fbbf0140
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
3 changed files with 71 additions and 45 deletions

70
.github/workflows/docker.yml vendored Normal file
View File

@ -0,0 +1,70 @@
name: Docker
on:
push:
branches:
- 'master'
schedule:
- cron: '0 3 * * *'
jobs:
generate-matrix:
name: Generate matrix for Docker build
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: master
- name: Set matrix for build
id: set-matrix
run: |
# FIXME: https://github.com/actions/checkout/issues/290
git fetch --force --tags
one="{ \"file\": \"./support/docker/production/Dockerfile.bullseye\", \"ref\": \"develop\", \"tags\": \"chocobozzz/peertube-test:develop-bullseye\" }"
two="{ \"file\": \"./support/docker/production/Dockerfile.buster\", \"ref\": \"master\", \"tags\": \"chocobozzz/peertube-test:production-buster,chocobozzz/peertube-test:$(git describe --abbrev=0)-buster\" }"
three="{ \"file\": \"./support/docker/production/Dockerfile.nginx\", \"ref\": \"master\", \"tags\": \"chocobozzz/peertube-webserver-test:latest\" }"
matrix="[$one,$two,$three]"
echo ::set-output name=matrix::{\"include\":$(echo $matrix)}
docker:
runs-on: ubuntu-latest
needs: generate-matrix
strategy:
matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
fail-fast: false
steps:
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Checkout develop
uses: actions/checkout@v2
with:
ref: ${{ matrix.ref }}
-
name: Docker build
uses: docker/build-push-action@v2
with:
context: '.'
platforms: linux/amd64,linux/arm64
push: true
file: ${{ matrix.file }}
tags: ${{ matrix.tags }}

View File

@ -1,4 +1,4 @@
name: Stats"
name: Stats
on:
push:

View File

@ -38,47 +38,3 @@ build-nightly:
- eval `ssh-agent -s`
- if [ ! -z ${DEPLOYEMENT_KEY+x} ]; then ssh-add <(echo "${DEPLOYEMENT_KEY}"); fi
- if [ ! -z ${DEPLOYEMENT_KEY+x} ]; then scp ./peertube-nightly-* ${DEPLOYEMENT_USER}@${DEPLOYEMENT_HOST}:../../web/nightly; fi
.docker: &docker
stage: docker-nightly
cache: {}
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
before_script:
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"auth\":\"$CI_REGISTRY_AUTH\",\"email\":\"$CI_REGISTRY_EMAIL\"}}}" > /kaniko/.docker/config.json
script:
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $DOCKERFILE --destination $DOCKER_IMAGE_NAME
build-docker-develop:
<<: *docker
only:
- schedules
variables:
DOCKER_IMAGE_NAME: chocobozzz/peertube:develop-bullseye
DOCKERFILE: $CI_PROJECT_DIR/support/docker/production/Dockerfile.bullseye
build-docker-webserver:
<<: *docker
only:
- schedules
variables:
DOCKER_IMAGE_NAME: chocobozzz/peertube-webserver
DOCKERFILE: $CI_PROJECT_DIR/support/docker/production/Dockerfile.nginx
build-docker-tag:
<<: *docker
only:
- tags
variables:
DOCKER_IMAGE_NAME: chocobozzz/peertube:$CI_COMMIT_TAG-bullseye
DOCKERFILE: $CI_PROJECT_DIR/support/docker/production/Dockerfile.bullseye
build-docker-master:
<<: *docker
only:
- master
variables:
DOCKER_IMAGE_NAME: chocobozzz/peertube:production-bullseye
DOCKERFILE: $CI_PROJECT_DIR/support/docker/production/Dockerfile.bullseye