mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2026-07-31 15:59:34 -04:00
- Introduced .dockerignore to exclude unnecessary files from Docker context. - Added .env.aio.example for minimal configuration of the AdventureLog All-in-One setup. - Updated .env.example to include optional SITE_URL and GUNICORN_WORKERS settings. - Enhanced deploy.sh script for improved deployment flexibility and backup options. - Updated docker-compose files to use PostGIS 16-3.5 and added health checks for services. - Created docker-compose.aio.yml for All-in-One deployment configuration. - Improved health checks and service dependencies in docker-compose.dev.yml and docker-compose.yml. - Added GitHub workflows for building and pushing Docker images, including smoke tests for AIO setup.
126 lines
3.8 KiB
YAML
126 lines
3.8 KiB
YAML
name: Build and push Docker image
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
context:
|
|
required: true
|
|
type: string
|
|
image_name:
|
|
required: true
|
|
type: string
|
|
tag:
|
|
required: true
|
|
type: string
|
|
include_latest_tag:
|
|
required: false
|
|
type: boolean
|
|
default: false
|
|
dockerfile:
|
|
required: false
|
|
type: string
|
|
default: docker/Dockerfile
|
|
target:
|
|
required: false
|
|
type: string
|
|
default: ""
|
|
secrets:
|
|
ACCESS_TOKEN:
|
|
required: true
|
|
DOCKERHUB_USERNAME:
|
|
required: true
|
|
DOCKERHUB_TOKEN:
|
|
required: true
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
actions: write
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Prepare image tags
|
|
id: tags
|
|
env:
|
|
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
run: |
|
|
append_tag() {
|
|
TAGS="${TAGS}"$'\n'"$1"
|
|
}
|
|
|
|
TAGS=""
|
|
append_tag "ghcr.io/${{ github.repository_owner }}/${{ inputs.image_name }}:${{ inputs.tag }}"
|
|
append_tag "${DOCKERHUB_USERNAME}/${{ inputs.image_name }}:${{ inputs.tag }}"
|
|
|
|
if [ "${{ inputs.include_latest_tag }}" = "true" ]; then
|
|
append_tag "ghcr.io/${{ github.repository_owner }}/${{ inputs.image_name }}:latest"
|
|
append_tag "${DOCKERHUB_USERNAME}/${{ inputs.image_name }}:latest"
|
|
fi
|
|
|
|
{
|
|
echo "value<<EOF"
|
|
printf '%s\n' "${TAGS}"
|
|
echo "EOF"
|
|
} >> "${GITHUB_OUTPUT}"
|
|
|
|
- name: Login to GitHub Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.ACCESS_TOKEN }}
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Build and push
|
|
id: build
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: ${{ inputs.context }}
|
|
file: ${{ inputs.dockerfile }}
|
|
target: ${{ inputs.target != '' && inputs.target || null }}
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: ${{ steps.tags.outputs.value }}
|
|
labels: |
|
|
org.opencontainers.image.revision=${{ github.sha }}
|
|
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
|
|
cache-from: |
|
|
type=gha,scope=${{ inputs.image_name }}-${{ inputs.tag }}
|
|
type=registry,ref=ghcr.io/${{ github.repository_owner }}/${{ inputs.image_name }}:buildcache
|
|
cache-to: |
|
|
type=gha,scope=${{ inputs.image_name }}-${{ inputs.tag }},mode=max
|
|
type=registry,ref=ghcr.io/${{ github.repository_owner }}/${{ inputs.image_name }}:buildcache,mode=max
|
|
|
|
- name: Report amd64 image size
|
|
env:
|
|
DOCKERFILE: ${{ inputs.dockerfile }}
|
|
TARGET: ${{ inputs.target }}
|
|
CONTEXT: ${{ inputs.context }}
|
|
IMAGE: ${{ inputs.image_name }}-size-check
|
|
run: |
|
|
args=(--platform linux/amd64 --load)
|
|
if [[ -n "$TARGET" ]]; then
|
|
args+=(--target "$TARGET")
|
|
fi
|
|
args+=(-f "$DOCKERFILE" -t "$IMAGE" "$CONTEXT")
|
|
docker buildx build "${args[@]}"
|
|
SIZE=$(docker image inspect "$IMAGE" --format='{{.Size}}')
|
|
echo "${{ inputs.image_name }} amd64 size: $(awk "BEGIN {printf \"%.1f MB\", ${SIZE}/1024/1024}")"
|
|
docker rmi "$IMAGE"
|