2015-07-07 04:13:50 +00:00
# Installation
2015-05-24 01:52:04 +00:00
2015-07-10 08:33:31 +00:00
To quickly tryout Drone we have a [Docker image ](https://registry.hub.docker.com/u/drone/drone/ ) that includes everything you need to get started. Simply run the commend below:
2015-05-24 01:52:04 +00:00
2015-07-10 08:33:31 +00:00
```
2015-07-07 04:13:50 +00:00
sudo docker run \
--volume /var/lib/drone:/var/lib/drone \
--volume /var/run/docker.sock:/var/run/docker.sock \
2015-10-07 20:06:14 +00:00
--env-file /etc/drone/dronerc \
2015-07-07 04:13:50 +00:00
--restart=always \
--publish=80:8000 \
--detach=true \
--name=drone \
2015-07-10 08:33:31 +00:00
drone/drone
2015-05-24 01:52:04 +00:00
```
2015-07-10 08:33:31 +00:00
Drone is now running (in the background) on `http://localhost:80` . Note that before running you should create the `--env-file` and add your Drone configuration (GitHub, Bitbucket, GitLab credentials, etc).
2015-05-24 01:52:04 +00:00
2015-07-07 04:13:50 +00:00
## Docker options
2015-05-24 01:52:04 +00:00
2015-07-07 04:13:50 +00:00
Here are some of the Docker options, explained:
2015-05-24 01:52:04 +00:00
2015-07-07 04:13:50 +00:00
* `--restart=always` starts Drone automatically during system init process
* `--publish=80:8000` runs Drone on port `80`
* `--detach=true` starts Drone in the background
* `--volume /var/lib/drone:/var/lib/drone` mounted volume to persist sqlite database
* `--volume /var/run/docker.sock:/var/run/docker.sock` mounted volume to access Docker and spawn builds
2015-07-10 08:33:31 +00:00
* `--env-file /etc/defaults/drone` loads an external file with environment variables. Used to configure Drone.
2015-05-24 01:52:04 +00:00
2015-07-07 04:13:50 +00:00
## Drone settings
2015-05-24 01:52:04 +00:00
2015-07-10 08:33:31 +00:00
Drone uses environment variables for runtime settings and configuration, such as GitHub, GitLab, plugins and more. These settings can be provided to Docker using an `--env-file` as seen above.
2015-08-24 10:35:51 +00:00
Once you have your drone container created, then you can start/stop/restart it in below ways.
2015-07-10 08:33:31 +00:00
## Starting, Stopping, Logs
Commands to start, stop and restart Drone:
```
docker start drone
docker stop drone
docker restart drone
```
And to view the Drone logs:
```
docker logs drone
```
## Upstart
Drone can be configured to work with process managers, such as **Ubuntu** Upstart, to automatically start when the operating system initializes. Here is an example upstart script that can be placed in `/etc/init/drone.conf` :
```
description "Drone container"
2015-05-25 22:41:01 +00:00
2015-07-10 08:33:31 +00:00
start on filesystem and started docker
stop on runlevel [!2345]
respawn
2015-05-25 22:41:01 +00:00
2015-07-10 08:33:31 +00:00
script
2015-08-24 10:35:51 +00:00
/usr/bin/docker start -a drone
2015-07-10 08:33:31 +00:00
end script
```
Commands to start and stop Drone:
```
sudo start drone
sudo stop drone
```
## Systemd
Drone can be configured to work with Systemd to automatically start when the operating system initializes. Here is an example systemd file:
```
[Unit]
Description=Drone container
Requires=docker.service
After=docker.service
[Service]
Restart=always
ExecStart=/usr/bin/docker start -a drone
ExecStop=/usr/bin/docker stop -t 2 drone
[Install]
WantedBy=local.target
```