diff --git a/drone/Dockerfile b/drone/Dockerfile new file mode 100644 index 0000000..314b6df --- /dev/null +++ b/drone/Dockerfile @@ -0,0 +1,41 @@ +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"] diff --git a/drone/docker-compose.yml b/drone/docker-compose.yml new file mode 100644 index 0000000..3d4b82a --- /dev/null +++ b/drone/docker-compose.yml @@ -0,0 +1,50 @@ +version: "3.9" +services: + drone-server: + image: esinio/drone:v2.5.0 + env_file: + - ./.env + environment: + - "TZ=Asia/Shanghai" + - "DRONE_GITEA_CLIENT_ID=${DRONE_GITEA_CLIENT_ID}" + - "DRONE_GITEA_CLIENT_SECRET=${DRONE_GITEA_CLIENT_SECRET}" + - "DRONE_GITEA_SERVER=${DRONE_GITEA_SERVER}" + - "DRONE_RPC_SECRET=${DRONE_RPC_SECRET}" + - "DRONE_SERVER_HOST=${DRONE_SERVER_HOST}" + - "DRONE_SERVER_PROTO=${DRONE_SERVER_PROTO}" + - "DRONE_DATABASE_DRIVER=${DRONE_DATABASE_DRIVER}" + - "DRONE_DATABASE_DATASOURCE=${DRONE_DATABASE_DATASOURCE}" + - "DRONE_DATABASE_SECRET=${DRONE_DATABASE_SECRET}" + - "DRONE_USER_CREATE=${DRONE_USER_CREATE}" + - "DRONE_USER_FILTER=${DRONE_USER_FILTER}" + - "DRONE_LOGS_DEBUG=${DRONE_LOGS_DEBUG}" + volumes: + - "./data:/data" + labels: + - "traefik.enable=true" + - "traefik.http.routers.dronesrv.rule=Host(`${DRONE_SERVER_HOST}`)" + - "traefik.http.routers.dronesrv.entrypoints=websecure" + - "traefik.http.routers.dronesrv.tls=true" + - "traefik.http.routers.dronesrv.middlewares=dronesrv-mw" + - "traefik.http.middlewares.dronesrv-mw.compress=true" + - "traefik.http.middlewares.dronesrv-mw.compress.excludedcontenttypes=text/event-stream" + - "traefik.http.services.dronesrv.loadbalancer.server.port=80" + external_links: + - postgresql + networks: + - traefik + drone-runner-docker: + image: drone/drone-runner-docker:1 + environment: + - "DRONE_RPC_HOST=${DRONE_SERVER_HOST}" + - "DRONE_RPC_PROTO=${DRONE_SERVER_PROTO}" + - "DRONE_RPC_SECRET=${DRONE_RPC_SECRET}" + - "DRONE_RUNNER_CAPACITY=${DRONE_RUNNER_CAPACITY}" + - "DRONE_RUNNER_NAME=${DRONE_RUNNER_DOCKER_NAME}}" + volumes: + - /var/run/docker.sock:/var/run/docker.sock + networks: + - traefik +networks: + traefik: + external: true \ No newline at end of file diff --git a/drone/run b/drone/run new file mode 100644 index 0000000..8b88ac0 --- /dev/null +++ b/drone/run @@ -0,0 +1,13 @@ +docker run \ + -it \ + --rm \ + -p 80:80 \ + -e DRONE_GITEA_CLIENT_ID=96cb2d20-cec7-40f2-95cc-c05cba99ef13 \ + -e DRONE_GITEA_CLIENT_SECRET=XyP0GfQeeh3le1aSJnT6m9Ui8OCVeODLAbCqz7Tlnx05 \ + -e DRONE_GITEA_SERVER=https://git.esin.io \ + -e DRONE_RPC_SECRET=bea26a2221fd8090ea38720fc445eca6 \ + -e DRONE_SERVER_PORT=:80 \ + -e DRONE_SERVER_HOST=localhost \ + -e DRONE_SERVER_PROTO=http \ + --name=drone \ + esinio/drone:v2.5.0