Now that we have a running Gogs installation for our source code (see here) - we can use Drone to build working software from those repos. Drone is an Continious Integration System, that comes in two flavors: Drone.io - which is the hosted service you could use - or Drone - as self-hosted service. We want to use the later one. To install drone in our existing Docker setup (with gogs already installed) we need to complete following steps:
# Create docker-compose.yml in ~/drone/
cd ~
mkdir drone
cd drone
vi docker-compose.yml
# Copy this content into your docker-compose.yml file
drone: restart: unless-stopped image: drone/drone:0.4.2 volumes: - /var/drone:/var/lib/drone - /var/run/docker.sock:/var/run/docker.sock env_file: - ./dronerc ports: - "8000:8000"
# Create the dronerc file
vi dronerc
# Copy this content into your dronerc file
# replace yourserverip with the ip or dns name of your server, i.e. example.com
# replace the gogsport with the port of the http port of the gogs installation, i.e. was 3000 in our example
REMOTE_DRIVER=gogs REMOTE_CONFIG=https://yourserverip:gogsport?open=false DEBUG=true
# Create the needed folders
sudo mkdir /var/drone
sudo chown -R yourusername:yourusername /var/drone/
After that, an docker-compose up will start the service, you can end it via STRG + C and really start it in deattached mode with docker-compose up -d
You can then go to http://yourserverip:8000 and log in into drone with your gogs login and allow access.
The current readme for drone can be found on http://readme.drone.io/usage/overview/ and you'll need to include a .drone.yml in your repos to really build something.
In my example, I used this .drone.yml
cache: mount: - /drone/.m2 build: main: image: maven:3-jdk-8-onbuild commands: - mvn clean install -Pcoverage -Dmaven.repo.local=/drone/.m2 - mvn package -Dmaven.repo.local=/drone/.m2 - mvn test -Dmaven.repo.local=/drone/.m2 - echo "Build has been completed." debug: true
and this pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.mycompany.app</groupId> <artifactId>WhereIsMyPi</artifactId> <version>1.0</version> <packaging>jar</packaging> <name>Where is my Pi</name> <url>http://www.nico-maas.de</url> <build> <sourceDirectory>src</sourceDirectory> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.5</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> <plugin> <!-- Build an executable JAR --> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.4</version> <configuration> <archive> <manifest> <addClasspath>true</addClasspath> <classpathPrefix>lib/</classpathPrefix> <mainClass>WMP</mainClass> </manifest> </archive> </configuration> </plugin> </plugins> </build> </project>
to build my "WhereIsMyPi" project :).
Happy building!