Basic Drone install with Docker

Hello,

Following https://github.com/drone/docs/issues/263
I want to do a very basic install of Drone to integrate with Gitea.
I’m using Docker with RancherOS and have installed docker-compose.

Here is my docker-compose.yml

$ cat docker-compose.yml
version: '2'

services:
  drone-server:
    image: drone/drone:0.7
    environment:
      - DRONE_OPEN=true
      - DRONE_HOST=${DRONE_HOST}
      - DRONE_GITEA=true
      - DRONE_GITEA_URL=http://192.168.1.5:3000
      - DRONE_SECRET=${DRONE_SECRET}

  drone-agent:
    image: drone/drone:0.7
    command: agent
    restart: always
    depends_on:
      - drone-server
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      - DRONE_SERVER=ws://drone-server:8000/ws/broker
      - DRONE_SECRET=${DRONE_SECRET}

and my env variable was set using:

export DRONE_HOST=192.168.1.5
export DRONE_SECRET=.....

I build containers using:

$ docker-compose up -d

but I haven’t been able to connect to Drone using web interface

$ docker-compose ps
         Name               Command      State              Ports
---------------------------------------------------------------------------
droneci_drone-agent_1    /drone agent    Up       443/tcp, 80/tcp, 8000/tcp
droneci_drone-server_1   /drone server   Exit 1

I did a

$ docker-compose down

and changed docker-compose.yml for

version: '2'

services:
  drone-server:
    image: drone/drone:0.7
    environment:
      - DRONE_OPEN=true
      - DRONE_HOST=${DRONE_HOST}
      - DRONE_GITEA=true
      - DRONE_GITEA_URL=http://192.168.1.5:3000
      - DRONE_SECRET=${DRONE_SECRET}

  drone-agent:
    image: drone/drone:0.7
    command: agent
    restart: always
    depends_on:
      - drone-server
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
-      - DRONE_SERVER=ws://drone-server:8000/ws/broker
+      - DRONE_SERVER=ws://192.168.1.5:8000/ws/broker
      - DRONE_SECRET=${DRONE_SECRET}

After

$ docker-compose up -d

I get

$ docker-compose ps
         Name               Command      State             Ports
--------------------------------------------------------------------------
droneci_drone-agent_1    /drone agent    Up      443/tcp, 80/tcp, 8000/tcp
droneci_drone-server_1   /drone server   Up      443/tcp, 80/tcp, 8000/tcp

but I still don’t see web interface and after some seconds

$ docker-compose ps
         Name               Command      State              Ports
---------------------------------------------------------------------------
droneci_drone-agent_1    /drone agent    Up       443/tcp, 80/tcp, 8000/tcp
droneci_drone-server_1   /drone server   Exit 1

Any help will be very kind.

I will submit a PR to help to improve doc for other people (Docker beginner like me) facing similar problem.

Kind regards

Your server configuration is missing the following paramters:

services:
  drone-server:
    image: drone/drone:0.7
+   ports:
+     - 80:8000
+   volumes:
+     - /var/lib/drone:/var/lib/drone/

Note that it looks like you have attempted to update a number of parameters (such as the drone server address) which should not be updated. Please only change the fields highlighted below in green.

version: '2'

services:
  drone-server:
    image: drone/drone:0.7
    ports:
      - 80:8000
    volumes:
      - /var/lib/drone:/var/lib/drone/
    restart: always
    environment:
      - DRONE_OPEN=true
      - DRONE_GOGS=true
+     - DRONE_GOGS_URL=http://gogs.mycompany.com
+     - DRONE_SECRET=<some shared secret>

  drone-agent:
    image: drone/drone:0.7
    command: agent
    restart: always
    depends_on: [ drone-server ]
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      - DRONE_SERVER=ws://drone-server:8000/ws/broker
+     - DRONE_SECRET=<some shared secret>
  • DRONE_GOGS_URL

should probably be replaced by

  • DRONE_GITEA_URL

Thanks @bradrydzewski
Web interface is now available.

I can connect with my Gitea user.
That’s nice.

I will try with a sample Python project.
Maybe you have one as a sample with unittest, nosetest or pytest?

