Skip to content

Conversation

@decaffeinatedio
Copy link

@decaffeinatedio decaffeinatedio commented Dec 5, 2025

I ran a quick test to deploy Prebid Cache + Redis with Dokku on a random VPS and noticed a number of issues with the Dockerfile. I think this proposed PR will make things faster, cleaner and more secure.

FWIW, this also shrinks the (local) image size from ~129MB to ~29MB.

Major changes:

  • Switch from Ubuntu 22 to Alpine 3.23.
  • Support ARM
  • Pin Go version for more reproducible builds
  • Simplify build and strip out unwanted files with .dockerignore

@decaffeinatedio decaffeinatedio changed the title Use alpine Use Alpine and Clean Up Dockerfile Dec 5, 2025
@linux019
Copy link

I'm using a simpler dockerfile, also go vendoring is enabled to prevent modules download at the compile stage every time

ARG GOVERSION=1.25.3

FROM golang:${GOVERSION}-alpine3.22 AS builder
WORKDIR /build/
RUN apk add --no-cache pcre-dev bash gcc musl-dev git
COPY ./ ./
ARG TEST="false"
RUN if [ "$TEST" != "false" ]; then ./validate.sh ; fi
RUN go build -mod=vendor -trimpath -ldflags "\
    -X github.com/prebid/prebid-cache/version.Ver=$(git describe --tags) \
    -X github.com/prebid/prebid-cache/version.Rev=$(git rev-parse HEAD)" .

FROM alpine:3.22 AS release
WORKDIR /usr/local/bin/
COPY --from=builder --chmod=544 /build/prebid-cache .
COPY --from=builder --chmod=444 /build/config.yaml .
RUN adduser -D -H prebid_user
USER prebid_user
EXPOSE 2424 2525
ENTRYPOINT ["/usr/local/bin/prebid-cache"]

@decaffeinatedio
Copy link
Author

@linux019 I think your Dockerfile is even cleaner (trimpath is a good improvement, too). I can modify the PR to use that -- my main concerns were targeting ARM and not using a huge Ubuntu base image. Let me know!

@bsardo bsardo self-assigned this Dec 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants