Update configs and scripts for Ngrok and Drone CI setup

- Added ".example-env" with necessary configuration placeholders.

 - Updated README.md with detailed setup instructions for Ngrok and Drone CI, including running in different modes.

 - Renamed the container from "ngrok_container" to "ngrok".

 - Added "start_with_domain.sh" for users opting to use a predefined Ngrok domain.

 - Modified "start.sh" to support starting Ngrok without a domain.

 - Updated "stop.sh" to align with the new container name.
This commit is contained in:
Chou Tzu Chieh 2024-03-26 17:30:36 +08:00
parent e9a9704c56
commit 9f28e652b3
6 changed files with 37 additions and 9 deletions

6
.example-env Normal file
View File

@ -0,0 +1,6 @@
NGROK_AUTH_TOKEN=YOUR_NGROK_AUTH_TOKEN
NGROK_DOMAIN=YOUR_NGROK_DOMAIN
DRONE_GITHUB_CLIENT_ID=YOUR_GITHUB_CLIENT_ID
DRONE_GITHUB_CLIENT_SECRET=YOUR_GITHUB_CLIENT_SECRET
DRONE_RPC_SECRET=YOUR_DRONE_RPC_SECRE
DRONE_SERVER_HOST=YOUR_DRONE_SERVER_HOST

View File

@ -7,9 +7,13 @@ Setting up [Drone CI for Github provider](https://docs.drone.io/server/provider/
### Expose local 8080 port using Ngrok
```
$ export NGROK_AUTH_TOKEN=YOUR_NGROK_AUTH_TOKEN
$ export NGROK_DOMAIN=YOUR_NGROK_DOMAIN
# run with domain
$ export NGROK_DOMAIN=YOUR_NGROK_DOMAIN
$ docker run --name ngrok_container --net=host -it -e NGROK_AUTHTOKEN=${NGROK_AUTH_TOKEN} ngrok/ngrok:latest http --domain=${NGROK_DOMAIN} 8080
# run with randomly generated domain by Ngrok
$ docker run --name ngrok_container --net=host -it -e NGROK_AUTHTOKEN=${NGROK_AUTH_TOKEN} ngrok/ngrok:latest http 8080
```
### Start Drone with Docker Compose
@ -19,20 +23,24 @@ $ export DRONE_GITHUB_CLIENT_SECRET=YOUR_GITHUB_CLIENT_SECRET >> .env
$ export DRONE_RPC_SECRET=YOUR_DRONE_RPC_SECRET >> .env
$ export DRONE_SERVER_HOST=YOUR_DRONE_SERVER_HOST >> .env
$ docker compose up
$ docker compose up -d
```
## Quick Start
If `.env` file is already set up (Simply edit the `.example-env` file and then rename it to `.env`)
### Running Drone CI in the Background
if `.env` file is already set up
If you have set up `NGROK_DOMAIN` in `.env` file:
```bash
$ chmod +x start_with_domain.sh
$ ./start_with_domain.sh
```
Start Ngrok without `NGROK_DOMAIN`:
```bash
$ chmod +x start.sh
$ ./start.sh
```
## Stop Drone CI and Ngrok
### Stop Drone CI and Ngrok
```bash
$ chmod +x stop.sh
$ ./stop.sh

View File

@ -2,6 +2,7 @@ version: '3'
services:
drone-server:
image: drone/drone:2
container_name: drone-server
restart: always
volumes:
- /var/lib/drone:/data
@ -17,6 +18,7 @@ services:
drone-runner:
image: drone/drone-runner-docker:1
container_name: drone-runner
restart: always
depends_on:
- drone-server

View File

@ -6,7 +6,7 @@ source .env
set +a
# Expose local 8080 port using Ngrok
docker run --name ngrok_container --net=host -e NGROK_AUTHTOKEN=${NGROK_AUTH_TOKEN} ngrok/ngrok:latest http --domain=${NGROK_DOMAIN} 8080 &
docker run --name ngrok --net=host -e NGROK_AUTHTOKEN=${NGROK_AUTH_TOKEN} ngrok/ngrok:latest http &
# Start Drone server and agent using Docker Compose
docker compose up -d

12
start_with_domain.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/bash
# Source environment variables from .env file
set -a
source .env
set +a
# Expose local 8080 port using Ngrok
sudo docker run --name ngrok --net=host -e NGROK_AUTHTOKEN=${NGROK_AUTH_TOKEN} ngrok/ngrok:latest http --domain=${NGROK_DOMAIN} 8080 &
# Start Drone server and agent using Docker Compose
sudo docker compose up -d

View File

@ -2,5 +2,5 @@
# Stop and remove the Docker containers
docker compose down
docker stop ngrok_container
docker rm ngrok_container
docker stop ngrok
docker rm ngrok