How do I pass configuration files to services?

In my cloning step, I get all my configuration files necessary for services like php, nginx, etc…

I need to have these files available as volumes to services when I run them. I do not see a way to delay running service because services do not take depends_on directive. Alternatively I tried running nginx service as one of the steps and set detached to true. However, when I do this, other steps that follow are not able to resolve the nginx step’s service by it’s step name.

How should one go about this?

Services do not have access to the depend_on instruction, indeed.

However, detached steps can be made to wait on other instructions before launching.
https://docs.drone.io/pipeline/docker/syntax/services/#detached-steps

That’s the way I’m launching containers that must be configured at runtime in my pipelines.

I discovered that when you have a detached step, you can not have commands, otherwise service breaks and it’s not accessible. It feels like a bug to me, but at very least, the documentation should mention this.

when you have a detached step, you can not have commands, otherwise service breaks and it’s not accessible

I’m very curious about that…
Unless I understand you wrong, I’ve been doing exactly that in my pipelines for a while without issues…

Here’s a sample step from one of my projects…

- name: ${DRONE_COMMIT}.focusoptimization.com
      image: node:12-alpine
      detach: true
      user: node
      commands:
          - npm start
      environment:
          API_URL: https://api-backend.focusoptimization.com:5443
          WEB_PROXY_URL: https://${DRONE_COMMIT}.focusoptimization.com
      volumes:
          - name: certs
            path: /etc/ssl/focus
      depends_on:
          - ci
          - Wait On

(This step launches a webserver, then detaches from the flow, so that in another container, I can wait for the server to be up
npx wait-on -t 300000 https-get://${DRONE_COMMIT}.focusoptimization.com
then run my tests on the server

You are correct. The claim that drone has issues with detached steps and commands was a false positive. See this thread:
http://discuss.harness.io/t/command-entry-in-detached-step-breaks-service/9522

1 Like