From daf79338b553063e7d2b7daf623f6316a482ba8f Mon Sep 17 00:00:00 2001 From: Dom Rodriguez Date: Mon, 12 Sep 2022 21:58:40 +0100 Subject: [PATCH 1/2] Add Docker support for RSSingle, and a workflow for builds This commit adds a Dockerfile, .dockerignore, and a GH Action for pushing container images to - and this is by default, other registries can be used - Docker Hub (you need to generate a token and install it in the repo), and GitHub Registry, which doesn't require a manual token. The workflow won't build until #3 is merged, as it relies on successful builds from that workflow before a container image is pushed. Once we use unit tests, this will ensure container images aren't broken when pushed to a remote registry. I have marked this PR as draft for that reason. Signed-off-by: Dom Rodriguez --- .dockerignore | 5 ++++ .github/workflows/container.yml | 44 +++++++++++++++++++++++++++++++++ Dockerfile | 18 ++++++++++++++ 3 files changed, 67 insertions(+) create mode 100644 .dockerignore create mode 100644 .github/workflows/container.yml create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..bbeff06 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +/LICENSE +/README.md +/rssingle.png +/Dockerfile +/config.yml diff --git a/.github/workflows/container.yml b/.github/workflows/container.yml new file mode 100644 index 0000000..90d8c2b --- /dev/null +++ b/.github/workflows/container.yml @@ -0,0 +1,44 @@ +name: Container image builder for RSS single + +on: + workflow_run: + workflows: ["CI workflow for RSSingle"] + types: [completed] + branches: [main] + +jobs: + build-and-push-container-image: + name: Build and push container image to Docker Hub and GHCR.io + if: ${{ github.event.workflow_run.conclusion == 'success' }} + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v2 + + - name: Build container image + id: build + uses: redhat-actions/buildah-build@v2 + with: + image: tanrax/rssingle + tags: latest + containerfiles: Dockerfile + + - name: Push container image to Docker Hub + uses: redhat-actions/push-to-registry@v2 + with: + image: ${{ steps.build.outputs.image }} + tags: ${{ steps.build.outputs.tags }} + registry: docker.io + username: tanrax + password: ${{ secrets.DOCKER_TOKEN }} + + - name: Push container image to GHCR.io + uses: redhat-actions/push-to-registry@v2 + with: + image: ${{ steps.build.outputs.image }} + tags: ${{ steps.build.outputs.tags }} + registry: ghcr.io + username: tanrax + password: ${{ secrets.GITHUB_TOKEN }} + + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..230fb73 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM docker.io/python:3.8-buster AS base + +FROM base AS build + +WORKDIR /work + +COPY . . + +RUN pip3 install pyinstaller + +RUN pip3 install -r /work/requirements.txt +RUN pyinstaller --onefile /work/rssingle.py + +FROM docker.io/python:3.8-buster AS app + +COPY --from=build /work/dist/rssingle /rssingle + +ENTRYPOINT ["/rssingle"] From 1f36dea8898b4c00f9194c1ed50853abe2ddd292 Mon Sep 17 00:00:00 2001 From: Dom Rodriguez Date: Mon, 12 Sep 2022 23:45:26 +0100 Subject: [PATCH 2/2] Adjust branch, assumed the branch - use master I didn't realise you were using `master` as the branch name, so this wouldn't run if the PR was accepted. Now fixed. Signed-off-by: Dom Rodriguez --- .github/workflows/container.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/container.yml b/.github/workflows/container.yml index 90d8c2b..73ff0e6 100644 --- a/.github/workflows/container.yml +++ b/.github/workflows/container.yml @@ -4,7 +4,7 @@ on: workflow_run: workflows: ["CI workflow for RSSingle"] types: [completed] - branches: [main] + branches: [master] jobs: build-and-push-container-image: