Skip to content

Commit

Permalink
fix(ci): Add build image to registry for caching
Browse files Browse the repository at this point in the history
  • Loading branch information
pando85 committed Jan 17, 2024
1 parent 9ccd337 commit 28062db
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 16 deletions.
15 changes: 8 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ RUN curl -sLO \
chmod 755 ./build-ffmpeg && \
SKIPINSTALL=yes ./build-ffmpeg \
--build \
--enable-gpl-and-non-free
--enable-gpl-and-non-free && \
rm -rf packages && \
find workspace -mindepth 1 -maxdepth 1 -type d ! -name 'bin' -exec rm -rf {} \; && \
find workspace/bin -mindepth 1 -maxdepth 1 -type f ! -name 'ff*' -exec rm -f {} \;

FROM debian:trixie-20240110-slim as base

Expand All @@ -29,14 +32,12 @@ RUN apt-get update \
libva-drm2 \
&& rm -rf /var/lib/apt/lists/*

COPY --from=build /app/workspace/bin/ffmpeg /usr/bin/ffmpeg
COPY --from=build /app/workspace/bin/ffprobe /usr/bin/ffprobe
COPY --from=build /app/workspace/bin/ffplay /usr/bin/ffplay
COPY --from=build /app/workspace/bin/ff* /usr/bin/

# Check shared library
RUN ldd /usr/bin/ffmpeg
RUN ldd /usr/bin/ffprobe
RUN ldd /usr/bin/ffplay
RUN ldd /usr/bin/ffmpeg && \
ldd /usr/bin/ffprobe && \
ldd /usr/bin/ffplay

FROM base as server
COPY ./dist/transcoder-server /app/transcoder-server
Expand Down
33 changes: 24 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,43 @@ images: ## build container images
push-images: push-image-server push-image-worker
push-images: ## build and push container images

DOCKER_BUILD_ARG := --cache-to type=inline
DOCKER_BUILD_ARG += --cache-from $(IMAGE_NAME):latest-build
DOCKER_BUILD_ARG += --cache-from $(IMAGE_NAME):latest-base

.PHONY: image-%
.PHONY: push-image-%
image-% push-image-%: build-%
@export DOCKER_BUILD_ARG="--cache-to type=inline $(if $(findstring push,$@),--push,--load)"; \
docker buildx build \
@export DOCKER_BUILD_ARG="$(DOCKER_BUILD_ARG) $(if $(findstring push,$@),--push,--load)"; \
if [ "$*" = "server" ]; then \
docker buildx build \
$${DOCKER_BUILD_ARG} \
--cache-from $(IMAGE_NAME):latest-$* \
-t $(IMAGE_NAME):$(IMAGE_VERSION)-$* \
-t $(IMAGE_NAME):$(IMAGE_VERSION)-build \
--target build \
-f Dockerfile \
--target $* \
. ; \
if [ "$*" = "worker" ]; then \
docker buildx build \
$${DOCKER_BUILD_ARG} \
-t $(IMAGE_NAME):$(IMAGE_VERSION)-base \
--target base \
-f Dockerfile \
. ; \
else \
docker buildx build \
$${DOCKER_BUILD_ARG} \
--cache-from $(IMAGE_NAME):latest-worker-pgs \
-t $(IMAGE_NAME):$(IMAGE_VERSION)-worker-pgs \
--target worker-pgs \
-f Dockerfile \
. ; \
fi;

MAX_ATTEMPTS ?= 10
fi; \
docker buildx build \
$${DOCKER_BUILD_ARG} \
--cache-from $(IMAGE_NAME):latest-$* \
-t $(IMAGE_NAME):$(IMAGE_VERSION)-$* \
-f Dockerfile \
--target $* \
. ;

.PHONY: run-all
run-all: images
Expand Down

0 comments on commit 28062db

Please sign in to comment.