Learn about how Ergomake routes requests to and within environments.
localhost
port on your docker-compose.yml
.
For example, if you bind a container’s 3000
port to a port on localhost
, Ergomake will expose port 3000
to the internet when deploying your that service in your preview environment.
Take the api
and database
services below, for example.
3001
port to localhost:8080
. Consequently, Ergomake will expose the container’s 3001
port over the internet.
Similarly, Ergomake will also expose the database
’s 27017
port over the internet when creating your environment.
Here’s what the URLs to reach api
and database
would look like in the above scenario, respectively:
api
: https://api-yourOrg-yourRepo-prNumber.env.ergomake.link
database
: https://database-yourOrg-yourRepo-prNumber.env.ergomake.link
9001
for the api
service is exposed within localhost
, it won’t be exposed to the internet. That’s because only the first bound port will be exposed to the internet.
api
can address a service named database
by using database
as the hostname.
Assume, for example, that you have a service named api
containing a Node.js application. The api
service connects to a MongoDB instance within a service named mongo
.
mongo
as the hostname within your Node.js application.
localhost
to
connect to them. Exposing services so that you can connect to them via
localhost
will not work because localhost
does not exist for Ergomake.
Please make sure to always use your service’s names when connecting to them.REACT_APP_API_URL
during build time, as shown below.
REACT_APP_API_URL
build argument with the address we’ll generate for api
. That build argument will be used to set the REACT_APP_API_URL
environment variable that npm run build
uses when bundling the React app.
To do that, you’ll use the dev.ergomake.env.replace-arg.YOUR_ENV_VAR
label. Within that label, you can interpolate the address we’ll generate for the api
service, as shown in the example below.
REACT_APP_API_URL
when creating your image.