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: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Login to DockerHub - name: Login to Docker
uses: docker/login-action@v1 uses: docker/login-action@v1
with: with:
username: ${{ secrets.DOCKER_USER }} registry: docker.pkg.github.com
password: ${{ secrets.DOCKER_TOKEN }} username: ${{ github.actor }}
password: ${{ github.token }}
- name: Pull latest - 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 - 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 - 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: build_target_bases:
name: Build target base image name: Build target base image
needs: build_base needs: build_base
@ -36,17 +39,20 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Login to DockerHub - name: Login to Docker
uses: docker/login-action@v1 uses: docker/login-action@v1
with: with:
username: ${{ secrets.DOCKER_USER }} registry: docker.pkg.github.com
password: ${{ secrets.DOCKER_TOKEN }} username: ${{ github.actor }}
password: ${{ github.token }}
- name: Pull latest - 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 - 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 - 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: build_targets:
name: Build target-variant image name: Build target-variant image
needs: build_target_bases needs: build_target_bases
@ -61,17 +67,20 @@ jobs:
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Generate Dockerfile - name: Generate Dockerfile
run: ./generate.sh ${{ matrix.target }} ${{ matrix.variant }} run: ./generate.sh ${{ matrix.target }} ${{ matrix.variant }}
- name: Login to DockerHub - name: Login to Docker
uses: docker/login-action@v1 uses: docker/login-action@v1
with: with:
username: ${{ secrets.DOCKER_USER }} registry: docker.pkg.github.com
password: ${{ secrets.DOCKER_TOKEN }} username: ${{ github.actor }}
password: ${{ github.token }}
- name: Pull latest - 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 - 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 - 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: build_ffmpeg:
name: Build ffmpeg name: Build ffmpeg
needs: build_targets needs: build_targets
@ -84,6 +93,12 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 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 - name: Build ffmpeg
run: ./build.sh ${{ matrix.target }} ${{ matrix.variant }} run: ./build.sh ${{ matrix.target }} ${{ matrix.variant }}
- name: Upload artifacts - name: Upload artifacts

View file

@ -10,7 +10,7 @@ to_df() {
echo >> Dockerfile 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" to_df "ENV TARGET=$TARGET VARIANT=$VARIANT REPO=$REPO"
for script in scripts.d/*.sh; do 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 ENV DEBIAN_FRONTEND noninteractive

View file

@ -3,6 +3,9 @@ set -xe
cd "$(dirname "$0")" cd "$(dirname "$0")"
source util/vars.sh 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" ./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" TARGET="$1"
VARIANT="${2:-gpl}" VARIANT="${2:-gpl}"
REPO="${DOCKER_REPO:-btbn/ffmpeg-builder}" REPO="${GITHUB_REPOSITORY:-btbn/ffmpeg-builds}"
IMAGE="$REPO:$TARGET-$VARIANT" 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() { ffbuild_configure() {
return 0 return 0