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
21 changes: 14 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
FROM --platform="${BUILDPLATFORM:-linux/amd64}" docker.io/busybox:1.37.0 as builder
FROM --platform=linux/amd64 node:20.18.0-alpine3.20 as ui-builder

ARG TARGETOS TARGETARCH TARGETVARIANT
WORKDIR /ui
COPY ui/ .
RUN npm install react-scripts
RUN npm install
RUN npm run build

FROM --platform=linux/amd64 golang:1.23.3-alpine3.20 as go-builder
WORKDIR /app
COPY dist dist
COPY . .
COPY --from=ui-builder /ui/build ui/build
RUN CGO_ENABLED=0 go build -v -ldflags '-w -extldflags '-static'' -o pyrra

# NOTICE: See goreleaser.yml for the build paths.
RUN if [ "${TARGETARCH}" = 'amd64' ]; then \
cp "dist/pyrra_${TARGETOS}_${TARGETARCH}_${TARGETVARIANT:-v1}/pyrra" . ; \
cp "dist/pyrra_${TARGETOS}_${TARGETARCH}_${TARGETVARIANT:-v1}/pyrra" . ; \
elif [ "${TARGETARCH}" = 'arm' ]; then \
cp "dist/pyrra_${TARGETOS}_${TARGETARCH}_${TARGETVARIANT##v}/pyrra" . ; \
cp "dist/pyrra_${TARGETOS}_${TARGETARCH}_${TARGETVARIANT##v}/pyrra" . ; \
else \
cp "dist/pyrra_${TARGETOS}_${TARGETARCH}/pyrra" . ; \
cp "dist/pyrra_${TARGETOS}_${TARGETARCH}/pyrra" . ; \
fi
RUN chmod +x pyrra

FROM --platform="${TARGETPLATFORM:-linux/amd64}" docker.io/alpine:3.21.2 AS runner
WORKDIR /
COPY --chown=0:0 --from=builder /app/pyrra /usr/bin/pyrra
COPY --chown=0:0 --from=go-builder /app/pyrra /usr/bin/pyrra
USER 65533

ENTRYPOINT ["/usr/bin/pyrra"]
11 changes: 11 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ var CLI struct {
TLSCertFile string `default:"" help:"File containing the default x509 Certificate for HTTPS."`
TLSPrivateKeyFile string `default:"" help:"File containing the default x509 private key matching --tls-cert-file."`
TLSClientCAFile string `default:"" help:"File containing the CA certificate for the client"`
MimirTenantIds []string `default:"" help:"Mimir tenant IDs to query if multi-tenancy is enabled."`
} `cmd:"" help:"Runs Pyrra's API and UI."`
Filesystem struct {
ConfigFiles string `default:"/etc/pyrra/*.yaml" help:"The folder where Pyrra finds the config files to use. Any non yaml files will be ignored."`
Expand Down Expand Up @@ -131,6 +132,16 @@ func main() {
if CLI.API.TLSClientCAFile != "" {
clientConfig.TLSConfig = promconfig.TLSConfig{CAFile: CLI.API.TLSClientCAFile}
}
if len(CLI.API.MimirTenantIds) > 0 {
mimirHeaderValue := strings.Join(CLI.API.MimirTenantIds, "|")
clientConfig.HTTPHeaders = &promconfig.Headers{
Headers: map[string]promconfig.Header{
"X-Scope-OrgID": {
Values: []string{mimirHeaderValue},
},
},
}
}

roundTripper, err := promconfig.NewRoundTripperFromConfig(clientConfig, "prometheus")
if err != nil {
Expand Down
Loading