From 9c8b9e0da499e74789ff38b9e958d8877e5ec579 Mon Sep 17 00:00:00 2001 From: Rodrigo Vargas Honorato Date: Wed, 20 Mar 2024 11:42:01 +0100 Subject: [PATCH] Add Dockerfile and workflow for building and publishing Docker image (#22) --- .github/workflows/docker-publish.yml | 48 ++++++++++++++++++++++++++++ Dockerfile | 8 +++++ 2 files changed, 56 insertions(+) create mode 100644 .github/workflows/docker-publish.yml create mode 100644 Dockerfile diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..b5f9b12 --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,48 @@ +# +name: build and publish an image + +on: + push: + # run only against tags + tags: + - "*" + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu. +jobs: + build-and-push-image: + runs-on: ubuntu-latest + # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job. + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + # Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here. + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels. + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5946ea4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +#============================================================================================== +FROM python:3.10 +WORKDIR /opt/software +COPY . . +RUN pip install . +WORKDIR /data +ENTRYPOINT [ "prodigy_lig" ] +#==============================================================================================