From fdbb3841789531d4f5f7945394ba2d97d54e8205 Mon Sep 17 00:00:00 2001 From: Dom Rodriguez Date: Fri, 6 Jan 2023 18:54:55 +0000 Subject: [PATCH 1/4] Add support for GH Actions container build workflow This commit adds support for a container build workflow, that, upon pushes to the repo, but *not* pull requests, builds a container image at one at a time, and pushes to GitHub Registry. --- .../workflows/build-and-push-to-registry.yml | 34 +++++++++++++++++++ .gitignore | 1 + 2 files changed, 35 insertions(+) create mode 100644 .github/workflows/build-and-push-to-registry.yml diff --git a/.github/workflows/build-and-push-to-registry.yml b/.github/workflows/build-and-push-to-registry.yml new file mode 100644 index 0000000..8d06e56 --- /dev/null +++ b/.github/workflows/build-and-push-to-registry.yml @@ -0,0 +1,34 @@ +name: Container image builder workflow +on: + push: + workflow_dispatch: + +concurrency: + group: gh-ref-${{ github.ref }} + cancel-in-progress: true + +jobs: + build-and-push-images: + name: Build and push container image for PineBuds Pro SDK to GHCR.io + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v3 + + - name: Build images + id: build + uses: redhat-actions/buildah-build@v2 + with: + image: ${{ github.repository }} + context: / + tags: ${{ contains(github.ref_name, 'main') && 'latest' || github.ref_name }}-sdk + containerfiles: /Dockerfile + + - name: Push container + uses: redhat-actions/push-to-registry@v2 + with: + image: ${{ steps.build.outputs.image }} + tags: ${{ steps.build.outputs.tags }} + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index b2615e8..8804d5f 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ !.gitignore !.gitattributes !.mailmap +!.github # Backup files *~ From 01f547aa90c625d86925db534432eec6d49a26ba Mon Sep 17 00:00:00 2001 From: Dom Rodriguez Date: Fri, 6 Jan 2023 18:45:55 +0000 Subject: [PATCH 2/4] Add support for Dependabot This commit adds support for Dependabot, which will automatically make PRs on a weekly basis (if necessary) for GitHub Actions and the Dockerfile. --- .github/dependabot.yml | 15 +++++++++++++++ .gitignore | 1 + 2 files changed, 16 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..6f04401 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,15 @@ +version: 2 +updates: + - package-ecosystem: "docker" + directory: "/" + schedule: + interval: "weekly" + commit-message: + prefix: "chore(deps)" + + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + commit-message: + prefix: "chore(ci)" diff --git a/.gitignore b/.gitignore index b2615e8..8804d5f 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ !.gitignore !.gitattributes !.mailmap +!.github # Backup files *~ From 71fedffbad81fd06462d2ebff853d7f9e8c8080a Mon Sep 17 00:00:00 2001 From: Dom Rodriguez Date: Thu, 5 Jan 2023 19:13:19 +0000 Subject: [PATCH 3/4] Refactor Dockerfile - see description - Use Debian Bullseye as `base` image. - Use proper `LABEL` for authors/maintainers. - Multi-stage builds. - Download Rust via rustup. - Combine RUN commands to reduce layers. --- Dockerfile | 54 +++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 15 deletions(-) diff --git a/Dockerfile b/Dockerfile index cb9afa2..1435ae9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,23 +1,47 @@ -FROM rust:1-slim-buster as programmer_build -LABEL maintainer="Ben V. Brown " +FROM debian:bullseye-slim AS base + +FROM base AS rust_build + +LABEL org.opencontainers.image.authors = "Ben V. Brown , Dom Rodriguez " + WORKDIR /usr/src -RUN apt-get update && apt-get install -y git pkg-config libudev-dev bc -RUN git clone https://github.com/Ralim/bestool.git -RUN cd /usr/src/bestool/bestool/ && cargo build --release +ENV PATH="/root/.cargo/bin:$PATH" -FROM debian:buster -LABEL maintainer="Ben V. Brown " +RUN apt-get update \ + && apt-get install -y \ + bc \ + build-essential \ + curl \ + git \ + libudev-dev \ + pkg-config \ + && curl https://sh.rustup.rs -sSf | bash -s -- -y \ + && git clone https://github.com/Ralim/bestool.git \ + && cd /usr/src/bestool/bestool/ \ + && cargo build --release +FROM base as dev_env -RUN apt update && apt-get install -y make git bash curl tar bzip2 bc xxd ffmpeg +WORKDIR /usr/src -WORKDIR /src -# Git trust -RUN git config --global --add safe.directory /src -# Grab arm compiler; we have to use this ancient one or else we get boot failures. Probably subtle link issues. +RUN apt-get update \ + && apt-get install -y \ + bash \ + bc \ + bzip2 \ + curl \ + ffmpeg \ + git \ + make \ + tar \ + xxd \ + && git config --global --add safe.directory /src \ + && mkdir -pv /src \ + && curl \ + https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/9-2019q4/gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2 | tar -xj -C /src/ -RUN curl https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/9-2019q4/gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2 | tar -xj ENV PATH="${PATH}:/src/gcc-arm-none-eabi-9-2019-q4-major/bin" -WORKDIR /usr/src -COPY --from=programmer_build /usr/src/bestool/bestool/target/release/bestool /usr/local/bin/bestool +COPY --from=rust_build /usr/src/bestool/bestool/target/release/bestool /usr/local/bin/bestool COPY . /usr/src + +ENTRYPOINT ["/bin/bash"] From 6fdfed449d822e3bbf463eca6d1ba80190e3041e Mon Sep 17 00:00:00 2001 From: Thatcher Chamberlin Date: Fri, 6 Jan 2023 15:02:46 -0500 Subject: [PATCH 4/4] Removed the "command: bash" line so that ./start_dev.sh works --- docker-compose.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 05d42b3..0cffbdf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,6 @@ services: privileged: true build: context: . - command: /bin/bash volumes: - ./:/usr/src:Z - /dev/:/dev/