Hello there!
I have a simple application I’d like to deploy over here consisting of a react application, a node/express app and a mongodb database. The react app communicates with the express app, which works as an api, fetching data from the databse and returning it to the frontend app.
I have a docker-compose file for it (which will be written down below, with some irrelevant info ommitted), and the app works wonders locally, but from what I’ve gathered, in order to deploy it here in fly.io, I would have to deploy each component of the application as its own separate app.
This is no real issue when it comes to the react and express apps, I can just use their respective dockerfiles to launch the application and those two work wonders.
The issue is that the express app is seemingly unable to communicate with the mongodb container.
I created a dockerfile just to deploy the mongodb app itself, the contents of which are just the following:
FROM mongo:latest
EXPOSE 27017
CMD [ "mongod" ]
And the original docker-compose.yaml I’m trying to deploy:
version: '3'
services:
client:
build: ./client
container_name: atlas-client
ports:
- "3000:3000"
server:
build: ./server
container_name: atlas-server
ports:
- "9000:9000"
volumes:
......
db:
image: mongo
container_name: mongodb
ports:
- "27017:27017"
Does anyone more knowledgeable than me (it’s my first time deploying on an environment I can’t just docker-compose my way out of) know of a way to host this database?
I’m afraid I have wasted too much time trying to hammer this out all by myself
Have a nice evening!
Edit: for some extra context, I configured the ports correctly, and I am passing the hostname of each application as environment variables