Search code examples
sqlitedocker-composedrone.io

DroneCI server 0.8 unable to open database file


I'm struggling to get DroneCI up and running, using the below (sanitized) docker-compose.yaml.

(See link at bottom for output from docker-compose up executions).

# Docker compose file syntax:
version: '2'

services:
  drone-server:
    image: drone/drone:0.8

    ports:
      - 5124:8000
      - 5125:9000
    volumes:
      - '/var/lib/drone:/var/lib/drone/:Z'
    restart: always
    environment:
      - DRONE_OPEN=true
      - DRONE_HOST=http://drone.COMPANY.intra:80
      - DRONE_STASH=true
      - DRONE_STASH_GIT_USERNAME=USERNAME
      - DRONE_STASH_GIT_PASSWORD=PASSWORD
      - DRONE_STASH_CONSUMER_KEY=CONSUMER_KEY
      - DRONE_STASH_CONSUMER_RSA=/etc/bitbucket/key.pem
      - DRONE_STASH_URL=https://COMPANY_URL.intra
      - DRONE_SECRET=SECRET1
    volumes:
      - '/etc/bitbucket/key.pem:/etc/bitbucket/key.pem:Z'

  drone-agent:
    image: drone/agent:0.8

    restart: always
    depends_on:
      - drone-server
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:Z
    environment:
      - DRONE_SERVER=http://drone.COMPANY.intra
      - DRONE_SECRET=SECRET1

What is it I am missing/not seeing?

I found this, which seems eerily familiar...

However, if that's the root cause, how can I set the permissions of a database file I'm currently assuming resides in the drone/drone:0.8 image? (Seems strange that it'd be the container creating it though...)

There's also no mention of a database file in the official documentation, neither here nor here =/.

Links:

  1. Original discussion @discourse.drone.io.

    • (Was advised to try my luck here @ S/O).
  2. Link to promised gist with normal (and verbose) - sanitized! - output:


Solution

  • There are (at least) two things wrong with your docker-compose file:

    1) you have the volumes: section twice in the config for the drone server, consolidate and put both volume mappings in the same section

    2) in the drone agent config, the URL of the drone server is wrong, it shouldn't include the http:// scheme and it's missing the port, try DRONE_SERVER=drone-server:9000

    docker-compose.yml

    # Docker compose file syntax:
    version: '2'
    
    services:
      drone-server:
        image: drone/drone:0.8
    
        ports:
          - 5124:8000
          - 5125:9000
        volumes:
          - '/var/lib/drone:/var/lib/drone/:Z'
          - '/etc/bitbucket/key.pem:/etc/bitbucket/key.pem:Z'
        restart: always
        environment:
          - DRONE_OPEN=true
          - DRONE_HOST=http://drone.COMPANY.intra:80
          - DRONE_STASH=true
          - DRONE_STASH_GIT_USERNAME=USERNAME
          - DRONE_STASH_GIT_PASSWORD=PASSWORD
          - DRONE_STASH_CONSUMER_KEY=CONSUMER_KEY
          - DRONE_STASH_CONSUMER_RSA=/etc/bitbucket/key.pem
          - DRONE_STASH_URL=https://COMPANY_URL.intra
          - DRONE_SECRET=SECRET1
    
      drone-agent:
        image: drone/agent:0.8
    
        restart: always
        depends_on:
          - drone-server
        volumes:
          - /var/run/docker.sock:/var/run/docker.sock:Z
        environment:
          - DRONE_SERVER=drone-server:9000
          - DRONE_SECRET=SECRET1