build debug
Build and Push Docker Image / build-and-push (push) Successful in 4m39s

Signed-off-by: kaedwen <kaedwen@heinrich.blue>
This commit is contained in:
kaedwen
2026-07-04 20:55:56 +02:00
parent 1f70dd91dd
commit 0a52786c86
2 changed files with 96 additions and 1 deletions
+29 -1
View File
@@ -58,6 +58,20 @@ jobs:
type=sha,prefix={{branch}}-
type=raw,value=latest,enable={{is_default_branch}}
- name: Extract metadata for debug image
id: meta-debug
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch,suffix=-debug
type=ref,event=pr,suffix=-debug
type=semver,pattern={{version}},suffix=-debug
type=semver,pattern={{major}}.{{minor}},suffix=-debug
type=semver,pattern={{major}},suffix=-debug
type=sha,prefix={{branch}}-,suffix=-debug
type=raw,value=debug,enable={{is_default_branch}}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
@@ -70,5 +84,19 @@ jobs:
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache,mode=max
platforms: linux/amd64
- name: Build and push debug Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile.debug
push: true
tags: ${{ steps.meta-debug.outputs.tags }}
labels: ${{ steps.meta-debug.outputs.labels }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-debug
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-debug,mode=max
platforms: linux/amd64
- name: Image digest
run: echo ${{ steps.meta.outputs.digest }}
run: |
echo "Production: ${{ steps.meta.outputs.digest }}"
echo "Debug: ${{ steps.meta-debug.outputs.digest }}"
+67
View File
@@ -0,0 +1,67 @@
# Debug build with shell and tools
FROM golang:1.26-alpine AS builder
WORKDIR /build
# Install build dependencies
RUN apk add --no-cache git
# Copy go mod files
COPY go.mod go.sum ./
RUN go mod download
# Copy source code
COPY . .
# Build the application (static binary, no CGO, migrations embedded)
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
-a \
-installsuffix cgo \
-ldflags="-w -s -extldflags '-static'" \
-o aitrade \
./cmd/aitrade
# Build healthcheck utility
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
-ldflags="-w -s -extldflags '-static'" \
-o healthcheck \
./cmd/healthcheck
# Debug runtime stage - Alpine with shell and debugging tools
FROM alpine:latest
# Install debugging tools
RUN apk add --no-cache \
bash \
curl \
wget \
netcat-openbsd \
bind-tools \
busybox-extras \
ca-certificates \
sqlite \
tzdata
# Set working directory
WORKDIR /app
# Copy binary from builder (migrations are embedded in binary)
COPY --from=builder /build/aitrade /app/aitrade
COPY --from=builder /build/healthcheck /app/healthcheck
# Create non-root user
RUN addgroup -g 1000 appuser && \
adduser -D -u 1000 -G appuser appuser && \
chown -R appuser:appuser /app
USER appuser
# Expose web port
EXPOSE 8080
# Health check using custom binary
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD ["/app/healthcheck", "localhost", "8080"]
# Run application
ENTRYPOINT ["/app/aitrade"]