Here is my .drone.yml for Python

pipeline:
  build:
    image: python:${PYTHON_VERSION}
    commands:
      - pip install -r dev-requirements.txt
      - python setup.py install
      - pytest -s -r xX
      - flake8 --version
      - flake8 --ignore E501 setup.py sample tests    
    
matrix:
  PYTHON_VERSION:
    - 2.7
    - 3.6

maybe doc should provide an example for Python also?

(inspired by http://docs.drone.io/golang-example/ )

I did a complete reinstall of gitea and Drone

I just changed my username (to have same user with Gitea and Github)

I’m testing CI with this sample project

it’s available using http://192.168.1.5:3000/scls19fr/sample_python inside my network with Gitea

When I’m pushing code to Git CI is automatically run

+ git init
0s
2
Initialized empty Git repository in /drone/src/192.168.1.5:3000/scls19fr/sample_python/compare/191bc31812c27be64e1d6e93073833204c20d25e...4ca3728ba4dd97c9bf07b1993667ef849473831d/.git/
0s
3
+ git remote add origin http://192.168.1.5:3000/scls19fr/sample_python.git
0s
4
+ git fetch --no-tags origin +refs/heads/master:
0s
5
From http://192.168.1.5:3000/scls19fr/sample_python
0s
6
 * branch            master     -> FETCH_HEAD
0s
7
 * [new branch]      master     -> origin/master
0s
8
+ git reset --hard -q 4ca3728ba4dd97c9bf07b1993667ef849473831d
0s
9
+ git submodule update --init --recursive

but build is now failing

+ pip install -r dev-requirements.txt
0s
2
Collecting flake8 (from -r dev-requirements.txt (line 1))
0s
3
  Downloading flake8-3.4.1-py2.py3-none-any.whl (68kB)
0s
4
Collecting pytest (from -r dev-requirements.txt (line 2))
0s
5
  Downloading pytest-3.2.3-py2.py3-none-any.whl (187kB)
0s
6
Collecting coveralls (from -r dev-requirements.txt (line 3))
0s
7
  Downloading coveralls-1.2.0-py2.py3-none-any.whl
0s
8
Collecting enum34; python_version < "3.4" (from flake8->-r dev-requirements.txt (line 1))
0s
9
  Downloading enum34-1.1.6-py2-none-any.whl
1s
10
Collecting configparser; python_version < "3.2" (from flake8->-r dev-requirements.txt (line 1))
1s
11
  Downloading configparser-3.5.0.tar.gz
1s
12
Collecting pyflakes<1.6.0,>=1.5.0 (from flake8->-r dev-requirements.txt (line 1))
1s
13
  Downloading pyflakes-1.5.0-py2.py3-none-any.whl (225kB)
1s
14
Collecting mccabe<0.7.0,>=0.6.0 (from flake8->-r dev-requirements.txt (line 1))
1s
15
  Downloading mccabe-0.6.1-py2.py3-none-any.whl
1s
16
Collecting pycodestyle<2.4.0,>=2.0.0 (from flake8->-r dev-requirements.txt (line 1))
2s
17
  Downloading pycodestyle-2.3.1-py2.py3-none-any.whl (45kB)
2s
18
Collecting py>=1.4.33 (from pytest->-r dev-requirements.txt (line 2))
2s
19
  Downloading py-1.4.34-py2.py3-none-any.whl (84kB)
2s
20
Requirement already satisfied: setuptools in /usr/local/lib/python2.7/site-packages (from pytest->-r dev-requirements.txt (line 2))
2s
21
Collecting requests>=1.0.0 (from coveralls->-r dev-requirements.txt (line 3))
2s
22
  Downloading requests-2.18.4-py2.py3-none-any.whl (88kB)
2s
23
Collecting coverage>=3.6 (from coveralls->-r dev-requirements.txt (line 3))
2s
24
  Downloading coverage-4.4.1-cp27-cp27mu-manylinux1_x86_64.whl (193kB)
3s
25
Collecting urllib3[secure]; python_version < "3" (from coveralls->-r dev-requirements.txt (line 3))
3s
26
  Downloading urllib3-1.22-py2.py3-none-any.whl (132kB)
3s
27
Collecting docopt>=0.6.1 (from coveralls->-r dev-requirements.txt (line 3))
3s
28
  Downloading docopt-0.6.2.tar.gz
3s
29
Collecting idna<2.7,>=2.5 (from requests>=1.0.0->coveralls->-r dev-requirements.txt (line 3))
3s
30
  Downloading idna-2.6-py2.py3-none-any.whl (56kB)
3s
31
Collecting certifi>=2017.4.17 (from requests>=1.0.0->coveralls->-r dev-requirements.txt (line 3))
3s
32
  Downloading certifi-2017.7.27.1-py2.py3-none-any.whl (349kB)
3s
33
Collecting chardet<3.1.0,>=3.0.2 (from requests>=1.0.0->coveralls->-r dev-requirements.txt (line 3))
4s
34
  Downloading chardet-3.0.4-py2.py3-none-any.whl (133kB)
4s
35
Collecting pyOpenSSL>=0.14; python_version <= "2.7" and extra == "secure" (from urllib3[secure]; python_version < "3"->coveralls->-r dev-requirements.txt (line 3))
4s
36
  Downloading pyOpenSSL-17.3.0-py2.py3-none-any.whl (51kB)
4s
37
Collecting cryptography>=1.3.4; python_version <= "2.7" and extra == "secure" (from urllib3[secure]; python_version < "3"->coveralls->-r dev-requirements.txt (line 3))
4s
38
  Downloading cryptography-2.0.3-cp27-cp27mu-manylinux1_x86_64.whl (2.2MB)
4s
39
Collecting ipaddress; python_version <= "2.7" and extra == "secure" (from urllib3[secure]; python_version < "3"->coveralls->-r dev-requirements.txt (line 3))
5s
40
  Downloading ipaddress-1.0.18-py2-none-any.whl
5s
41
Collecting six>=1.5.2 (from pyOpenSSL>=0.14; python_version <= "2.7" and extra == "secure"->urllib3[secure]; python_version < "3"->coveralls->-r dev-requirements.txt (line 3))
5s
42
  Downloading six-1.11.0-py2.py3-none-any.whl
6s
43
Collecting cffi>=1.7 (from cryptography>=1.3.4; python_version <= "2.7" and extra == "secure"->urllib3[secure]; python_version < "3"->coveralls->-r dev-requirements.txt (line 3))
6s
44
  Downloading cffi-1.11.1-cp27-cp27mu-manylinux1_x86_64.whl (405kB)
6s
45
Collecting asn1crypto>=0.21.0 (from cryptography>=1.3.4; python_version <= "2.7" and extra == "secure"->urllib3[secure]; python_version < "3"->coveralls->-r dev-requirements.txt (line 3))
6s
46
  Downloading asn1crypto-0.23.0-py2.py3-none-any.whl (99kB)
6s
47
Collecting pycparser (from cffi>=1.7->cryptography>=1.3.4; python_version <= "2.7" and extra == "secure"->urllib3[secure]; python_version < "3"->coveralls->-r dev-requirements.txt (line 3))
6s
48
  Downloading pycparser-2.18.tar.gz (245kB)
6s
49
Building wheels for collected packages: configparser, docopt, pycparser
7s
50
  Running setup.py bdist_wheel for configparser: started
7s
51
  Running setup.py bdist_wheel for configparser: finished with status 'done'
7s
52
  Stored in directory: /root/.cache/pip/wheels/1c/bd/b4/277af3f6c40645661b4cd1c21df26aca0f2e1e9714a1d4cda8
7s
53
  Running setup.py bdist_wheel for docopt: started
7s
54
  Running setup.py bdist_wheel for docopt: finished with status 'done'
7s
55
  Stored in directory: /root/.cache/pip/wheels/b2/16/5f/c33a2bb5f2dce71205f8e65cbfd05647d79d441282be31fd82
7s
56
  Running setup.py bdist_wheel for pycparser: started
7s
57
  Running setup.py bdist_wheel for pycparser: finished with status 'done'
8s
58
  Stored in directory: /root/.cache/pip/wheels/95/14/9a/5e7b9024459d2a6600aaa64e0ba485325aff7a9ac7489db1b6
8s
59
Successfully built configparser docopt pycparser
8s
60
Installing collected packages: enum34, configparser, pyflakes, mccabe, pycodestyle, flake8, py, pytest, idna, pycparser, cffi, ipaddress, asn1crypto, six, cryptography, pyOpenSSL, certifi, urllib3, chardet, requests, coverage, docopt, coveralls
8s
61
Successfully installed asn1crypto-0.23.0 certifi-2017.7.27.1 cffi-1.11.1 chardet-3.0.4 configparser-3.5.0 coverage-4.4.1 coveralls-1.2.0 cryptography-2.0.3 docopt-0.6.2 enum34-1.1.6 flake8-3.4.1 idna-2.6 ipaddress-1.0.18 mccabe-0.6.1 py-1.4.34 pyOpenSSL-17.3.0 pycodestyle-2.3.1 pycparser-2.18 pyflakes-1.5.0 pytest-3.2.3 requests-2.18.4 six-1.11.0 urllib3-1.22
10s
62
+ pytest -s -r xX
10s
63
============================= test session starts ==============================
11s
64
platform linux2 -- Python 2.7.14, pytest-3.2.3, py-1.4.34, pluggy-0.4.0
11s
65
rootdir: /drone/src/192.168.1.5:3000/scls19fr/sample_python/compare/191bc31812c27be64e1d6e93073833204c20d25e...4ca3728ba4dd97c9bf07b1993667ef849473831d, inifile:
11s
66
collected 0 items / 1 errors
11s
67

11s
68
==================================== ERRORS ====================================
11s
69
____________________ ERROR collecting tests/test_sample.py _____________________
11s
70
ImportError while importing test module '/drone/src/192.168.1.5:3000/scls19fr/sample_python/compare/191bc31812c27be64e1d6e93073833204c20d25e...4ca3728ba4dd97c9bf07b1993667ef849473831d/tests/test_sample.py'.
11s
71
Hint: make sure your test modules/packages have valid Python names.
11s
72
Traceback:
11s
73
tests/test_sample.py:1: in <module>
11s
74
    from mysample import add
11s
75
E   ImportError: No module named mysample
11s
76
!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!!
11s
77
=========================== 1 error in 0.17 seconds ============================
11s
exit code 2

despite running pytest locally works fine.

I breaked something but I don’t understand what.

Any idea?

I can see you still have the port in the workspace folder. This needs to be changed as recommended in the other Julia post.

This is odd because with my previous install I didn’t need to change workspace with python testing.
But my Julia setup was broken.

This is because the problem is with the package loader (Julia vs Python). Some package loaders work just fine with colons in the folder path, while other do not.

So I wonder if I should install gitea on port 80 (instead of 3000)… it could be a workaround, isn’t it ?

The permanent fix is to install drone 0.8, which automatically removes the port from the path. You can see upgrade instructions here: http://docs.drone.io/release-0.8.0

Ok.

Here is now my docker-compose

version: '2'

services:
  drone-server:
    image: drone/drone:0.8
    ports:
      - 80:8000
    volumes:
      - /var/lib/drone:/var/lib/drone/
    restart: always
    environment:
      - DRONE_OPEN=true
      - DRONE_HOST=${DRONE_HOST}
      - DRONE_GITEA=true
      - DRONE_GITEA_URL=http://192.168.1.5:3000
      - DRONE_SECRET=${DRONE_SECRET}

  drone-agent:
    image: drone/drone:0.7
    command: agent
    restart: always
    depends_on:
      - drone-server
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      - DRONE_SERVER=ws://drone-server:8000/ws/broker
      - DRONE_SECRET=${DRONE_SECRET}

I did a

$ docker-compose down

and

$ docker-compose up -d

Now that’s a bit different…

but not better :disappointed_relieved:

Oups! I noticed what is wrong… drone-agent version.

but job is still pending

That’s fixed now!

A blank __init__.py was simply missing in tests directory (it was present locally but not add, commit and push to remote git repository). So that was more a Python and Git issue than a Drone issue.