# Build stage FROM docker.io/library/golang:1.24-alpine AS build-env # Install build dependencies RUN apk --no-cache add \ build-base \ && rm -rf /var/cache/apk/* # Set up the working directory WORKDIR /app # Copy go mod files COPY go.mod go.sum ./ # Download dependencies RUN go mod download # Copy source code COPY . . # Build the application RUN CGO_ENABLED=0 go build -tags sqlite_allow_null_time -o transcriber . # ---------------- # Production stage # ---------------- FROM docker.io/library/alpine:latest LABEL maintainer="anton@vakhrushev.me" # Install runtime dependencies RUN apk --no-cache add \ ca-certificates \ ffmpeg \ && rm -rf /var/cache/apk/* # Create user and group RUN addgroup -S -g 1000 transcriber && \ adduser -S -H -D \ -h /data/transcriber \ -s /bin/sh \ -u 1000 \ -G transcriber \ transcriber # Set environment variables ENV USER=transcriber # Create necessary directories RUN mkdir -p /data && chown -R transcriber:transcriber /data RUN mkdir -p /config && chown -R transcriber:transcriber /config # Set working directory WORKDIR /app # Copy the binary from build stage COPY --from=build-env /app/transcriber . # Copy entrypoint script COPY docker/entrypoint.sh /usr/bin/entrypoint RUN chmod 755 /usr/bin/entrypoint # Set user USER transcriber EXPOSE 8080 # Set entrypoint and default command ENTRYPOINT ["/usr/bin/entrypoint"] CMD ["./transcriber"]