R
Railway8mo ago
h246810

Is it possible to run docker compose as a railway service

I have a fairly straightforward app running via docker compose. Is there way to get this to run on a railway service? I will post the dockerfile below. I expect I would have to make some changes to use private networking if that is the case.
services:
frontend:
build:
context: ./frontend
ports:
- "80:80"
networks:
- osft-network
backend:
build:
context: ./backend
image: osft-backend
ports:
- "3000:3000"
depends_on:
- mongodb
- redis
networks:
- osft-network
mongodb:
image: "mongo:latest"
ports:
- "27017:27017"
networks:
- osft-network
volumes:
- db_data:/data/db
environment:
MONGO_INITDB_DATABASE: osft-local
redis:
image: "redis:latest"
ports:
- "6379:6379"
networks:
- osft-network

networks:
osft-network:
driver: bridge

volumes:
db_data:
driver: local
services:
frontend:
build:
context: ./frontend
ports:
- "80:80"
networks:
- osft-network
backend:
build:
context: ./backend
image: osft-backend
ports:
- "3000:3000"
depends_on:
- mongodb
- redis
networks:
- osft-network
mongodb:
image: "mongo:latest"
ports:
- "27017:27017"
networks:
- osft-network
volumes:
- db_data:/data/db
environment:
MONGO_INITDB_DATABASE: osft-local
redis:
image: "redis:latest"
ports:
- "6379:6379"
networks:
- osft-network

networks:
osft-network:
driver: bridge

volumes:
db_data:
driver: local
17 Replies
Percy
Percy8mo ago
Project ID: b70c2b91-7e72-49ce-a124-ecb0f1d43ff9
h246810
h246810OP8mo ago
b70c2b91-7e72-49ce-a124-ecb0f1d43ff9 Also, if this question has been answered, I would greatly appreciate a point in the right direction. Thanks.
Brody
Brody8mo ago
railway does not support docker compose, and if it did, this file only has one environment variable?
h246810
h246810OP8mo ago
Haha yes, it's more of a 'test' if you would. ENV vars are hardcoded
Brody
Brody8mo ago
test or not, never hardcode variables, it creates fragile systems mongo alone would need about 5 variables to be setup properly
h246810
h246810OP8mo ago
I see. It is running with this configuration on my machine, but I imagine it would be different running in a railway environment>? ?*
Brody
Brody8mo ago
running is one thing, running properly is a whole other ball game, for example mongo has no password, and your backend has no environment variable to tell it what mongo's hostname would be, same goes for redis, same also goes for the frontend, it doesnt have an environment variable to tell it the url of the backend
h246810
h246810OP8mo ago
Well yes, again I was more interested in a quick test and this would never actually come close to production or anything that anybody could use before I could delete it
Brody
Brody8mo ago
i understand, but i believe good practices should still be used, even for testing besides, this compose file would be incredibly easy to translate manually into a project, youd spend the most time removing all the hardcoded stuff
h246810
h246810OP8mo ago
Totally I was like 90% on my way to getting the app up and running via compose, and lazily hardcoding got it running. Totally agree that good practices should be used in testing. Thanks for letting me know that compose is not supported via railway It's an old application of mine, was trying to port for fun
Brody
Brody8mo ago
well not yet at least, and im not sure how i feel about them adding support for it, after seeing this kind of compose file, no offense ❤️
h246810
h246810OP8mo ago
hahaha none taken lol i respect it this is horrible secrets management do not attempt at home kids** if you're reading
Brody
Brody8mo ago
i mean even supabase has a bad compose file, so its not even really your fault
h246810
h246810OP8mo ago
that makes me feel a bit better
Brody
Brody8mo ago
remove all the hardcoded stuff from in your code and then id be happy to help you get this up and running on railway
h246810
h246810OP8mo ago
I'll come back to you
Brody
Brody8mo ago
sounds good
Want results from more Discord servers?
Add your server