Files
go-otel/Dockerfile
T
mats 193e6c6e39
Build and Publish / Metadata (push) Successful in 4s
Build and Publish / BuildAndPushAmd64 (push) Failing after 1m27s
update rum
2026-11-04 13:04:34 +01:00

78 lines
1.7 KiB
Docker

ARG APP_RELEASE=dev
ARG PUBLIC_SOURCEMAPS=false
# UI build stage
ARG TARGETOS
ARG TARGETARCH
FROM node:alpine AS ui-builder
ARG APP_RELEASE
ENV VITE_APP_RELEASE=${APP_RELEASE}
WORKDIR /app
COPY otel-ui/ .
RUN npm install && npm run build
FROM node:24-alpine AS rum-builder
WORKDIR /app/rum
COPY rum/package*.json ./
RUN npm ci
COPY rum/ ./
COPY scripts/otel-rum.test.mjs /app/scripts/otel-rum.test.mjs
RUN npm test
# Go build stage
FROM --platform=$BUILDPLATFORM golang:1.27-alpine AS go-builder
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY cmd/ ./cmd
COPY internal/ ./internal
# Copy built UI dist
COPY --from=ui-builder /app/dist ./otel-ui/dist
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -a -installsuffix cgo -o /go-otel ./cmd/server
# Final stage
FROM alpine:latest
ARG PUBLIC_SOURCEMAPS
RUN apk --no-cache add ca-certificates nmap nmap-scripts
# Create non-root user
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
WORKDIR /home/appuser/
COPY --from=go-builder /go-otel .
COPY --from=go-builder /app/otel-ui/dist ./dist
COPY static/ ./static
COPY --from=rum-builder /app/static/ ./static/
COPY db/GeoLite2-City.mmdb db/GeoLite2-ASN.mmdb ./db/
COPY agents_example.md .
COPY instrumentation.md .
# Private server-side maps are the default. Staging/dev can opt into public
# maps for Chrome DevTools with --build-arg PUBLIC_SOURCEMAPS=true.
RUN if [ "${PUBLIC_SOURCEMAPS}" != "true" ]; then find ./dist ./static -type f -name '*.map' -delete; fi
# Ensure the appuser owns the files
RUN chown -R appuser:appgroup /home/appuser/
USER appuser
ENV OTEL_GEOIP_CITY_DB=/home/appuser/db/GeoLite2-City.mmdb \
OTEL_GEOIP_ASN_DB=/home/appuser/db/GeoLite2-ASN.mmdb
EXPOSE 8080
CMD ["./go-otel"]