From 63f5586d525b703222cb2dfb4bd85b443f44afdd Mon Sep 17 00:00:00 2001 From: Glenn Date: Thu, 18 Aug 2022 20:29:48 +0200 Subject: [PATCH] Initial import --- Dockerfile | 5 +++ README.md | 44 ++++++++++++++++++++++ docker-compose.yml | 88 +++++++++++++++++++++++++++++++++++++++++++ entrypoint-wrapper.sh | 8 ++++ 4 files changed, 145 insertions(+) create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 docker-compose.yml create mode 100755 entrypoint-wrapper.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..652e3ee --- /dev/null +++ b/Dockerfile @@ -0,0 +1,5 @@ +FROM drone/drone-runner-docker:1.8.2 + +COPY entrypoint-wrapper.sh /usr/bin/entrypoint-wrapper + +# ENTRYPOINT ["/usr/bin/entrypoint-wrapper"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..c90e276 --- /dev/null +++ b/README.md @@ -0,0 +1,44 @@ +# Drone Server + +## Setup on Dokku + +Create APP + + dokku apps:create cicd + +Setup Network & Domains + + dokku network:create cicd_net + dokku network:set cicd initial-network cicd_net + dokku config:set --no-restart cicd DOKKU_LETSENCRYPT_EMAIL=username@example.com + +Setup Database + + dokku postgres:create cicd + dokku postgres:link cicd cicd + +Setup Volumes + + dokku storage:mount cicd /home/data/cicd.drone:/data + +Setup Configuration + + dokku config:set cicd DRONE_DATABASE_DRIVER=postgres + dokku config:set cicd DRONE_GIT_ALWAYS_AUTH=false + dokku config:set cicd DRONE_GITEA_SERVER=https://gitea.example.com + dokku config:set cicd DRONE_SERVER_HOST=cicd.example.com + dokku config:set cicd DRONE_SERVER_PROTO=https + dokku config:set cicd DRONE_TLS_AUTOCERT=false + +Setup Secrets + + dokku config:set cicd DRONE_COOKIE_SECRET=$(openssl rand -hex 16) + dokku config:set cicd DRONE_RPC_SECRET=$(openssl rand -hex 16) + dokku config:set cicd DRONE_GITEA_CLIENT_ID=FIXME + dokku config:set cicd DRONE_GITEA_CLIENT_SECRET=FIXME + +Deploy + + git remote add dokku dokku@dinlas.apps.glenux.net:cicd + git push + diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..9d3019f --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,88 @@ +--- +version: '3.6' + +# References +# * https://www.alexhyett.com/drone-ci-raspberry-pi + +services: + # gitea: + # container_name: gitea + # image: gitea/gitea:${GITEA_VERSION:-1.10.6} + # restart: unless-stopped + # environment: + # # https://docs.gitea.io/en-us/install-with-docker/#environments-variables + # - APP_NAME="Gitea" + # - USER_UID=1000 + # - USER_GID=1000 + # - RUN_MODE=prod + # - DOMAIN=${IP_ADDRESS} + # - SSH_DOMAIN=${IP_ADDRESS} + # - HTTP_PORT=3000 + # - ROOT_URL=http://${IP_ADDRESS}:3000 + # - SSH_PORT=222 + # - SSH_LISTEN_PORT=22 + # - DB_TYPE=sqlite3 + # ports: + # - "3000:3000" + # - "222:22" + # networks: + # - cicd_net + # volumes: + # - ./gitea:/data + + drone: + container_name: drone + image: "drone/drone:${DRONE_VERSION:-2.12.1}" + restart: unless-stopped + depends_on: [] + environment: + # https://docs.drone.io/server/provider/gitea/ + - DRONE_DATABASE_DRIVER=sqlite3 + - DRONE_DATABASE_DATASOURCE=/data/database.sqlite + - DRONE_GIT_ALWAYS_AUTH="false" + - DRONE_RPC_SECRET="${DRONE_RPC_SECRET}" + - DRONE_SERVER_PROTO=http + - DRONE_SERVER_HOST="${IP_ADDRESS}:3001" + - DRONE_TLS_AUTOCERT="false" + - DRONE_USER_CREATE="${DRONE_USER_CREATE}" + # DRONE_GITEA_SERVER: "http://${IP_ADDRESS}:3000/" + # DRONE_GITEA_CLIENT_ID: "${DRONE_GITEA_CLIENT_ID}" + # DRONE_GITEA_CLIENT_SECRET: "${DRONE_GITEA_CLIENT_SECRET}" + ports: + - "3001:80" + - "9001:9000" + networks: + - cicd_net + volumes: + - /var/run/docker.sock:/var/run/docker.sock + - ./drone:/data + + drone-runner: + container_name: drone-runner + image: drone/drone-runner-docker:${DRONE_RUNNER_VERSION:-1.8.2} + restart: unless-stopped + depends_on: + - drone + environment: + # https://docs.drone.io/runner/docker/installation/linux/ + # https://docs.drone.io/server/metrics/ + DRONE_RPC_PROTO: http + DRONE_RPC_HOST: drone + DRONE_RPC_SECRET: "${DRONE_RPC_SECRET}" + # DRONE_RUNNER_NAME: "${HOSTNAME}-runner" + DRONE_RUNNER_CAPACITY: 2 + DRONE_RUNNER_NETWORKS: cicd_net + DRONE_DEBUG: "false" + DRONE_TRACE: "false" + ports: + - "3002:3000" + networks: + - cicd_net + volumes: + - /var/run/docker.sock:/var/run/docker.sock + +networks: + cicd_net: + name: cicd_net + +# diff --git a/entrypoint-wrapper.sh b/entrypoint-wrapper.sh new file mode 100755 index 0000000..f9d873e --- /dev/null +++ b/entrypoint-wrapper.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +echo "# Entrypoint Wrapper" +echo "- Setting DRONE_DATABASE_DATASOURCE from DATABASE_URL" +DRONE_DATABASE_DATASOURCE="${DATABASE_URL}" +export DRONE_DATABASE_DATASOURCE + +exec /bin/drone-server "$@"