R
Railwayβ€’11mo ago
Louis.L

MongoDB with volume fails to authenticate after duplication (environment creation)

Hello there, When i create a new environment, already containing a MongoDB instance on the main env, it tries to duplicates it, without any ENV Variables (?), and once i import all the variables from de main environment, the MongoDB instance fails to authenticate (on the "Data" tab of the MongoDB service). I'm a bit confused of the "duplication" behavior, without env vars, and i don't understand why it does not work after i import the variables as well. Thanks for helping !
No description
No description
No description
Solution:
- in the main environment's mongodb service set a service variable MONGO_DBPATH to ${{RAILWAY_VOLUME_MOUNT_PATH}} - cancel the popup - in the mongodb service settings set this start command /bin/sh -c "docker-entrypoint.sh mongod --dbpath ${MONGO_DBPATH} --ipv6 --bind_ip ::,0.0.0.0" - don't cancel the popup - create your new environment in the projects settings...
Jump to solution
21 Replies
Percy
Percyβ€’11mo ago
Project ID: fa4f3b3c-8eb7-43a6-a995-0619ad7c212c
Louis.L
Louis.Lβ€’11mo ago
fa4f3b3c-8eb7-43a6-a995-0619ad7c212c
Brody
Brodyβ€’11mo ago
if you want to create a duplicate environment with all variables the same, you want to use forked environments https://docs.railway.app/develop/environments#forking-and-merging-environments
Louis.L
Louis.Lβ€’11mo ago
Thanks for the reply, i'm not really looking to completely "clone" my environment, just create independant environments "prod, dev, preprod", with the same architecture but with their own data. The problem is the behavior of the MongoDB service with i create a new environment, would you be alright to explain what I need to do with the variables to make it work ?
Brody
Brodyβ€’11mo ago
though i understand they confusion, the reason why the database couldn't be connected to even after adding all the variables back to it is likely because it was already deployed and initialized itself with no variables, this seems like it messed something up internally in the container. in my opinion that flow should not auto deploy anything and instead ask you to setup the variables and then give you a deploy now button for when you have all variables setup
Louis.L
Louis.Lβ€’11mo ago
Alright ! Thats what i was testing and it seems to be the case, because i also have a volume connected to the service. Problem is if i decide to delete the volume to restart the deployment with the variables, the volumes of all the other environments get deleted as well πŸ˜‚ Is there a possibility to reset a volume on one environment only ?
Brody
Brodyβ€’11mo ago
let me see if i can come up with a flow to solve this
Louis.L
Louis.Lβ€’11mo ago
The solution i came up with is to stop de deployment as fast as possible to not write anything on the partition, then import the variables, then re-deploy
Brody
Brodyβ€’11mo ago
thats what im thinking, but doing that is hard, docker images deploy fast and mongo could write garbage to the volume before you are able to abort
Louis.L
Louis.Lβ€’11mo ago
It would be great to have a "Deploy" button floating top right (or any other place) on the dashboard, to click when the user finish to setup the environment Yes, had to do it 3 times before a success
Brody
Brodyβ€’11mo ago
yeah and not have anything auto deploy, because 9 times out of 10 (made up number) a service will fail without any variables set
Louis.L
Louis.Lβ€’11mo ago
Thanks for the help ! Can I mark this thread as solved ?
Brody
Brodyβ€’11mo ago
not solved yet, i havent come up with a flow that works every time yet
Louis.L
Louis.Lβ€’11mo ago
Oh you are still on it, thanks !
Brody
Brodyβ€’11mo ago
of course
Want results from more Discord servers?
Add your server