By phuctm97
Hi DO, I’m building a Node.js app which requires a Docker internal service, it needs to be able to access the Docker internal service (via env vars). Currently, I couldn’t find documentation anywhere talk about this. I couldn’t configure workers in deploy.template.yaml, either. My configuration: https://github.com/phuctm97/img-node/blob/master/.do/deploy.template.yaml
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!
Hello, quickly looking at the linked repository it seems the API is trying to talk to the puppeteer worker via websockets. In App Platform workers are not exposed via HTTP. For this type of interaction you should use “internal services” rather than a worker. See internal_ports in app spec reference. Here is an example repo utilizing the concept (under the /multi route).
So in your case, I think the spec should look something like:
spec:
name: img
services:
- name: api
environment_slug: node-js
git:
branch: master
repo_clone_url: https://github.com/phuctm97/img-node
envs:
- key: BROWSER_ENDPOINT
scope: RUN_TIME
value: "chrome:3000"
- name: chrome
environment_slug: docker
image:
repository: browserless/chrome
internal_ports:
- 3000
That should result in the api service exposed publicly, and the chrome service exposed internally on port 3000. Provided that browserless/chrome respects the PORT env parameter (quickly looking into the code on GitHub it looks like it should), that should make the puppeteer websocket service available to call from the api service.
Hope this helps!
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.