mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-09-28 05:46:36 +08:00
9d56f02e64
Relocate agent-entrypoint.sh from docker/ to scripts/ so operational shell scripts live in one directory and update Dockerfile.agent copy path.
46 lines
1.5 KiB
Docker
46 lines
1.5 KiB
Docker
# syntax=docker/dockerfile:1.7
|
|
ARG VERSION=dev
|
|
|
|
FROM golang:1.25-alpine AS builder
|
|
|
|
ARG VERSION
|
|
ARG TARGETOS=linux
|
|
ARG TARGETARCH
|
|
|
|
ENV CGO_ENABLED=0 \
|
|
GOOS=${TARGETOS} \
|
|
GOARCH=${TARGETARCH}
|
|
|
|
WORKDIR /build
|
|
COPY go.mod go.sum ./
|
|
RUN --mount=type=cache,target=/go/pkg/mod \
|
|
go mod download
|
|
|
|
COPY . .
|
|
RUN apk add --no-cache bash curl \
|
|
&& bash scripts/fetch-agent-geoip-mmdb.sh
|
|
RUN --mount=type=cache,target=/go/pkg/mod \
|
|
--mount=type=cache,target=/root/.cache/go-build \
|
|
go build -trimpath -ldflags "-s -w -X 'github.com/Rain-kl/Wavelet/internal/apps/agent/config.Version=$VERSION'" -o /build/bin/openflare-agent ./cmd/agent/main.go
|
|
|
|
FROM openresty/openresty:alpine
|
|
|
|
RUN apk add --no-cache ca-certificates tzdata perl libmaxminddb su-exec libcap \
|
|
&& ln -sf /usr/lib/libmaxminddb.so.0 /usr/lib/libmaxminddb.so \
|
|
&& opm get anjia0532/lua-resty-maxminddb \
|
|
&& addgroup -S openflare \
|
|
&& adduser -S -G openflare -H -h /data -s /sbin/nologin openflare \
|
|
&& mkdir -p /etc/openflare /data \
|
|
&& chown -R openflare:openflare /etc/openflare /data \
|
|
&& setcap 'cap_net_bind_service=+ep' /usr/local/openresty/nginx/sbin/nginx
|
|
|
|
ENV OPENFLARE_OPENRESTY_PATH=openresty \
|
|
OPENFLARE_DATA_DIR=/data
|
|
|
|
COPY --from=builder /build/bin/openflare-agent /usr/local/bin/openflare-agent
|
|
COPY scripts/agent-entrypoint.sh /usr/local/bin/openflare-agent-entrypoint.sh
|
|
RUN chmod +x /usr/local/bin/openflare-agent-entrypoint.sh
|
|
|
|
EXPOSE 80 443 18081
|
|
ENTRYPOINT ["/usr/local/bin/openflare-agent-entrypoint.sh"]
|
|
CMD ["-config", "/etc/openflare/agent.json"] |