Make local build script spin up a temporary registry
This commit is contained in:
		
							parent
							
								
									ab020724b4
								
							
						
					
					
						commit
						fcc7e6d9fb
					
				
					 7 changed files with 24 additions and 11 deletions
				
			
		
							
								
								
									
										3
									
								
								.github/workflows/build.yml
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.github/workflows/build.yml
									
										
									
									
										vendored
									
									
								
							| 
						 | 
					@ -121,6 +121,7 @@ jobs:
 | 
				
			||||||
        run: |
 | 
					        run: |
 | 
				
			||||||
          IMG="ghcr.io/${GITHUB_REPOSITORY,,}/${{ matrix.target }}-${{ matrix.variant }}"
 | 
					          IMG="ghcr.io/${GITHUB_REPOSITORY,,}/${{ matrix.target }}-${{ matrix.variant }}"
 | 
				
			||||||
          echo "::set-output name=name::${IMG/ /-}"
 | 
					          echo "::set-output name=name::${IMG/ /-}"
 | 
				
			||||||
 | 
					          echo "::set-output name=gh_repo::${GITHUB_REPOSITORY,,}"
 | 
				
			||||||
      - name: Stop Commands
 | 
					      - name: Stop Commands
 | 
				
			||||||
        run: T="$(echo -n ${{ github.token }} | sha256sum | head -c 64)" && echo -e "::add-mask::${T}\n::stop-commands::${T}"
 | 
					        run: T="$(echo -n ${{ github.token }} | sha256sum | head -c 64)" && echo -e "::add-mask::${T}\n::stop-commands::${T}"
 | 
				
			||||||
      - name: Build target base image
 | 
					      - name: Build target base image
 | 
				
			||||||
| 
						 | 
					@ -132,6 +133,8 @@ jobs:
 | 
				
			||||||
          tags: ${{ steps.imagename.outputs.name }}:latest
 | 
					          tags: ${{ steps.imagename.outputs.name }}:latest
 | 
				
			||||||
          cache-to: type=registry,mode=max,ref=${{ steps.imagename.outputs.name }}:cache
 | 
					          cache-to: type=registry,mode=max,ref=${{ steps.imagename.outputs.name }}:cache
 | 
				
			||||||
          cache-from: type=registry,ref=${{ steps.imagename.outputs.name }}:cache
 | 
					          cache-from: type=registry,ref=${{ steps.imagename.outputs.name }}:cache
 | 
				
			||||||
 | 
					          build-args: |
 | 
				
			||||||
 | 
					            GH_REPO=ghcr.io/${{ steps.imagename.outputs.gh_repo }}
 | 
				
			||||||
  build_ffmpeg:
 | 
					  build_ffmpeg:
 | 
				
			||||||
    name: Build ffmpeg
 | 
					    name: Build ffmpeg
 | 
				
			||||||
    if: ${{ ( github.event.inputs.buildOnly == 'true' && !cancelled() ) || success() }}
 | 
					    if: ${{ ( github.event.inputs.buildOnly == 'true' && !cancelled() ) || success() }}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,5 @@
 | 
				
			||||||
ARG GH_REPO=btbn/ffmpeg-builds
 | 
					ARG GH_REPO=ghcr.io/btbn/ffmpeg-builds
 | 
				
			||||||
FROM ghcr.io/$GH_REPO/base:latest
 | 
					FROM $GH_REPO/base:latest
 | 
				
			||||||
 | 
					
 | 
				
			||||||
RUN --mount=src=ct-ng-config,dst=/.config \
 | 
					RUN --mount=src=ct-ng-config,dst=/.config \
 | 
				
			||||||
    git clone --filter=blob:none https://github.com/crosstool-ng/crosstool-ng.git /ct-ng && cd /ct-ng && \
 | 
					    git clone --filter=blob:none https://github.com/crosstool-ng/crosstool-ng.git /ct-ng && cd /ct-ng && \
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,5 @@
 | 
				
			||||||
ARG GH_REPO=btbn/ffmpeg-builds
 | 
					ARG GH_REPO=ghcr.io/btbn/ffmpeg-builds
 | 
				
			||||||
