Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 44 additions & 1 deletion .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish Docker Image
name: Publish Docker Artifacts

on:
push:
Expand All @@ -24,13 +24,19 @@ jobs:

env:
IMAGE_NAME: ${{ vars.DOCKERHUB_IMAGE }}
COMPOSE_FILE: docker-compose.oci.yml

steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || github.ref }}

- name: Set up Docker Compose
uses: docker/setup-compose-action@v1
with:
version: latest

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

Expand Down Expand Up @@ -65,6 +71,22 @@ jobs:

echo "BRANCH_TAG=$tag" >> "$GITHUB_ENV"

- name: Resolve compose artifact name
run: |
override="${{ vars.DOCKERHUB_COMPOSE_ARTIFACT }}"
if [ -n "$override" ]; then
artifact="$override"
else
image="${IMAGE_NAME}"
if [[ "$image" == */* ]]; then
artifact="${image%/*}/${image##*/}-compose"
else
artifact="${image}-compose"
fi
fi

echo "COMPOSE_ARTIFACT_NAME=$artifact" >> "$GITHUB_ENV"

- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
Expand All @@ -84,3 +106,24 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Validate publish compose file
run: docker compose -f "$COMPOSE_FILE" config >/dev/null

- name: Publish compose artifact (main)
if: github.ref == 'refs/heads/main'
env:
HOMESEC_IMAGE: ${{ env.IMAGE_NAME }}:latest
run: docker compose -f "$COMPOSE_FILE" publish "${COMPOSE_ARTIFACT_NAME}:latest"

- name: Publish compose artifact (release)
if: github.event_name == 'release'
env:
HOMESEC_IMAGE: ${{ env.IMAGE_NAME }}:${{ env.RELEASE_VERSION }}
run: docker compose -f "$COMPOSE_FILE" publish "${COMPOSE_ARTIFACT_NAME}:${RELEASE_VERSION}"

- name: Publish compose artifact (manual)
if: github.event_name == 'workflow_dispatch'
env:
HOMESEC_IMAGE: ${{ env.IMAGE_NAME }}:${{ env.BRANCH_TAG }}
run: docker compose -f "$COMPOSE_FILE" publish "${COMPOSE_ARTIFACT_NAME}:${BRANCH_TAG}"
40 changes: 40 additions & 0 deletions docker-compose.oci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
services:
homesec:
image: ${HOMESEC_IMAGE:-leva/homesec:latest}
restart: unless-stopped
depends_on:
postgres:
condition: service_healthy
ports:
- "${HOMESEC_PORT:-8081}:8081"
volumes:
- homesec_config:/config
- homesec_recordings:/data/recordings
- homesec_storage:/data/storage
- homesec_yolo_cache:/app/yolo_cache
environment:
DB_DSN: postgresql+asyncpg://${POSTGRES_USER:-homesec}:${POSTGRES_PASSWORD:-homesec}@postgres:5432/${POSTGRES_DB:-homesec}

postgres:
image: ${POSTGRES_IMAGE:-postgres:16}
restart: unless-stopped
environment:
POSTGRES_USER: ${POSTGRES_USER:-homesec}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-homesec}
POSTGRES_DB: ${POSTGRES_DB:-homesec}
ports:
- "${POSTGRES_PORT:-5432}:5432"
volumes:
- homesec_pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-homesec} -d ${POSTGRES_DB:-homesec}"]
interval: 5s
timeout: 5s
retries: 5

volumes:
homesec_config:
homesec_recordings:
homesec_storage:
homesec_yolo_cache:
homesec_pgdata:
Loading