woodpecker/doc/setup/install.md

97 lines
2.6 KiB
Markdown
Raw Normal View History

2015-07-11 00:40:03 +00:00
> **NOTE** we are not yet producing an image for 0.4 so this section does not work as documented. An official image for the 0.4 release is coming soon
2015-07-07 04:13:50 +00:00
# Installation
2015-05-24 01:52:04 +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-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 \
--env-file /etc/defaults/drone \
2015-07-07 04:13:50 +00:00
--restart=always \
--publish=80:8000 \
--detach=true \
--name=drone \
drone/drone
2015-05-24 01:52:04 +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
* `--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
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.
## 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
start on filesystem and started docker
stop on runlevel [!2345]
respawn
2015-05-25 22:41:01 +00:00
pre-start script
/usr/bin/docker rm -f drone
end script
script
/usr/bin/docker run -a drone
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
```