FROM ghcr.io/$GH_REPO/base:latest
 | 
					FROM $GH_REPO/base:latest
 | 
				
			||||||
 | 
					
 | 
				
			||||||
RUN --mount=src=ct-ng-config,dst=/.config \
 | 
					RUN --mount=src=ct-ng-config,dst=/.config \
 | 
				
			||||||
    git clone --filter=blob:none https://github.com/crosstool-ng/crosstool-ng.git /ct-ng && cd /ct-ng && \
 | 
					    git clone --filter=blob:none https://github.com/crosstool-ng/crosstool-ng.git /ct-ng && cd /ct-ng && \
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,5 @@
 | 
				
			||||||
ARG GH_REPO=btbn/ffmpeg-builds
 | 
					ARG GH_REPO=ghcr.io/btbn/ffmpeg-builds
 | 
				
			||||||
FROM ghcr.io/$GH_REPO/base:latest
 | 
					FROM $GH_REPO/base:latest
 | 
				
			||||||
 | 
					
 | 
				
			||||||
RUN --mount=src=ct-ng-config,dst=/.config \
 | 
					RUN --mount=src=ct-ng-config,dst=/.config \
 | 
				
			||||||
    git clone --filter=blob:none https://github.com/crosstool-ng/crosstool-ng.git /ct-ng && cd /ct-ng && \
 | 
					    git clone --filter=blob:none https://github.com/crosstool-ng/crosstool-ng.git /ct-ng && cd /ct-ng && \
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,5 @@
 | 
				
			||||||
ARG GH_REPO=btbn/ffmpeg-builds
 | 
					ARG GH_REPO=ghcr.io/btbn/ffmpeg-builds
 | 
				
			||||||
FROM ghcr.io/$GH_REPO/base:latest
 | 
					FROM $GH_REPO/base:latest
 | 
				
			||||||
 | 
					
 | 
				
			||||||
