Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Git
.git
.gitignore
.gitattributes

# IDE
.idea
.vscode
*.swp
*.swo
*~

# Documentation
*.md
README.md
LICENSE

# CI/CD
.github

# Test files and sample data
*_test.go
test_utils.go
sample-requests
configtest

# Build artifacts
prebid-cache
*.exe
*.dll
*.so
*.dylib

# Go vendor directory (created in container)
vendor/

# Temporary files
*.tmp
*.log
.DS_Store

# Docker
Dockerfile*
.dockerignore
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ prebid-cache

# ide
.vscode/
.idea/

# autogenerated mac file

Expand Down
61 changes: 30 additions & 31 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,39 +1,38 @@
FROM ubuntu:22.04 AS build
RUN apt-get update && \
apt-get -y upgrade && \
apt-get install -y --no-install-recommends wget ca-certificates
ENV GO_INSTALLER=go1.19.5.linux-amd64.tar.gz
WORKDIR /tmp
RUN wget https://dl.google.com/go/$GO_INSTALLER && \
tar -C /usr/local -xzf $GO_INSTALLER
RUN mkdir -p /app/prebid-cache/
FROM alpine:3.23 AS build

RUN apk update && \
apk add --no-cache go=1.25.5-r0 git bash ca-certificates && \
rm -rf /var/cache/apk/*

ENV GOPROXY="https://proxy.golang.org" \
CGO_ENABLED=0

WORKDIR /app/prebid-cache/
ENV GOROOT=/usr/local/go
ENV PATH=$GOROOT/bin:$PATH
ENV GOPROXY="https://proxy.golang.org"
RUN apt-get update && \
apt-get install -y --no-install-recommends git && \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
ENV CGO_ENABLED 0
COPY ./ ./

COPY go.mod go.sum ./
RUN go mod download && go mod verify

COPY . .
RUN go mod vendor
RUN go mod tidy

ARG TEST="true"
RUN if [ "$TEST" != "false" ]; then ./validate.sh ; fi
RUN go build -mod=vendor -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 ubuntu:22.04 AS release
LABEL maintainer="hans.hjort@xandr.com"
RUN apt-get update && \
apt-get install -y --no-install-recommends ca-certificates && \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN go build -mod=vendor -ldflags "-X github.com/prebid/prebid-cache/version.Ver=$(git describe --tags 2>/dev/null || echo 'dev') -X github.com/prebid/prebid-cache/version.Rev=$(git rev-parse HEAD 2>/dev/null || echo 'unknown')" .
FROM alpine:3.23 AS release
LABEL maintainer="hans.hjort@xandr.com"

RUN apk add --no-cache ca-certificates && \
rm -rf /var/cache/apk/*

RUN addgroup -g 2001 -S prebidgroup && \
adduser -u 1001 -S -G prebidgroup prebid

WORKDIR /usr/local/bin/
COPY --from=build /app/prebid-cache/prebid-cache .
RUN chmod a+xr prebid-cache
COPY --from=build /app/prebid-cache/config.yaml .
RUN chmod a+r config.yaml
RUN addgroup --system --gid 2001 prebidgroup && adduser --system --uid 1001 --ingroup prebidgroup prebid

COPY --from=build /app/prebid-cache/prebid-cache \
/app/prebid-cache/config.yaml ./

USER prebid
EXPOSE 2424
EXPOSE 2525
EXPOSE 2424 2525
ENTRYPOINT ["/usr/local/bin/prebid-cache"]