I successfully created a worker using this https://docs.digitalocean.com/developer-center/how-to-setup-a-job-scheduler-on-digitalocean-app-platform/, 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
alerts:
- rule: DEPLOYMENT_FAILED
- rule: DOMAIN_FAILED
name: walrus-app
region: nyc
services:
- environment_slug: node-js
git:
branch: main
repo_clone_url: https://github.com/digitalocean/sample-nodejs.git
http_port: 8080
instance_count: 1
instance_size_slug: basic-xxs
name: sample-nodejs
routes:
- path: /
run_command: yarn start
source_dir: /
workers:
- dockerfile_path: Dockerfile
github:
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.
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!
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.
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!
Best,
Bobby