Created
December 28, 2021 19:17
-
-
Save ilude/44fa4035d641fc14c72699a7e9df343e to your computer and use it in GitHub Desktop.
Drone and Gitea
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
based on https://dev.to/ruanbekker/self-hosted-cicd-with-gitea-and-drone-ci-200l |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.6' | |
services: | |
drone-cli: | |
container_name: drone-cli | |
image: drone/cli:1.2.4-alpine | |
restart: unless-stopped | |
environment: | |
- DRONE_TOKEN=${DRONE_TOKEN} | |
- DRONE_SERVER=http://${FQDN}:4001 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.6' | |
services: | |
gitea: | |
container_name: gitea | |
image: gitea/gitea:${GITEA_VERSION:-1.12.4} | |
restart: unless-stopped | |
environment: | |
# https://docs.gitea.io/en-us/install-with-docker/#environments-variables | |
- APP_NAME="Gitea" | |
- USER_UID=${UUID} | |
- USER_GID=${GUID} | |
- RUN_MODE=prod | |
- DOMAIN=${FQDN} | |
- SSH_DOMAIN=${FQDN} | |
- HTTP_PORT=4000 | |
- ROOT_URL=http://${FQDN}:4000 | |
- SSH_PORT=222 | |
- SSH_LISTEN_PORT=22 | |
- DB_TYPE=sqlite3 | |
ports: | |
- "4000:4000" | |
- "222:22" | |
volumes: | |
- ./data/gitea:/data | |
drone: | |
container_name: drone | |
image: drone/drone:${DRONE_VERSION:-2.0.0} | |
restart: unless-stopped | |
depends_on: | |
- gitea | |
environment: | |
# https://docs.drone.io/server/provider/gitea/ | |
- DRONE_DATABASE_DRIVER=sqlite3 | |
- DRONE_DATABASE_DATASOURCE=/data/database.sqlite | |
- DRONE_GITEA_SERVER=http://${FQDN}:4000/ | |
- DRONE_GIT_ALWAYS_AUTH=false | |
- DRONE_RPC_SECRET=${DRONE_RPC_SECRET} | |
- DRONE_SERVER_PROTO=http | |
- DRONE_SERVER_HOST=${FQDN}:4001 | |
- DRONE_TLS_AUTOCERT=false | |
- DRONE_USER_CREATE=${DRONE_USER_CREATE} | |
- DRONE_GITEA_CLIENT_ID=${DRONE_GITEA_CLIENT_ID} | |
- DRONE_GITEA_CLIENT_SECRET=${DRONE_GITEA_CLIENT_SECRET} | |
ports: | |
- "4001:80" | |
- "4002:9000" | |
volumes: | |
- /var/run/docker.sock:/var/run/docker.sock | |
- ./data/drone:/data | |
drone-runner: | |
container_name: drone-runner | |
image: drone/drone-runner-docker:${DRONE_RUNNER_VERSION:-1} | |
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=${PROJECT_NAME}_default | |
- DRONE_DEBUG=false | |
- DRONE_TRACE=false | |
ports: | |
- "4003:3000" | |
volumes: | |
- /var/run/docker.sock:/var/run/docker.sock |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# get current timestamp | |
export DATE := $(shell date "+%Y-%m-%d-%H.%M.%S") | |
export FQDN := $(shell hostname --fqdn) | |
export HOSTNAME := $(shell hostname) | |
export PROJECT_NAME := $(notdir $(CURDIR)) | |
export GITEA_VERSION := 1.14.2 | |
export GITEA_ADMIN_USER := admin | |
export DRONE_VERSION := 1 | |
export DRONE_RUNNER_VERSION := 1 | |
export DRONE_RPC_SECRET := $(shell echo ${HOSTNAME} | openssl dgst -sha256 -hex | sed 's/^.*= //') | |
export DRONE_USER_CREATE := username:${GITEA_ADMIN_USER},machine:false,admin:true,token:${DRONE_RPC_SECRET} | |
export DRONE_GITEA_CLIENT_ID := MUST_BE_SET | |
export DRONE_GITEA_CLIENT_SECRET := MUST_BE_SET | |
export UUID := $(shell id -u ${USER}) | |
export GUID := $(shell id -g ${USER}) | |
ifneq (,$(wildcard ./.env)) | |
include .env | |
export | |
endif | |
up: | |
docker-compose up --force-recreate --abort-on-container-exit --remove-orphans | |
@echo "Gitea: http://${FQDN}:4000/" | |
@echo "Drone: http://${FQDN}:4001/" | |
echo: | |
@echo ========================================= | |
@echo = PROJECT_NAME: $(PROJECT_NAME) | |
@echo = DATE: $(DATE) | |
@echo = FQDN: $(FQDN) | |
@echo = HOSTNAME: $(HOSTNAME) | |
@echo = DRONE_RPC_SECRET: $(DRONE_RPC_SECRET) | |
@echo = DRONE_USER_CREATE: $(DRONE_USER_CREATE) | |
@echo ========================================= | |
start: | |
docker-compose up -d --force-recreate --abort-on-container-exit --remove-orphans | |
@echo "Gitea: http://${FQDN}:4000/" | |
@echo "Drone: http://${FQDN}:4001/" | |
down: | |
docker-compose down | |
restart: down start | |
logs: | |
docker-compose logs -f | |
attach: | |
docker-compose exec ${CONTAINER_NAME} bash | |
bash: | |
docker-compose run --rm ${CONTAINER_NAME} bash | |
pull: | |
docker-compose pull | |
clean: | |
docker-compose down --volumes --remove-orphans --rmi local | |
docker-compose rm -f |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment