49 lines
898 B
Docker
49 lines
898 B
Docker
# UI build stage
|
|
ARG TARGETOS
|
|
ARG TARGETARCH
|
|
FROM node:alpine AS ui-builder
|
|
|
|
WORKDIR /app
|
|
|
|
COPY otel-ui/ .
|
|
|
|
RUN npm install && npm run build
|
|
|
|
# Go build stage
|
|
FROM --platform=$BUILDPLATFORM golang:1.25-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
|
|
|
|
RUN apk --no-cache add ca-certificates
|
|
|
|
# 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
|
|
|
|
# Ensure the appuser owns the files
|
|
RUN chown -R appuser:appgroup /home/appuser/
|
|
|
|
USER appuser
|
|
|
|
EXPOSE 8080
|
|
|
|
CMD ["./go-otel"]
|