feat: add multi-stage Dockerfile and docker-compose.yml
- Multi-stage Dockerfile: golang:1.24-alpine builder → alpine:3.21 runtime - CGO_ENABLED=0 for static binary, stripped with -ldflags="-s -w" - Only copies ca-certificates and tzdata to runtime image - Config via volume mount at /etc/gosearch/config.toml - docker-compose.yml: gosearch + Valkey 8 - Valkey healthcheck ensures gosearch starts after cache is ready - Persistent Valkey volume - config.toml mounted read-only - Update .gitignore with Go build artifacts
This commit is contained in:
parent
94322ceff4
commit
4c54ed5b56
4 changed files with 70 additions and 0 deletions
27
Dockerfile
Normal file
27
Dockerfile
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
# Build stage
|
||||
FROM golang:1.24-alpine AS builder
|
||||
|
||||
RUN apk add --no-cache git
|
||||
|
||||
WORKDIR /src
|
||||
|
||||
# Cache module downloads
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
# Copy source and build
|
||||
COPY . .
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /gosearch ./cmd/searxng-go
|
||||
|
||||
# Runtime stage
|
||||
FROM alpine:3.21
|
||||
|
||||
RUN apk add --no-cache ca-certificates tzdata
|
||||
|
||||
COPY --from=builder /gosearch /usr/local/bin/gosearch
|
||||
COPY config.example.toml /etc/gosearch/config.example.toml
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
ENTRYPOINT ["gosearch"]
|
||||
CMD ["-config", "/etc/gosearch/config.toml"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue