Skip to content

Build and Publish ReefGuideWorker.jl Docker Image #12

Build and Publish ReefGuideWorker.jl Docker Image

Build and Publish ReefGuideWorker.jl Docker Image #12

# Additional notes:
# - The workflow uses the github.repository context to name the image, ensuring it's tied to your repository
# - The GITHUB_TOKEN is automatically provided by GitHub Actions, no need to set it up manually
# - The Docker metadata action automatically generates appropriate tags based on the release version
# - The Julia version can be easily updated by changing the JULIA_VERSION environment variable at the top of the workflow
name: Build and Publish ReefGuideWorker.jl Docker Image
on:
workflow_dispatch:
release:
types: [published]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}/reefguide-worker
JULIA_VERSION: 1.11
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
# Checkout the repository code
- name: Checkout repository
uses: actions/checkout@v4
# Log in to the GitHub Container Registry
# This uses the provided GitHub token for authentication
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Extract metadata for Docker
# This step generates tags and labels for the Docker image
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}.{{minor}}.{{patch}}
type=semver,pattern={{major}}
type=ref,event=branch
type=sha,format=long
type=sha,format=short
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
# Build and push the Docker image
# This step builds the reefguide-worker image and pushes it to the registry
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
target: app-src # Specifies which stage of the Dockerfile to build
push: true # Pushes the image to the registry
tags: ${{ steps.meta.outputs.tags }} # Uses the tags generated in the metadata step
labels: ${{ steps.meta.outputs.labels }} # Uses the labels generated in the metadata step
# Passes the Julia versions to the Dockerfile
build-args: |
JULIA_VERSION=${{ env.JULIA_VERSION }}