docker-deploy/drone/Dockerfile
2021-12-03 23:45:25 +08:00

42 lines
1.2 KiB
Docker

FROM golang:alpine AS Builder
WORKDIR /src
ENV DRONE_VERSION "v2.5.0"
ENV CGO_CFLAGS="-g -O2 -Wno-return-local-addr"
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories && \
echo "Asia/Shanghai" > /etc/timezone && \
apk add build-base git ca-certificates && \
git clone https://github.com/harness/drone.git drone-${DRONE_VERSION}
WORKDIR /src/drone-${DRONE_VERSION}
RUN go env -w GOPROXY="https://goproxy.cn,direct" && \
go mod download && \
go build -ldflags "-extldflags \"-static\"" -tags="nolimit" github.com/drone/drone/cmd/drone-server
FROM alpine
EXPOSE 80 443
VOLUME /data
RUN [ ! -e /etc/nsswitch.conf ] && echo 'hosts: files dns' > /etc/nsswitch.conf
ENV GODEBUG netdns=go
ENV XDG_CACHE_HOME /data
ENV DRONE_DATABASE_DRIVER sqlite3
ENV DRONE_DATABASE_DATASOURCE /data/database.sqlite
ENV DRONE_RUNNER_OS=linux
ENV DRONE_RUNNER_ARCH=amd64
ENV DRONE_SERVER_PORT=:80
ENV DRONE_SERVER_HOST=localhost
ENV DRONE_DATADOG_ENABLED=true
ENV DRONE_DATADOG_ENDPOINT=https://stats.drone.ci/api/v1/series
COPY --from=Builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=Builder /src/drone-v2.5.0/drone-server /bin/drone-server
ENTRYPOINT ["/bin/drone-server"]