Is there anyways to point to a container that is running outside of the drone network that gets created?
I would like to have the supporting services already running in their own containers to share across different branch / project builds.
Is there anyways to point to a container that is running outside of the drone network that gets created?
I would like to have the supporting services already running in their own containers to share across different branch / project builds.
yes, you would have to create the container and attach to a user-defined network. Then you can attach the user defined network globally to all pipelines using this parameter. I have provided a link to the setting below; you can probably also search this forum for discussions of its use.
https://docs.drone.io/runner/docker/configuration/reference/drone-runner-networks/
Excellent, I love this answer.
When you mention that the runner container needs to be specified to these other networks, then I assume in the steps I need to tell it which network or it will just sort that out?
Going to give this a shot now and see what happens.
I assume they would still just reference the resources by the docker names?
So it appears it can’t seem to see the reference when specifying the hostname on the configuration for the mysql host
Mysql2::Error::ConnectionError:
Can’t connect to MySQL server on ‘mysql’ (115)
So I created a docker network named drone-shared, which is a bridge network.
I started MySQL and Redis containers on that network and confirmed they were there based on the docker network inspect drone-shared
.
I redid the drone runner with the following, specifying the DRONE_RUNNER_NETWORKS=drone-shared
:
docker run -d \
-v /var/run/docker.sock:/var/run/docker.sock \
-e DRONE_RPC_PROTO=http \
-e DRONE_RPC_HOST=xxxxx.dyndns.org:5000 \
-e DRONE_RPC_SECRET=xxxxxxx9b158b72d40ba08d00d9c \
-e DRONE_RUNNER_CAPACITY=10 \
-e DRONE_RUNNER_NAME=${HOSTNAME} \
-e DRONE_RUNNER_NETWORKS=drone-shared \
-p 3000:3000 \
--restart always \
--name runner \
drone/drone-runner-docker:1
docker run \
-p 3306:3306 \
--env MYSQL_DATABASE=test \
--env MYSQL_ROOT_PASSWORD=password \
--name mysql \
--network drone-shared \
--detach \
--rm \
mysql:8.0.23
docker run \
-p 6379:6379 \
--name redis \
--network drone-shared \
--detach \
--rm \
redis:6.0.10
And the step block looks like so:
steps:
- name: rspec
image: ruby:2.7.1
environment:
RAILS_MASTER_KEY:
from_secret: master_key
ELASTICSEARCH_HOST: elasticsearch:9200
MYSQL_HOST: mysql
MYSQL_PORT: 3306
MYSQL_USER: root
MYSQL_PASSWORD: password
MYSQL_DATABASE: db_name_test
REDIS_NAMESPACE: drone_test
REDIS_URL: redis://redis:6379
commands:
- bundle config set path '/bundle'
- bundle install --jobs=3 --retry=3
- bundle exec rake spec
volumes:
- name: gem-cache-${DRONE_BRANCH}-$(checksum Gemfile.lock)
path: /bundle
- name: tmp
path: /drone/src/tmp