RUN --mount=src=ct-ng-config,dst=/.config \
 | 
					RUN --mount=src=ct-ng-config,dst=/.config \
 | 
				
			||||||
    git clone --filter=blob:none https://github.com/crosstool-ng/crosstool-ng.git /ct-ng && cd /ct-ng && \
 | 
					    git clone --filter=blob:none https://github.com/crosstool-ng/crosstool-ng.git /ct-ng && cd /ct-ng && \
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										14
									
								
								makeimage.sh
									
										
									
									
									
								
							
							
						
						
									
										14
									
								
								makeimage.sh
									
										
									
									
									
								
							| 
						 | 
					@ -14,21 +14,31 @@ docker buildx inspect ffbuilder &>/dev/null || docker buildx create \
 | 
				
			||||||
    --bootstrap \
 | 
					    --bootstrap \
 | 
				
			||||||
    --name ffbuilder \
 | 
					    --name ffbuilder \
 | 
				
			||||||
    --config "$TMPCFG" \
 | 
					    --config "$TMPCFG" \
 | 
				
			||||||
 | 
					    --driver-opt network=host \
 | 
				
			||||||
    --driver-opt env.BUILDKIT_STEP_LOG_MAX_SIZE=-1 \
 | 
					    --driver-opt env.BUILDKIT_STEP_LOG_MAX_SIZE=-1 \
 | 
				
			||||||
    --driver-opt env.BUILDKIT_STEP_LOG_MAX_SPEED=-1
 | 
					    --driver-opt env.BUILDKIT_STEP_LOG_MAX_SPEED=-1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if [[ -z "$QUICKBUILD" ]]; then
 | 
					if [[ -z "$QUICKBUILD" ]]; then
 | 
				
			||||||
 | 
					    docker container inspect ffbuildreg &>/dev/null || \
 | 
				
			||||||
 | 
					        docker run --rm -d -p 127.0.0.1:0:5000 --name ffbuildreg registry:2
 | 
				
			||||||
 | 
					    LOCAL_REG_PORT="$(docker container inspect --format='{{range $p, $conf := .NetworkSettings.Ports}}{{(index $conf 0).HostPort}}{{end}}' ffbuildreg)"
 | 
				
			||||||
 | 
					    LOCAL_ROOT="127.0.0.1:${LOCAL_REG_PORT}/local"
 | 
				
			||||||
 | 
					    trap "rm -f '$TMPCFG'; docker container stop ffbuildreg" EXIT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if grep "FROM.*base.*" "images/base-${TARGET}/Dockerfile" >/dev/null 2>&1; then
 | 
					    if grep "FROM.*base.*" "images/base-${TARGET}/Dockerfile" >/dev/null 2>&1; then
 | 
				
			||||||
        docker buildx --builder ffbuilder build \
 | 
					        docker buildx --builder ffbuilder build \
 | 
				
			||||||
            --cache-from=type=local,src=.cache/"${BASE_IMAGE/:/_}" \
 | 
					            --cache-from=type=local,src=.cache/"${BASE_IMAGE/:/_}" \
 | 
				
			||||||
            --cache-to=type=local,mode=max,dest=.cache/"${BASE_IMAGE/:/_}" \
 | 
					            --cache-to=type=local,mode=max,dest=.cache/"${BASE_IMAGE/:/_}" \
 | 
				
			||||||
            --load --tag "$BASE_IMAGE" images/base
 | 
					            --push --tag "${LOCAL_ROOT}/base:latest" images/base
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    docker buildx --builder ffbuilder build \
 | 
					    docker buildx --builder ffbuilder build \
 | 
				
			||||||
        --cache-from=type=local,src=.cache/"${TARGET_IMAGE/:/_}" \
 | 
					        --cache-from=type=local,src=.cache/"${TARGET_IMAGE/:/_}" \
 | 
				
			||||||
        --cache-to=type=local,mode=max,dest=.cache/"${TARGET_IMAGE/:/_}" \
 | 
					        --cache-to=type=local,mode=max,dest=.cache/"${TARGET_IMAGE/:/_}" \
 | 
				
			||||||
        --load --build-arg GH_REPO="$REPO" --tag "$TARGET_IMAGE" "images/base-${TARGET}"
 | 
					        --push --tag "${LOCAL_ROOT}/base-${TARGET}:latest" \
 | 
				
			||||||
 | 
					        --build-arg GH_REPO="$LOCAL_ROOT" "images/base-${TARGET}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    export REGISTRY_OVERRIDE="127.0.0.1:${LOCAL_REG_PORT}" GITHUB_REPOSITORY="local"
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
./generate.sh "$TARGET" "$VARIANT" "${ADDINS[@]}"
 | 
					./generate.sh "$TARGET" "$VARIANT" "${ADDINS[@]}"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -32,7 +32,7 @@ done
 | 
				
			||||||
 | 
					
 | 
				
			||||||
REPO="${GITHUB_REPOSITORY:-btbn/ffmpeg-builds}"
 | 
					REPO="${GITHUB_REPOSITORY:-btbn/ffmpeg-builds}"
 | 
				
			||||||
REPO="${REPO,,}"
 | 
					REPO="${REPO,,}"
 | 
				
			||||||
REGISTRY="ghcr.io"
 | 
					REGISTRY="${REGISTRY_OVERRIDE:-ghcr.io}"
 | 
				
			||||||
BASE_IMAGE="${REGISTRY}/${REPO}/base:latest"
 | 
					BASE_IMAGE="${REGISTRY}/${REPO}/base:latest"
 | 
				
			||||||
TARGET_IMAGE="${REGISTRY}/${REPO}/base-${TARGET}:latest"
 | 
					TARGET_IMAGE="${REGISTRY}/${REPO}/base-${TARGET}:latest"
 | 
				
			||||||
IMAGE="${REGISTRY}/${REPO}/${TARGET}-${VARIANT}${ADDINS_STR:+-}${ADDINS_STR}:latest"
 | 
					IMAGE="${REGISTRY}/${REPO}/${TARGET}-${VARIANT}${ADDINS_STR:+-}${ADDINS_STR}:latest"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue