From 194f517be833df5acd7c21d1f012dca690614a6b Mon Sep 17 00:00:00 2001 From: Michael Kuhn Date: Tue, 2 Apr 2024 20:51:15 +0200 Subject: [PATCH] Improve Dockerfiles - Specify Docker registry explicitly (e.g., Podman does not use `docker.io` by default) - Use `make miniflux` instead of duplicating `go build` arguments (this leverages Go's PIE build mode) - Enable cgo to fix ARM containers (we need to make sure to use the same OS version for both container stages to avoid libc issues) --- packaging/docker/alpine/Dockerfile | 12 ++++-------- packaging/docker/distroless/Dockerfile | 10 +++------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/packaging/docker/alpine/Dockerfile b/packaging/docker/alpine/Dockerfile index 9fc93858..93355295 100644 --- a/packaging/docker/alpine/Dockerfile +++ b/packaging/docker/alpine/Dockerfile @@ -1,14 +1,10 @@ -FROM golang:alpine AS build -ENV CGO_ENABLED=0 -RUN apk add --no-cache --update git +FROM docker.io/library/golang:alpine3.19 AS build +RUN apk add --no-cache build-base git make ADD . /go/src/app WORKDIR /go/src/app -RUN go build \ - -o miniflux \ - -ldflags="-s -w -X 'miniflux.app/v2/internal/version.Version=`git describe --tags --abbrev=0`' -X 'miniflux.app/v2/internal/version.Commit=`git rev-parse --short HEAD`' -X 'miniflux.app/v2/internal/version.BuildDate=`date +%FT%T%z`'" \ - main.go +RUN make miniflux -FROM alpine:latest +FROM docker.io/library/alpine:3.19 LABEL org.opencontainers.image.title=Miniflux LABEL org.opencontainers.image.description="Miniflux is a minimalist and opinionated feed reader" diff --git a/packaging/docker/distroless/Dockerfile b/packaging/docker/distroless/Dockerfile index 5d50dd98..a4080891 100644 --- a/packaging/docker/distroless/Dockerfile +++ b/packaging/docker/distroless/Dockerfile @@ -1,13 +1,9 @@ -FROM golang:latest AS build -ENV CGO_ENABLED=0 +FROM docker.io/library/golang:bookworm AS build ADD . /go/src/app WORKDIR /go/src/app -RUN go build \ - -o miniflux \ - -ldflags="-s -w -X 'miniflux.app/v2/internal/version.Version=`git describe --tags --abbrev=0`' -X 'miniflux.app/v2/internal/version.Commit=`git rev-parse --short HEAD`' -X 'miniflux.app/v2/internal/version.BuildDate=`date +%FT%T%z`'" \ - main.go +RUN make miniflux -FROM gcr.io/distroless/base:nonroot +FROM gcr.io/distroless/base-debian12:nonroot LABEL org.opencontainers.image.title=Miniflux LABEL org.opencontainers.image.description="Miniflux is a minimalist and opinionated feed reader"