| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent f3be4c6 commit acaae4e
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,65 @@ | |||
| 1 | + # Multi-stage Dockerfile for chromad Go application using Hermit-managed tools | ||
| 2 | + | ||
| 3 | + # Build stage | ||
| 4 | + FROM ubuntu:22.04 AS builder | ||
| 5 | + | ||
| 6 | + # Install system dependencies | ||
| 7 | + RUN apt-get update && apt-get install -y \ | ||
| 8 | + curl \ | ||
| 9 | + git \ | ||
| 10 | + make \ | ||
| 11 | + ca-certificates \ | ||
| 12 | + && rm -rf /var/lib/apt/lists/* | ||
| 13 | + | ||
| 14 | + # Set working directory | ||
| 15 | + WORKDIR /app | ||
| 16 | + | ||
| 17 | + # Copy the entire project (including bin directory with Hermit tools) | ||
| 18 | + COPY . . | ||
| 19 | + | ||
| 20 | + # Make Hermit tools executable and add to PATH | ||
| 21 | + ENV PATH="/app/bin:${PATH}" | ||
| 22 | + | ||
| 23 | + # Set Go environment variables for static compilation | ||
| 24 | + ENV CGO_ENABLED=0 | ||
| 25 | + ENV GOOS=linux | ||
| 26 | + ENV GOARCH=amd64 | ||
| 27 | + | ||
| 28 | + # Build the application using make | ||
| 29 | + RUN make build/chromad | ||
| 30 | + | ||
| 31 | + # Runtime stage | ||
| 32 | + FROM alpine:3.19 AS runtime | ||
| 33 | + | ||
| 34 | + # Install ca-certificates for HTTPS requests | ||
| 35 | + RUN apk --no-cache add ca-certificates | ||
| 36 | + | ||
| 37 | + # Create a non-root user | ||
| 38 | + RUN addgroup -g 1001 chromad && \ | ||
| 39 | + adduser -D -s /bin/sh -u 1001 -G chromad chromad | ||
| 40 | + | ||
| 41 | + # Set working directory | ||
| 42 | + WORKDIR /app | ||
| 43 | + | ||
| 44 | + # Copy the binary from build stage | ||
| 45 | + COPY --from=builder /app/build/chromad /app/chromad | ||
| 46 | + | ||
| 47 | + # Change ownership to non-root user | ||
| 48 | + RUN chown chromad:chromad /app/chromad | ||
| 49 | + | ||
| 50 | + # Switch to non-root user | ||
| 51 | + USER chromad | ||
| 52 | + | ||
| 53 | + # Expose port (default is 8080, but can be overridden via PORT env var) | ||
| 54 | + EXPOSE 8080 | ||
| 55 | + | ||
| 56 | + # Set default environment variables | ||
| 57 | + ENV PORT=0.0.0.0:8080 | ||
| 58 | + ENV CHROMA_CSRF_KEY="testtest" | ||
| 59 | + | ||
| 60 | + # Health check | ||
| 61 | + HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ | ||
| 62 | + CMD curl -fsSL http://127.0.0.1:8080/ > /dev/null | ||
| 63 | + | ||
| 64 | + # Run the application | ||
| 65 | + CMD ["sh", "-c", "./chromad --csrf-key=$CHROMA_CSRF_KEY --bind=$PORT"] | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments