🐳 Attempt 1: Inline version of docker/Dockerfile

This commit is contained in:
2026-04-09 11:16:25 +02:00
parent 1c63530580
commit 3cafc7bcb2
3 changed files with 298 additions and 58 deletions

View File

@@ -1,27 +1,31 @@
---
# dance-lessons-coach Docker Push Workflow - Placeholder
# This workflow will be implemented to handle Docker image building and pushing
# Currently a placeholder to test workflow dispatch functionality
# dance-lessons-coach Docker Push Workflow
# Separate workflow for Docker image building and pushing
# Can be triggered manually or by CI/CD workflow
name: Docker Push
on:
# Manual trigger only for testing
# Manual trigger for testing or production
workflow_dispatch:
inputs:
deps_hash:
description: 'Dependency hash from build-cache job'
required: true
type: string
ref:
description: 'Git reference (branch/tag)'
required: false
type: string
default: ''
# Environment variables
env:
GITEA_INTERNAL: "https://gitea.arcodange.lab/"
GITEA_EXTERNAL: "https://gitea.arcodange.fr/"
GITEA_ORG: "arcodange"
GITEA_REPO: "dance-lessons-coach"
CI_REGISTRY: "gitea.arcodange.lab"
jobs:
placeholder:
name: Docker Push Placeholder
docker-push:
name: Docker Push
runs-on: ubuntu-latest-ca
steps:
@@ -30,10 +34,106 @@ jobs:
with:
ref: ${{ github.event.inputs.ref || github.ref }}
- name: Show workflow inputs
- name: Login to Gitea Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.CI_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.PACKAGES_TOKEN }}
- name: Calculate dependency hash
id: calc_hash
run: |
echo "🚀 Docker Push Workflow Triggered"
echo "Dependency Hash: ${{ github.event.inputs.deps_hash }}"
echo "Git Reference: ${{ github.event.inputs.ref || github.ref }}"
echo "📝 This is a placeholder - full implementation coming soon!"
echo "✅ Workflow dispatch is working correctly!"
# Calculate dependency hash (same method as build-cache job)
DEPS_HASH=$(sha256sum go.mod go.sum docker/Dockerfile.build | sha256sum | cut -d' ' -f1 | head -c 12)
echo "Dependency hash: $DEPS_HASH"
echo "deps_hash=$DEPS_HASH" >> $GITHUB_OUTPUT
- name: Build and push Docker image
run: |
source VERSION
IMAGE_VERSION="$MAJOR.$MINOR.$PATCH${PRERELEASE:+-$PRERELEASE}"
# Use the calculated dependency hash
DEPS_HASH="${{ steps.calc_hash.outputs.deps_hash }}"
echo "Using dependency hash: $DEPS_HASH"
TAGS="$IMAGE_VERSION latest ${{ github.sha }}"
echo "Building Docker image with tags: $TAGS"
# Build the production image using inline version of docker/Dockerfile
docker build -t dance-lessons-coach -f - . <<'EOF'
# dance-lessons-coach Docker Image
# Multi-stage build for production deployment
# Stage 1: Build binary
FROM golang:1.26.1-alpine AS builder
WORKDIR /app
# Copy go mod files
COPY go.mod go.sum ./
RUN go mod download
# Copy source code
COPY . ./
# Install swag and generate Swagger docs only if they don't exist
RUN if [ ! -f pkg/server/docs/swagger.json ]; then \
echo "📝 Generating Swagger documentation..." && \
go install github.com/swaggo/swag/cmd/swag@latest && \
cd pkg/server && go generate && \
echo "✅ Swagger documentation generated"; \
else \
echo "✅ Swagger documentation already exists, skipping swag installation and generation"; \
fi
# Build binary
RUN CGO_ENABLED=0 GOOS=linux go build -o /dance-lessons-coach ./cmd/server
# Stage 2: Final image
FROM alpine:3.18
WORKDIR /app
# Install dependencies
RUN apk add --no-cache ca-certificates tzdata
# Copy binary from builder
COPY --from=builder /dance-lessons-coach /app/dance-lessons-coach
# Copy configuration
COPY config.yaml /app/config.yaml
# Set permissions
RUN chmod +x /app/dance-lessons-coach
# Set timezone
ENV TZ=UTC
# Expose port
EXPOSE 8080
# Health check
HEALTHCHECK --interval=30s --timeout=3s \
CMD wget -q --spider http://localhost:8080/api/health || exit 1
# Entry point
ENTRYPOINT ["/app/dance-lessons-coach"]
EOF
for TAG in $TAGS; do
IMAGE_NAME="${{ env.CI_REGISTRY }}/${{ env.GITEA_ORG }}/${{ env.GITEA_REPO }}:$TAG"
echo "Tagging and pushing: $IMAGE_NAME"
docker tag dance-lessons-coach "$IMAGE_NAME"
docker push "$IMAGE_NAME"
done
- name: Show published images
run: |
source VERSION
IMAGE_VERSION="$MAJOR.$MINOR.$PATCH${PRERELEASE:+-$PRERELEASE}"
echo "📦 Published Docker images:"
echo " - ${{ env.CI_REGISTRY }}/${{ env.GITEA_ORG }}/${{ env.GITEA_REPO }}:$IMAGE_VERSION"
echo " - ${{ env.CI_REGISTRY }}/${{ env.GITEA_ORG }}/${{ env.GITEA_REPO }}:latest"
echo " - ${{ env.CI_REGISTRY }}/${{ env.GITEA_ORG }}/${{ env.GITEA_REPO }}:${{ github.sha }}"