Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
45 lines (38 loc) · 1.85 KB
/
Copy pathDockerfile
File metadata and controls
45 lines (38 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# syntax=docker/dockerfile:1
# One image, both transports:
# docker run -p 8000:8000 IMAGE -> HTTP on $PORT (default 8000; GET /health)
# docker run -i IMAGE stdio -> stdio worker, for DuckDB on the same host
# A pure-Go, statically linked build (no cgo): the worker doesn't link vgi-go's
# optional DuckDB expression evaluator (vgi/exprduckdb).
FROM golang:1.26-bookworm AS build
ENV CGO_ENABLED=0
WORKDIR /src
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod go mod download
COPY cmd ./cmd
COPY internal ./internal
RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build \
go build -trimpath -ldflags="-s -w" -o /out/vgi-cloudquery-worker ./cmd/vgi-cloudquery-worker
FROM debian:bookworm-slim
ARG VERSION=0.0.0
ARG GIT_COMMIT=unknown
LABEL org.opencontainers.image.title="vgi-cloudquery-worker" \
org.opencontainers.image.description="Host CloudQuery source plugins as DuckDB tables (a VGI worker)" \
org.opencontainers.image.source="https://github.com/Query-farm/vgi-cloudquery" \
org.opencontainers.image.version="${VERSION}" \
org.opencontainers.image.revision="${GIT_COMMIT}" \
org.opencontainers.image.licenses="0BSD"
# ca-certificates for outbound HTTPS, curl for the health check.
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates curl libstdc++6 \
&& rm -rf /var/lib/apt/lists/*
ENV PORT=8000
COPY --from=build --chmod=0755 /out/vgi-cloudquery-worker /usr/local/bin/vgi-cloudquery-worker
COPY --chmod=0755 docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
# Run as an unprivileged user.
RUN useradd --create-home --uid 10001 worker
USER worker
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s \
CMD curl -fsS "http://127.0.0.1:${PORT:-8000}/health" || exit 1
ENTRYPOINT ["docker-entrypoint.sh"]