mirror of
https://github.com/lukaszraczylo/gohoarder.git
synced 2026-06-05 22:53:53 +00:00
0a2c5f6c2c
go.mod requires go >= 1.25.5 but Dockerfiles were using golang:1.23-alpine. Updated all Go-based Dockerfiles to use golang:1.25-alpine. Affected files: - Dockerfile.server - Dockerfile.scanner - Dockerfile.migrate This fixes the build error: "go: go.mod requires go >= 1.25.5 (running go 1.23.12; GOTOOLCHAIN=local)"
67 lines
1.4 KiB
Docker
67 lines
1.4 KiB
Docker
# Migration Engine - Database Migration Tool
|
|
# Multi-stage build to compile with CGO support
|
|
ARG TARGETOS=linux
|
|
ARG TARGETARCH=amd64
|
|
|
|
# Build stage
|
|
FROM --platform=$TARGETOS/$TARGETARCH golang:1.25-alpine AS builder
|
|
|
|
# Install build dependencies for CGO
|
|
RUN apk add --no-cache \
|
|
gcc \
|
|
g++ \
|
|
musl-dev \
|
|
sqlite-dev \
|
|
git
|
|
|
|
WORKDIR /build
|
|
|
|
# Copy go mod files
|
|
COPY go.mod go.sum ./
|
|
RUN go mod download
|
|
|
|
# Copy source code
|
|
COPY . .
|
|
|
|
# Build with CGO enabled
|
|
ARG TARGETOS
|
|
ARG TARGETARCH
|
|
ARG VERSION=dev
|
|
ARG GIT_COMMIT=unknown
|
|
ARG BUILD_TIME=unknown
|
|
|
|
RUN CGO_ENABLED=1 GOOS=$TARGETOS GOARCH=$TARGETARCH \
|
|
go build -ldflags="-s -w \
|
|
-X main.Version=${VERSION} \
|
|
-X main.GitCommit=${GIT_COMMIT} \
|
|
-X main.BuildTime=${BUILD_TIME}" \
|
|
-o migrate ./cmd/migrate
|
|
|
|
# Runtime stage
|
|
FROM alpine:latest
|
|
|
|
# Install runtime dependencies (including CGO/SQLite dependencies)
|
|
RUN apk add --no-cache \
|
|
ca-certificates \
|
|
postgresql-client \
|
|
mysql-client \
|
|
busybox-extras \
|
|
sqlite-libs \
|
|
musl \
|
|
&& update-ca-certificates
|
|
|
|
# Create non-root user
|
|
RUN addgroup -g 1000 gohoarder && \
|
|
adduser -D -u 1000 -G gohoarder gohoarder
|
|
|
|
# Copy binary from builder
|
|
COPY --from=builder /build/migrate /usr/local/bin/migrate
|
|
RUN chmod +x /usr/local/bin/migrate
|
|
|
|
WORKDIR /app
|
|
USER gohoarder
|
|
|
|
# Run migrations
|
|
ENTRYPOINT ["/usr/local/bin/migrate"]
|
|
CMD ["--action=migrate"]
|