nezha/Dockerfile.agent
2020-11-06 21:25:17 +08:00

28 lines
816 B
Docker

FROM golang:alpine AS binarybuilder
RUN apk --no-cache --no-progress add \
gcc git musl-dev
WORKDIR /agent
COPY . .
RUN cd cmd/agent && go build -o app -ldflags="-s -w -X github.com/p14yground/nezha/service/dao.Version=$(git rev-parse HEAD)"
FROM alpine:latest
RUN apk --no-cache --no-progress add \
ca-certificates \
tzdata
WORKDIR /agent
COPY --from=binarybuilder /agent/cmd/agent/app ./app
ENV HOST_PROC=/agent/host/proc \
HOST_SYS=/agent/host/sys \
HOST_ETC=/agent/host/etc \
HOST_VAR=/agent/host/var \
HOST_RUN=/agent/host/run \
HOST_DEV=/agent/host/dev \
DEBUG=false
ENV [ID, SECRET, SERVER]
VOLUME ["/agent/host/proc", "/agent/host/sys", "/agent/host/etc", "/agent/host/var", "/agent/host/run", "/agent/host/dev"]
CMD /agent/app -s $SERVER -i $ID -p $SECRET -d $DEBUG