Master Lightweight CI/CD with Drone and Gogs: Step-by-Step Docker Deployment
Learn how to set up a lightweight, container‑based CI/CD pipeline using Drone and Gogs, install both tools via Docker, configure servers and runners, write .drone.yml scripts, and automate building and deploying a SpringBoot e‑commerce project, all with minimal memory usage.
Drone Overview
Drone is a container‑based continuous integration tool that uses simple YAML configuration files to define complex build, test, and deployment tasks. It is lightweight, consumes less than 1 GB of memory, and has gained over 22K stars on GitHub.
Gogs Installation
Gogs provides a lightweight Git service. Install it via Docker:
<code>docker pull gogs/gogs</code> <code>docker run -p 10022:22 -p 10080:3000 --name=gogs \
-e TZ="Asia/Shanghai" \
-v /mydata/gogs:/data \
-d gogs/gogs</code>After the container starts, access
http://192.168.5.78:10080to create a repository and push the
mall-tiny-dronesource code.
Drone Installation
Download the Drone server and runner images:
<code># Drone server
docker pull drone/drone:1
# Drone runner
docker pull drone-runner-docker:1</code>Run the Drone server container with required environment variables:
<code>docker run \
-v /mydata/drone:/data \
-e DRONE_AGENTS_ENABLED=true \
-e DRONE_GOGS_SERVER=http://192.168.5.78:10080 \
-e DRONE_RPC_SECRET=dronerpc666 \
-e DRONE_SERVER_HOST=192.168.5.78:3080 \
-e DRONE_SERVER_PROTO=http \
-e DRONE_USER_CREATE=username:macro,admin:true \
-e TZ="Asia/Shanghai" \
-p 3080:80 \
--restart=always \
--detach=true \
--name=drone \
drone/drone:1</code>Run the Drone runner container:
<code>docker run -d \
-v /var/run/docker.sock:/var/run/docker.sock \
-e DRONE_RPC_PROTO=http \
-e DRONE_RPC_HOST=192.168.5.78:3080 \
-e DRONE_RPC_SECRET=dronerpc666 \
-e DRONE_RUNNER_CAPACITY=2 \
-e DRONE_RUNNER_NAME=runner-docker \
-e TZ="Asia/Shanghai" \
-p 3000:3000 \
--restart always \
--name runner-docker \
drone/drone-runner-docker:1</code>Key server and runner parameters are explained in the article (e.g.,
DRONE_GOGS_SERVER,
DRONE_RPC_SECRET,
DRONE_SERVER_HOST, etc.).
Using Drone
Access the Drone UI at
http://192.168.5.78:3080/and log in with the Gogs account. Sync the repository, set it to
Trusted, and save. A webhook is automatically created in Gogs; pushing code triggers the pipeline.
If a pipeline fails because a secret (e.g.,
ssh_password) is missing, add the secret in the Gogs repository settings and retry.
Writing the Pipeline Script
The pipeline is defined in
.drone.yml. Below is a complete example with comments:
<code>kind: pipeline # object type (pipeline, secret, signature)
type: docker # pipeline executor (docker, kubernetes, exec, ssh, ...)
name: mall-tiny-drone # pipeline name
steps:
- name: package
image: maven:3-jdk-8
volumes:
- name: maven-cache
path: /root/.m2
- name: maven-build
path: /app/build
commands:
- mvn clean package
- cp target/mall-tiny-drone-1.0-SNAPSHOT.jar /app/build/mall-tiny-drone-1.0-SNAPSHOT.jar
- cp Dockerfile /app/build/Dockerfile
- cp run.sh /app/build/run.sh
- name: build-start
image: appleboy/drone-ssh
settings:
host: 192.168.5.78
username: root
password:
from_secret: ssh_password
port: 22
command_timeout: 5m
script:
- cd /mydata/maven/build
- chmod +x run.sh
- ./run.sh
volumes:
- name: maven-build
host:
path: /mydata/maven/build
- name: maven-cache
host:
path: /mydata/maven/cache</code>The
run.shscript builds the Docker image for the SpringBoot application and runs it; its details are linked in the original tutorial.
Conclusion
Compared with Jenkins’ heavy graphical interface, Drone’s script‑based pipelines are simpler and more transparent. Drone is lightweight, consumes little memory, and provides fast response, making it an attractive alternative for automated deployment.
Reference
Official documentation: https://docs.drone.io/
macrozheng
Dedicated to Java tech sharing and dissecting top open-source projects. Topics include Spring Boot, Spring Cloud, Docker, Kubernetes and more. Author’s GitHub project “mall” has 50K+ stars.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.