🔧 chore: merge docker-workflow-clean optimizations into move-docker-job
This commit is contained in:
@@ -41,68 +41,20 @@ jobs:
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.PACKAGES_TOKEN }}
|
||||
|
||||
- name: Calculate dependency hash
|
||||
id: calc_hash
|
||||
run: |
|
||||
# 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 Dockerfile
|
||||
docker build -t dance-lessons-coach -f - . <<'EOF'
|
||||
# dance-lessons-coach Production Docker Image
|
||||
# Inline Dockerfile - no template needed
|
||||
|
||||
# Use the build cache image as base
|
||||
FROM gitea.arcodange.lab/arcodange/dance-lessons-coach-build-cache:${DEPS_HASH} AS builder
|
||||
|
||||
# Set working directory and build the binary
|
||||
WORKDIR /workspace
|
||||
RUN go build -o dance-lessons-coach ./cmd/server
|
||||
|
||||
# Final minimal image
|
||||
FROM alpine:3.18
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install minimal dependencies
|
||||
RUN apk add --no-cache ca-certificates tzdata
|
||||
|
||||
# Copy binary from builder
|
||||
COPY --from=builder /workspace/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
|
||||
# Build using the standard Dockerfile (Attempt 2 - simplest approach)
|
||||
docker build -t dance-lessons-coach -f docker/Dockerfile .
|
||||
|
||||
for TAG in $TAGS; do
|
||||
IMAGE_NAME="${{ env.CI_REGISTRY }}/${{ env.GITEA_ORG }}/${{ env.GITEA_REPO }}:$TAG"
|
||||
|
||||
@@ -32,12 +32,12 @@ RUN go install github.com/swaggo/swag/cmd/swag@latest && \
|
||||
go install golang.org/x/tools/cmd/goimports@latest && \
|
||||
go install honnef.co/go/tools/cmd/staticcheck@latest
|
||||
|
||||
# Simple build environment - source code is mounted at runtime
|
||||
WORKDIR /build
|
||||
|
||||
# Copy only go.mod and go.sum first for dependency caching
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download && go mod verify
|
||||
|
||||
# Simple build environment - source code is mounted at runtime
|
||||
WORKDIR /workspace
|
||||
|
||||
# Pre-download common Go tools (already installed in base)
|
||||
# RUN go install github.com/swaggo/swag/cmd/swag@latest
|
||||
Reference in New Issue
Block a user