access service from worker instance

I successfully created a worker using this, while this is very easy and uses curl as an example, my problem is I need to run php script from the service instance so I need the crontab to access the service outside the worker container to run a php script e.g. /workspace/.heroku/php/bin/php /workspace/bin/console mautic:segments:update. I know I can access the internal service via exposed port 8080 by http://<name>:<port> but due to security concern, I would like to directly access the service rather than using http.

appspec is similar to this

name: walrus-app
region: nyc
- environment_slug: node-js
    branch: main
  http_port: 8080
  instance_count: 1
  instance_size_slug: basic-xxs
  name: sample-nodejs
  - path: /
  run_command: yarn start
  source_dir: /
- dockerfile_path: Dockerfile
    branch: main
    deploy_on_push: true
    repo: DO-Solutions/Docker-cron
  instance_count: 1
  instance_size_slug: basic-xxs
  name: Docker-cron
  source_dir: /

any help is greatly appreciated.

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
May 20, 2023

Hi there,

I recently had a discussion about this here:

The documentation that you’ve shared gives a Node.js sample app as an example to trigger HTTP endpoints. In order for this to work, you need to get the files from the docker-cron repo and use the Dockerfile from the example repo as a blueprint and adjust it for your PHP project.

That way, rather than running the example curl command from the demo Node app, the Worker component will clone your PHP project and will have access to all of the necessary files.

There is a PHP Dockerfile example in the answer above.

The alternative option as you mentioned is to use the internal port and send HTTP requests instead.

Hope that this helps!



Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

card icon
Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Sign up
card icon
Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We’d like to help.

Learn more
card icon
Become a contributor

You get paid; we donate to tech nonprofits.

Learn more
Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow – whether you’re running one virtual machine or ten thousand.

Learn more ->
DigitalOcean Cloud Control Panel