Storage all images on Github Docker Registry

This commit is contained in:
BtbN 2020-09-20 15:46:29 +02:00
parent 79e97cc7f2
commit 745db8c050
5 changed files with 46 additions and 23 deletions

View file

@ -14,17 +14,20 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Login to DockerHub
- name: Login to Docker
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_TOKEN }}
registry: docker.pkg.github.com
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Pull latest
run: docker pull btbn/ffmpeg-builder:base || true
run: docker pull docker.pkg.github.com/${GITHUB_REPOSITORY,,}/base:latest || true
- name: Build base image
run: docker build --pull --cache-from btbn/ffmpeg-builder:base --tag btbn/ffmpeg-builder:base images/base
run: |
IMG="docker.pkg.github.com/${GITHUB_REPOSITORY,,}/base:latest"
docker build --pull --cache-from "$IMG" --tag "$IMG" images/base
- name: Push base image
run: docker push btbn/ffmpeg-builder:base
run: docker push docker.pkg.github.com/${GITHUB_REPOSITORY,,}/base:latest
build_target_bases:
name: Build target base image
needs: build_base
@ -36,17 +39,20 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Login to DockerHub
- name: Login to Docker
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_TOKEN }}
registry: docker.pkg.github.com
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Pull latest
run: docker pull btbn/ffmpeg-builder:base-${{ matrix.target }} || true
run: docker pull docker.pkg.github.com/${GITHUB_REPOSITORY,,}/base-${{ matrix.target }}:latest || true
- name: Build target base image
run: docker build --pull --cache-from btbn/ffmpeg-builder:base-${{ matrix.target }} --tag btbn/ffmpeg-builder:base-${{ matrix.target }} images/base-${{ matrix.target }}
run: |
IMG="docker.pkg.github.com/${GITHUB_REPOSITORY,,}/base-${{ matrix.target }}:latest"
docker build --pull --build-arg GH_REPO=${GITHUB_REPOSITORY,,} --cache-from "$IMG" --tag "$IMG" images/base-${{ matrix.target }}
- name: Push target base image
run: docker push btbn/ffmpeg-builder:base-${{ matrix.target }}
run: docker push docker.pkg.github.com/${GITHUB_REPOSITORY,,}/base-${{ matrix.target }}:latest
build_targets:
name: Build target-variant image
needs: build_target_bases
@ -61,17 +67,20 @@ jobs:
uses: actions/checkout@v2
- name: Generate Dockerfile
run: ./generate.sh ${{ matrix.target }} ${{ matrix.variant }}
- name: Login to DockerHub
- name: Login to Docker
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_TOKEN }}
registry: docker.pkg.github.com
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Pull latest
run: docker pull btbn/ffmpeg-builder:${{ matrix.target }}-${{ matrix.variant }} || true
run: docker pull docker.pkg.github.com/${GITHUB_REPOSITORY,,}/${{ matrix.target }}-${{ matrix.variant }}:latest || true
- name: Build variant image
run: docker build --pull --cache-from btbn/ffmpeg-builder:${{ matrix.target }}-${{ matrix.variant }} --tag btbn/ffmpeg-builder:${{ matrix.target }}-${{ matrix.variant }} .
run: |
IMG="docker.pkg.github.com/${GITHUB_REPOSITORY,,}/${{ matrix.target }}-${{ matrix.variant }}:latest"
docker build --pull --cache-from "$IMG" --tag "$IMG" .
- name: Push variant image
run: docker push btbn/ffmpeg-builder:${{ matrix.target }}-${{ matrix.variant }}
run: docker push docker.pkg.github.com/${GITHUB_REPOSITORY,,}/${{ matrix.target }}-${{ matrix.variant }}:latest
build_ffmpeg:
name: Build ffmpeg
needs: build_targets
@ -84,6 +93,12 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Login to Docker
uses: docker/login-action@v1
with:
registry: docker.pkg.github.com
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Build ffmpeg
run: ./build.sh ${{ matrix.target }} ${{ matrix.variant }}
- name: Upload artifacts

View file

@ -10,7 +10,7 @@ to_df() {
echo >> Dockerfile
}
to_df "FROM $REPO:base-$TARGET"
to_df "FROM docker.pkg.github.com/${REPO}/base-${TARGET}:latest"
to_df "ENV TARGET=$TARGET VARIANT=$VARIANT REPO=$REPO"
for script in scripts.d/*.sh; do

View file

@ -1,4 +1,5 @@
FROM btbn/ffmpeg-builder:base
ARG GH_REPO=btbn/ffmpeg-builds
FROM docker.pkg.github.com/$GH_REPO/base:latest
ENV DEBIAN_FRONTEND noninteractive

View file

@ -3,6 +3,9 @@ set -xe
cd "$(dirname "$0")"
source util/vars.sh
docker build --cache-from "$BASE_IMAGE" --tag "$BASE_IMAGE" images/base
docker build --build-arg GH_REPO="$REPO" --cache-from "$TARGET_IMAGE" --tag "$TARGET_IMAGE" "images/base-${TARGET}"
./generate.sh "$TARGET" "$VARIANT"
exec docker build -t "$IMAGE" .
exec docker build --cache-from "$IMAGE" --tag "$IMAGE" .

View file

@ -7,8 +7,12 @@ fi
TARGET="$1"
VARIANT="${2:-gpl}"
REPO="${DOCKER_REPO:-btbn/ffmpeg-builder}"
IMAGE="$REPO:$TARGET-$VARIANT"
REPO="${GITHUB_REPOSITORY:-btbn/ffmpeg-builds}"
REPO="${REPO,,}"
REGISTRY="docker.pkg.github.com"
BASE_IMAGE="${REGISTRY}/${REPO}/base:latest"
TARGET_IMAGE="${REGISTRY}/${REPO}/base-${TARGET}:latest"
IMAGE="${REGISTRY}/${REPO}/${TARGET}-${VARIANT}:latest"
ffbuild_configure() {
return 0