diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml index dd73969..5917dca 100644 --- a/.gitea/workflows/release.yaml +++ b/.gitea/workflows/release.yaml @@ -1,6 +1,5 @@ name: Create and publish a Docker image -# Configures this workflow to run every time a change is pushed to the branch called `release`. on: push: # branches: ['main'] @@ -8,17 +7,13 @@ on: - '*.*.*' workflow_dispatch: -# Defines two custom environment variables for the workflow. These are used for the Container registry domain, -# and a name for the Docker image that this workflow builds. env: REGISTRY: git.housh.dev IMAGE_NAME: ductcalc -# 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 @@ -27,17 +22,14 @@ jobs: 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@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 with: registry: ${{ env.REGISTRY }} username: ${{ gitea.actor }} password: ${{ secrets.CONTAINER_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@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 @@ -46,19 +38,18 @@ jobs: tags: | type=ref,event=branch type=semver,pattern={{version}} + type=semver,pattern={{major.minor}} + type=semver,pattern={{major}} type=sha - type=raw,value=prod - # This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If - # the build succeeds, it pushes the image to GitHub Packages. It uses the `context` parameter to define the build's context - # as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" - # in the README of the `docker/build-push-action` repository. - # It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step. + type=raw,value=latest + - name: Build and push Docker image id: push uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 with: context: . file: docker/Dockerfile + platforms: linux/amd64,linux/arm64 push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index b2d86e5..6b5c1e8 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,6 +1,5 @@ name: Create and publish a Docker image -# Configures this workflow to run every time a change is pushed to the branch called `release`. on: push: # branches: ['main'] @@ -8,17 +7,13 @@ on: - '*.*.*' workflow_dispatch: -# Defines two custom environment variables for the workflow. These are used for the Container registry domain, -# and a name for the Docker image that this workflow builds. env: REGISTRY: ghcr.io IMAGE_NAME: ductcalc -# 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 @@ -27,17 +22,14 @@ jobs: 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.repository_owner }} password: ${{ secrets.CONTAINER_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 @@ -46,19 +38,18 @@ jobs: tags: | type=ref,event=branch type=semver,pattern={{version}} + type=semver,pattern={{major.minor}} + type=semver,pattern={{major}} type=sha - type=raw,value=prod - # This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If - # the build succeeds, it pushes the image to GitHub Packages. It uses the `context` parameter to define the build's context - # as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" - # in the README of the `docker/build-push-action` repository. - # It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step. + type=raw,value=latest + - name: Build and push Docker image id: push uses: docker/build-push-action@v6 with: context: . file: docker/Dockerfile + platforms: linux/amd64,linux/arm64 push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml new file mode 100644 index 0000000..5f7dd35 --- /dev/null +++ b/docker/docker-compose.yaml @@ -0,0 +1,22 @@ + +services: + db: + image: docker.io/postgres:18 + restart: unless-stopped + env_file: .env + volumes: + - ./data:/var/lib/postgresql + + app: + image: ghcr.io/m-housh/ductcalc:latest + restart: unless-stopped + env_file: .env + depends_on: + - db + ports: + - 8080:8080 + healthcheck: + test: curl --fail --silent http://0.0.0.0:8080/health || exit 1 + interval: 1m + timeout: 10s + retries: 3 diff --git a/docker/example.env b/docker/example.env new file mode 100644 index 0000000..9e7fbdf --- /dev/null +++ b/docker/example.env @@ -0,0 +1,20 @@ +# Shared with database & app +POSTGRES_USER=ductcalc +POSTGRES_PASSWORD=super-secret-change-me +POSTGRES_DB=ductcalc + +# App only +# +POSTGRES_HOSTNAME=db + +# If using sqlite not postgres +#SQLITE_PATH=db.sqlite + +# Set the pdf engine to use, this generally does not +# need set, unless extending the base image. +#PDF_ENGINE=weasyprint + +# Set the path to the pandoc executable. This generally +# does not need set, unless extending the base image. +#PANDOC_PATH=/usr/bin/pandoc +