Skip to content

Commit

Permalink
Use docker/build-push-action with maximum cachinng
Browse files Browse the repository at this point in the history
  • Loading branch information
ed-asriyan committed Oct 25, 2023
1 parent 3ec07df commit 1143c0f
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 13 deletions.
47 changes: 39 additions & 8 deletions .github/workflows/build-linux-and-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,36 +24,67 @@ jobs:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker caching
uses: jpribyl/[email protected]
continue-on-error: true
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v2

- name: Build lottie-to-apng
run: docker build -t lottie-to-apng:${{ inputs.arch }} --target lottie-to-apng --platform ${{ inputs.arch }} .

uses: docker/build-push-action@v4
with:
context: .
tags: lottie-to-apng:${{ inputs.arch }}
platforms: ${{ inputs.arch }}
target: lottie-to-apng
load: true
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Upload lottie-to-apng as artifact
uses: ishworkh/[email protected]
with:
image: lottie-to-apng:${{ inputs.arch }}

- name: Build lottie-to-gif
run: docker build -t lottie-to-gif:${{ inputs.arch }} --target lottie-to-gif --platform ${{ inputs.arch }} .
uses: docker/build-push-action@v4
with:
context: .
tags: lottie-to-gif:${{ inputs.arch }}
platforms: ${{ inputs.arch }}
target: lottie-to-gif
load: true
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Upload lottie-to-gif as artifact
uses: ishworkh/[email protected]
with:
image: lottie-to-gif:${{ inputs.arch }}

- name: Build lottie-to-png
run: docker build -t lottie-to-png:${{ inputs.arch }} --target lottie-to-png --platform ${{ inputs.arch }} .
uses: docker/build-push-action@v4
with:
context: .
tags: lottie-to-png:${{ inputs.arch }}
platforms: ${{ inputs.arch }}
target: lottie-to-png
load: true
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Upload lottie-to-png as artifact
uses: ishworkh/[email protected]
with:
image: lottie-to-png:${{ inputs.arch }}

- name: Build lottie-to-webp
run: docker build -t lottie-to-webp:${{ inputs.arch }} --target lottie-to-webp --platform ${{ inputs.arch }} .
uses: docker/build-push-action@v4
with:
context: .
tags: lottie-to-webp:${{ inputs.arch }}
platforms: ${{ inputs.arch }}
target: lottie-to-webp
load: true
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Upload lottie-to-webp as artifact
uses: ishworkh/[email protected]
Expand Down
14 changes: 9 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,21 @@ RUN pip3 install --break-system-packages conan==2.0.10

WORKDIR /application
RUN conan profile detect
ADD conanfile.txt .
COPY conanfile.txt .
RUN conan install . --build=missing -s build_type=Release

ADD CMakeLists.txt .
ADD src src
COPY CMakeLists.txt .
COPY src src
RUN cmake -DCMAKE_BUILD_TYPE=Release CMakeLists.txt && cmake --build . --config Release

FROM debian:buster-slim as lottie-to-gif
COPY --from=builder-gifski /usr/local/cargo/bin/gifski /usr/bin/gifski
COPY --from=builder-lottie-to-png /application/bin/lottie_to_png /usr/bin/lottie_to_png
ADD bin/* /usr/bin/
COPY bin/lottie_common.sh /usr/bin
COPY bin/lottie_to_apng.sh /usr/bin
COPY bin/lottie_to_gif.sh /usr/bin
COPY bin/lottie_to_png.sh /usr/bin
COPY bin/lottie_to_webp.sh /usr/bin
CMD bash -c "\
find /source -type f \( -iname \*.json -o -iname \*.lottie -o -iname \*.tgs \) | while IFS=$'\n' read -r FILE; do \
echo Converting \${FILE}... && lottie_to_\${FORMAT}.sh \${WIDTH:+--width \$WIDTH} \${HEIGHT:+--height \$HEIGHT} \${FPS:+--fps \$FPS} \${QUALITY:+--quality \$QUALITY} \$FILE && echo Done.; \
Expand All @@ -29,7 +33,7 @@ ENV FORMAT=gif

FROM alpine:3.16.2 as builder-lottie-to-some
COPY --from=builder-lottie-to-png /application/bin/lottie_to_png /usr/bin/lottie_to_png
ADD bin/* /usr/bin/
COPY bin/* /usr/bin/
CMD sh -c "\
find /source -type f \( -iname \*.json -o -iname \*.lottie -o -iname \*.tgs \) | while IFS=$'\n' read -r FILE; do \
echo Converting \${FILE}... && lottie_to_\${FORMAT}.sh \${WIDTH:+--width \$WIDTH} \${HEIGHT:+--height \$HEIGHT} \${FPS:+--fps \$FPS} \${QUALITY:+--quality \$QUALITY} \$FILE && echo Done.; \
Expand Down

0 comments on commit 1143c0f

Please sign in to comment.