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)
This commit is contained in:
Michael Kuhn 2024-04-02 20:51:15 +02:00 committed by Frédéric Guillot
parent 11fd1c935e
commit 194f517be8
2 changed files with 7 additions and 15 deletions

View file

@ -1,14 +1,10 @@
FROM golang:alpine AS build FROM docker.io/library/golang:alpine3.19 AS build
ENV CGO_ENABLED=0 RUN apk add --no-cache build-base git make
RUN apk add --no-cache --update git
ADD . /go/src/app ADD . /go/src/app
WORKDIR /go/src/app WORKDIR /go/src/app
RUN go build \ RUN make miniflux
-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
FROM alpine:latest FROM docker.io/library/alpine:3.19
LABEL org.opencontainers.image.title=Miniflux LABEL org.opencontainers.image.title=Miniflux
LABEL org.opencontainers.image.description="Miniflux is a minimalist and opinionated feed reader" LABEL org.opencontainers.image.description="Miniflux is a minimalist and opinionated feed reader"

View file

@ -1,13 +1,9 @@
FROM golang:latest AS build FROM docker.io/library/golang:bookworm AS build
ENV CGO_ENABLED=0
ADD . /go/src/app ADD . /go/src/app
WORKDIR /go/src/app WORKDIR /go/src/app
RUN go build \ RUN make miniflux
-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
FROM gcr.io/distroless/base:nonroot FROM gcr.io/distroless/base-debian12:nonroot
LABEL org.opencontainers.image.title=Miniflux LABEL org.opencontainers.image.title=Miniflux
LABEL org.opencontainers.image.description="Miniflux is a minimalist and opinionated feed reader" LABEL org.opencontainers.image.description="Miniflux is a minimalist and opinionated feed reader"