mirror of
https://github.com/fbartels/cloudron-drone-app.git
synced 2024-09-29 14:11:53 +00:00
readme and tweaks
Signed-off-by: Felix Bartels <felix@host-consultants.de>
This commit is contained in:
parent
505d264466
commit
438909a049
3 changed files with 78 additions and 15 deletions
57
README.md
57
README.md
|
@ -1,4 +1,57 @@
|
||||||
|
# Drone CI for Cloudron
|
||||||
|
|
||||||
|
Run the Drone server on Cloudron and the agents locally.
|
||||||
|
|
||||||
|
I am using this setup together with a Gitea running on the same Cloudron installation.
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
- `docker-compose`
|
||||||
|
- `git`
|
||||||
|
- `make`
|
||||||
|
- Cloudron CLI
|
||||||
|
|
||||||
|
## Tips and Tricks
|
||||||
|
|
||||||
|
I would also like to share some very useful commands. To install `drone` CLI, follow [official docs](https://docs.drone.io/cli/install/).
|
||||||
|
|
||||||
|
### Using drone-cli
|
||||||
|
|
||||||
|
Go to your [user settings](https://drone.9wd.eu/account) and get login information
|
||||||
|
|
||||||
|
```bash
|
||||||
|
export DRONE_SERVER=https://drone.9wd.eu
|
||||||
|
export DRONE_TOKEN=your token
|
||||||
|
drone info
|
||||||
|
```
|
||||||
|
|
||||||
|
### Executing pipelines directly
|
||||||
|
|
||||||
|
You can also run pipelines directly with the Drone CLI:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
drone exec --secret-file drone_secrets.yaml .drone.yml
|
||||||
|
```
|
||||||
|
|
||||||
|
A template for `drone-secrets.yaml`:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
slack_url: https://hooks.slack.com/services/xxxxxxxxxxxx
|
||||||
|
```
|
||||||
|
|
||||||
|
### Adding secrets through CLI
|
||||||
|
|
||||||
|
You can either add secrets through the web UI or use drone directly from your terminal:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
drone secret add -repository username/repository-name --name foo --data bar --allow-pull-request
|
||||||
|
```
|
||||||
|
|
||||||
|
## Inspiration
|
||||||
|
|
||||||
|
- [Setting up simple, self-hosted & fast CI/CD solution with Drone.io](https://webhookrelay.com/blog/2019/02/11/using-drone-for-simple-selfhosted-ci-cd/)
|
||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
|
|
||||||
- remove commited secrets
|
- [*] remove commited secrets
|
||||||
- retrieve rpc secret from cloudron
|
- [*] retrieve rpc secret from cloudron
|
||||||
|
|
|
@ -9,7 +9,7 @@ services:
|
||||||
volumes:
|
volumes:
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
environment:
|
environment:
|
||||||
- DRONE_RPC_SERVER=https://drone.9wd.eu
|
- DRONE_RPC_SERVER=${DRONE_RPC_SERVER}
|
||||||
- DRONE_RPC_SECRET=QdExkSpgVY5RiC783UcqFgt8mvEs0Mid
|
- DRONE_RPC_SECRET=${DRONE_RPC_SECRET}
|
||||||
- DRONE_RUNNER_CAPACITY=2
|
- DRONE_RUNNER_CAPACITY=${DRONE_RUNNER_CAPACITY}
|
||||||
- DRONE_RUNNER_NAME="clifford"
|
- DRONE_RUNNER_NAME=${DRONE_RUNNER_NAME}
|
28
run-agent.sh
28
run-agent.sh
|
@ -1,4 +1,4 @@
|
||||||
#/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
|
@ -6,12 +6,22 @@ random_string() {
|
||||||
LC_CTYPE=C tr -dc 'a-zA-Z0-9' < /dev/urandom | head -c32
|
LC_CTYPE=C tr -dc 'a-zA-Z0-9' < /dev/urandom | head -c32
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ ! -e .env ]; then
|
update_env_file () {
|
||||||
cat <<-EOF > ".env"
|
varname="$1"
|
||||||
DRONE_RPC_SERVER=https://drone.9wd.eu
|
varvalue="$2"
|
||||||
DRONE_RPC_SECRET=QdExkSpgVY5RiC783UcqFgt8mvEs0Mid
|
if ! grep -q "$varname" ./.env; then
|
||||||
DRONE_RUNNER_CAPACITY="$(nproc)"
|
echo "$varname=$varvalue" >> ./.env
|
||||||
DRONE_RUNNER_NAME="$(hostname)"
|
else
|
||||||
EOF
|
sed -i "/$varname/c $varname=$varvalue" ./.env
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
cloudron pull /app/data/.env .env
|
||||||
|
|
||||||
|
. ./.env
|
||||||
|
|
||||||
|
update_env_file DRONE_RPC_SERVER "https://$DRONE_SERVER_HOST"
|
||||||
|
update_env_file DRONE_RUNNER_CAPACITY "$(nproc)"
|
||||||
|
update_env_file DRONE_RUNNER_NAME "$(hostname)"
|
||||||
|
|
||||||
docker-compose up -d
|
docker-compose up -d
|
Loading…
Reference in a new issue