From 69da43cd014c9122533bebddca723084bdcf22e3 Mon Sep 17 00:00:00 2001 From: trivernis Date: Sat, 9 Apr 2022 13:55:33 +0200 Subject: [PATCH 1/2] Change container build workflow to podman Signed-off-by: trivernis --- .github/workflows/build-docker.yml | 33 +++++++++++++++++------------- Dockerfile => Containerfile | 22 ++++++++++---------- 2 files changed, 30 insertions(+), 25 deletions(-) rename Dockerfile => Containerfile (74%) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index e1be093..7dde127 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -28,23 +28,28 @@ jobs: - name: Cache Docker layers uses: actions/cache@v2 with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ hashFiles('Cargo.lock') }} + path: /var/lib/containers/ + key: ${{ runner.os }}-podman-${{ hashFiles('Cargo.lock') }} restore-keys: | - ${{ runner.os }}-buildx- + ${{ runner.os }}-podman- + - name: Build + id: build-image + uses: redhat-actions/buildah-build@v2 + with: + context: . + layers: true + containerfiles: ./Containerfile + platforms: ${{github.event.inputs.platforms}} + image: trivernis/tobi:latest - name: Login to DockerHub - uses: docker/login-action@v1 + uses: redhat-actions/podman-login@v1 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and push - uses: docker/build-push-action@v2 + registry: docker.io + - name: Push + uses: redhat-actions/push-to-registry@v2 with: - context: . - file: ./Dockerfile - platforms: ${{github.event.inputs.platforms}} - push: true - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache - tags: | - trivernis/tobi:latest \ No newline at end of file + image: ${{ steps.build-image.outputs.image }} + tags: ${{ steps.build-image.outputs.tags }} + registry: docker.io \ No newline at end of file diff --git a/Dockerfile b/Containerfile similarity index 74% rename from Dockerfile rename to Containerfile index c9bc647..65559a3 100644 --- a/Dockerfile +++ b/Containerfile @@ -1,9 +1,7 @@ -# syntax=docker/dockerfile:1.0-experimental - ARG QALCULATE_VERSION=4.1.1 ARG DEBIAN_RELEASE=bullseye -FROM rust:slim-${DEBIAN_RELEASE} AS builder +FROM docker.io/rust:slim-${DEBIAN_RELEASE} AS builder RUN apt-get update RUN apt-get install -y build-essential libssl-dev libopus-dev libpq-dev pkg-config WORKDIR /usr/src @@ -14,12 +12,18 @@ COPY src ./src COPY bot-coreutils ./bot-coreutils COPY bot-database ./bot-database RUN --mount=type=cache,target=/usr/local/cargo/registry \ - --mount=type=cache,target=target \ + --mount=type=cache,target=/usr/src/tobi/target \ cargo build --release RUN mkdir /tmp/tobi -RUN --mount=type=cache,target=target cp target/release/tobi-rs /tmp/tobi/ +RUN --mount=type=cache,target=/usr/src/tobi/target cp target/release/tobi-rs /tmp/tobi/ + +FROM docker.io/bitnami/minideb:${DEBIAN_RELEASE} AS runtime-base +RUN apt update +RUN apt install openssl libopus0 ffmpeg python3 python3-pip libpq5 pkg-config -y +RUN pip3 install youtube-dl +RUN rm -rf /var/lib/{apt,dpkg,cache,log}/ /var/cache -FROM bitnami/minideb:${DEBIAN_RELEASE} AS qalculate-builder +FROM docker.io/bitnami/minideb:${DEBIAN_RELEASE} AS qalculate-builder ARG QALCULATE_VERSION RUN mkdir /tmp/qalculate WORKDIR /tmp/qalculate @@ -28,11 +32,7 @@ RUN wget https://github.com/Qalculate/qalculate-gtk/releases/download/v${QALCULA RUN tar xf qalculate.tar.xz RUN cp qalculate-${QALCULATE_VERSION}/* /tmp/qalculate -FROM bitnami/minideb:${DEBIAN_RELEASE} -RUN apt update -RUN apt install openssl libopus0 ffmpeg python3 python3-pip libpq5 pkg-config -y +FROM runtime-base COPY --from=qalculate-builder /tmp/qalculate/* /usr/bin/ COPY --from=builder /tmp/tobi/tobi-rs . -RUN pip3 install youtube-dl -RUN rm -rf /var/lib/{apt,dpkg,cache,log}/ /var/cache ENTRYPOINT ["/tobi-rs"] \ No newline at end of file From 998c51acefd4cbd88c673684762eef55f83a9902 Mon Sep 17 00:00:00 2001 From: trivernis Date: Sat, 9 Apr 2022 13:59:24 +0200 Subject: [PATCH 2/2] Fix container build task Signed-off-by: trivernis --- .dockerignore => .containerignore | 0 .github/workflows/{build-docker.yml => build-container.yml} | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) rename .dockerignore => .containerignore (100%) rename .github/workflows/{build-docker.yml => build-container.yml} (93%) diff --git a/.dockerignore b/.containerignore similarity index 100% rename from .dockerignore rename to .containerignore diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-container.yml similarity index 93% rename from .github/workflows/build-docker.yml rename to .github/workflows/build-container.yml index 7dde127..c091990 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-container.yml @@ -1,4 +1,4 @@ -name: Build Docker Container +name: Build Container on: workflow_dispatch: @@ -40,7 +40,7 @@ jobs: layers: true containerfiles: ./Containerfile platforms: ${{github.event.inputs.platforms}} - image: trivernis/tobi:latest + image: trivernis/tobi - name: Login to DockerHub uses: redhat-actions/podman-login@v1 with: