From 99e4bbfda53b704ef77ea33fd23f29d22fb3d2b4 Mon Sep 17 00:00:00 2001 From: Jack Eadie Date: Tue, 28 Mar 2023 13:53:34 +1000 Subject: [PATCH 1/6] add dockerfiles --- Dockerfile.test | 12 ++++++++++++ Dockerfile.training | 14 ++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 Dockerfile.test create mode 100644 Dockerfile.training diff --git a/Dockerfile.test b/Dockerfile.test new file mode 100644 index 000000000..c59175b44 --- /dev/null +++ b/Dockerfile.test @@ -0,0 +1,12 @@ +FROM python:3.8-slim-buster +RUN apt-get update && apt-get install -y make + +WORKDIR /app + +COPY Makefile . +COPY requirements-test.txt . + +RUN make install-test && make test + +COPY . . +ENTRYPOINT ["python", "-m", "pytest", "-xsv", "tests"] \ No newline at end of file diff --git a/Dockerfile.training b/Dockerfile.training new file mode 100644 index 000000000..280d13be8 --- /dev/null +++ b/Dockerfile.training @@ -0,0 +1,14 @@ +FROM python:3.8-slim-buster +RUN apt-get update && apt-get install -y make + +WORKDIR /app + +COPY Makefile . +COPY requirements-training.txt . + +RUN make install-training + +COPY . . +WORKDIR /app/src/ + +ENTRYPOINT ["python", "-m", "training.main"] \ No newline at end of file From eafb7b237f829b651625f3267e8c91a8f802f80f Mon Sep 17 00:00:00 2001 From: Jack Eadie Date: Tue, 28 Mar 2023 13:57:12 +1000 Subject: [PATCH 2/6] GH action to create containers --- .github/workflows/containers.yml | 74 ++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 .github/workflows/containers.yml diff --git a/.github/workflows/containers.yml b/.github/workflows/containers.yml new file mode 100644 index 000000000..671b3f074 --- /dev/null +++ b/.github/workflows/containers.yml @@ -0,0 +1,74 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +# GitHub recommends pinning actions to a commit SHA. +# To get a newer version, you will need to update the SHA. +# You can also reference a tag or branch, but the action may change without warning. + +name: Create and publish a Docker image + +on: + push: + branches: + - main + paths-ignore: + - '**.md' + - 'CITATION.cff' + - 'LICENSE' + - '.gitignore' + - 'docs/**' + pull_request: + branches: + - main + paths-ignore: + - '**.md' + - 'CITATION.cff' + - 'LICENSE' + - '.gitignore' + - 'docs/**' + workflow_dispatch: + inputs: + manual_revision_reference: + required: false + type: string + manual_revision_test: + required: false + type: string + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Log in to the Container registry + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file From 094e43f8a0394d8ca3af8bc3e5096da0e4660f77 Mon Sep 17 00:00:00 2001 From: Jack Eadie Date: Tue, 28 Mar 2023 13:59:54 +1000 Subject: [PATCH 3/6] fix dockerfile path --- .github/workflows/ci.yml | 38 ++++++++++++++-------------- .github/workflows/containers.yml | 5 ++-- .github/workflows/python-publish.yml | 2 +- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c7314f628..d15a29873 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,24 +1,24 @@ name: Continuous integration -on: - push: - branches: - - main - paths-ignore: - - '**.md' - - 'CITATION.cff' - - 'LICENSE' - - '.gitignore' - - 'docs/**' - pull_request: - branches: - - main - paths-ignore: - - '**.md' - - 'CITATION.cff' - - 'LICENSE' - - '.gitignore' - - 'docs/**' +# on: +# push: +# branches: +# - main +# paths-ignore: +# - '**.md' +# - 'CITATION.cff' +# - 'LICENSE' +# - '.gitignore' +# - 'docs/**' +# pull_request: +# branches: +# - main +# paths-ignore: +# - '**.md' +# - 'CITATION.cff' +# - 'LICENSE' +# - '.gitignore' +# - 'docs/**' workflow_dispatch: inputs: manual_revision_reference: diff --git a/.github/workflows/containers.yml b/.github/workflows/containers.yml index 671b3f074..40d0135fb 100644 --- a/.github/workflows/containers.yml +++ b/.github/workflows/containers.yml @@ -66,9 +66,10 @@ jobs: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - name: Build and push Docker image - uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + uses: docker/build-push-action with: context: . push: true tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file + labels: ${{ steps.meta.outputs.labels }} + file: Dockerfile.training \ No newline at end of file diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index f336b13ba..e21b1b451 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -3,7 +3,7 @@ name: Release on: push: branches: - - main + - main-remove-action jobs: deploy: runs-on: ubuntu-latest From 3853211870a0db7baf7252520a897dca73feb52c Mon Sep 17 00:00:00 2001 From: Jack Eadie Date: Tue, 28 Mar 2023 14:02:00 +1000 Subject: [PATCH 4/6] add version to push --- .github/workflows/containers.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/containers.yml b/.github/workflows/containers.yml index 40d0135fb..4b060f598 100644 --- a/.github/workflows/containers.yml +++ b/.github/workflows/containers.yml @@ -66,7 +66,7 @@ jobs: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - name: Build and push Docker image - uses: docker/build-push-action + uses: docker/build-push-action@v4 with: context: . push: true From 2e5d4c76ae15546342c5cec60f63415c130a6346 Mon Sep 17 00:00:00 2001 From: Jack Eadie Date: Tue, 28 Mar 2023 15:07:35 +1000 Subject: [PATCH 5/6] add test container to GH action --- .github/workflows/containers.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/containers.yml b/.github/workflows/containers.yml index 4b060f598..b3c95fdb6 100644 --- a/.github/workflows/containers.yml +++ b/.github/workflows/containers.yml @@ -65,11 +65,22 @@ jobs: with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - name: Build and push Docker image + - name: Build & push training Docker image + id: build-and-push-training uses: docker/build-push-action@v4 with: context: . push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - file: Dockerfile.training \ No newline at end of file + file: Dockerfile.training + + - name: Build and push test Docker image + id: build-and-push-test + uses: docker/build-push-action@v4 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }}-test + labels: ${{ steps.meta.outputs.labels }} + file: Dockerfile.test \ No newline at end of file From ee68251eee6750fe609fba405b72767ca21b3186 Mon Sep 17 00:00:00 2001 From: Jack Eadie Date: Wed, 12 Apr 2023 11:32:03 +1000 Subject: [PATCH 6/6] add buildx to container GH action --- .github/workflows/containers.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/containers.yml b/.github/workflows/containers.yml index b3c95fdb6..ad3de0c9e 100644 --- a/.github/workflows/containers.yml +++ b/.github/workflows/containers.yml @@ -52,6 +52,9 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Log in to the Container registry uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 with: