Attach same volume to 2 different services
vishalkadam47
HOBBYOP

a year ago

I have a service app which required files in config folder and assets folder so i have attached a volume with /app/data then,
I deployed filebrowser template but it already comes with a volume, so i'm confused how do I use filebrowser to create those folders and upload my files. which is attached to my service app

    volumes:
      - ./config:/app/config
      - ./assets:/app/assets

or is there a way to attach the same volume for both the services, or is there any other workaround please help

Solved

47 Replies

vishalkadam47
HOBBYOP

a year ago

i don't have a project yet do not close the post


a year ago

unfortunately you can't add two volumes to the same service or have a shared volume between 2 services

maybe MinIO could help?


vishalkadam47
HOBBYOP

a year ago

how do i create config folder and add files in a volume


a year ago

Railway doesn't have a way to directly alter the volume in-app yet, so the easiest way to do that is by using the Filebrowser template to ask a intermediary

The steps are as follows:

  1. Right click on your project canvas

  2. Deploy from template

  3. Deploy Filebrowser

  4. Delete the volume Filebrowser comes with

  5. Dismount and Remount your volume to Filebrowser on path /data

  6. Set the variable USE_VOLUME_ROOT (or something like that) to 1

  7. Enter filebrowser using the creds in its service variable and make the changes

  8. Dismount the volume from filebrowser and reconned to your application


vishalkadam47
HOBBYOP

a year ago

now should i create /app folder and then subfolders as required or is there any other step

1346500732160839700


vishalkadam47
HOBBYOP

a year ago

or should i directly create config and assets folder in the root


a year ago

/app would be the directory for your actual app, if you were to mount the volume on /app then it'll overwrite everything within your application
there is no workaround for having both a volume /app/config and /app/assets on your service, you'll either have to use one or the other or use somehting like MinIO (if possible)


vishalkadam47
HOBBYOP

a year ago

not sure how to configure MinIO


a year ago

what're you deploying?


vishalkadam47
HOBBYOP

a year ago

is a go app i want to deploy for my own usecase and also want to create a template


a year ago

if it's your own app, why not just move config and assets to a data directory and then mount the volume to /app/data ?


a year ago

or is it a premade go app?


vishalkadam47
HOBBYOP

a year ago

not my own app, its an open source project


a year ago

ooh okay, you can check the open source project's docs to see if it has any MinIO or S3 support, if it does then you can just use that but if not then unfortunately you'll only be able to choose one path to store in a volume, (either config or assets, can't store both since Railway doesn't support multiple volumes yet)


vishalkadam47
HOBBYOP

a year ago

nope they do not have MinIO or S3 support


a year ago

Ah, dang 😔


vishalkadam47
HOBBYOP

a year ago

ok i have an option where i can use only one config path but still need a way do create files in the config folder path how should i do that


a year ago

if it's for a template, then you might have to create the files dynamically within the start command of the application
I did something similar for the Dashy template since it doesn't populate a default config itself

If it's just for personal use then you could just pop the volume into a Filebrowser deployment (make sure USE_VOLUME_ROOT is set to 1) and populate the volume with the appropriate files then mount it back to your service under /app/config


vishalkadam47
HOBBYOP

a year ago

actually i did check your dashy template but i didnt understand how does it download yml file from the url to dashy volume, do we need to have the variable name in dashy, i mean in the dashy's official repo


vishalkadam47
HOBBYOP

a year ago

so here i should change the volume to /app/config right and then use the env var for the yml file url

1346512316568440800


a year ago

if you deploy it you can go look at its start command, all the magic happens there


vishalkadam47
HOBBYOP

a year ago

ok now i get this, thanks


vishalkadam47
HOBBYOP

a year ago

my bad, previously i didnt check the stsrt command


a year ago

no worries


vishalkadam47
HOBBYOP

a year ago

but i need to check for go command


vishalkadam47
HOBBYOP

a year ago

thanks, finally i got this working


vishalkadam47
HOBBYOP

a year ago

but does the start command should be in a single line


a year ago

it should but you can pretty much condense any command I can think of into a single line


vishalkadam47
HOBBYOP

a year ago

Will publish a template today


vishalkadam47
HOBBYOP

a year ago

For my personal usecase I need a way to download multiple files in the given path


vishalkadam47
HOBBYOP

a year ago

one doubt what would be the health check path if this is given

HEALTHCHECK --timeout=10s --start-period=60s --interval=60s \
  CMD wget --spider -q http://localhost:8080/api/healthz

is it http://localhost:8080/api/healthz or /api/healthz or /healthz


vishalkadam47
HOBBYOP

a year ago

one doubt what should be the health check path if this is given, i did check the docs but didnt understand

HEALTHCHECK --timeout=10s --start-period=60s --interval=60s \
  CMD wget --spider -q http://localhost:8080/api/healthz

is it http://localhost:8080/api/healthz or /api/healthz or /healthz


a year ago

it depends on the application, but it's a path not a url so it wouldn't be the first one


vishalkadam47
HOBBYOP

a year ago

here's the template for which i was asking for volumes
https://railway.com/template/ZHBnkG?referralCode=vishify


vishalkadam47
HOBBYOP

a year ago

thanks for the magic command some how i figured it out a working start command


a year ago

Awesome!! Glad you got it working


a year ago

that's a cool template


vishalkadam47
HOBBYOP

a year ago

but it requires more other files so i was trying to enhance the start command if you can guide me through this

/bin/sh -c 'for VAR in CONFIG_FILES; do URLS=$(eval echo \$$VAR); for URL in $(echo "$URLS" | tr "," " "); do [ -n "$URL" ] && FILE_NAME=$(basename "$URL") && DEST_PATH="/app/config/$FILE_NAME" && echo "Downloading $FILE_NAME..." && wget -O "$DEST_PATH" "$URL" && echo "$FILE_NAME has been downloaded."; done; done; for VAR in CUSTOM_CSS FAVICON LOGO; do URL=$(eval echo \$$VAR); [ -n "$URL" ] && FILE_NAME=$(basename "$URL") && DEST_PATH="/app/config/$FILE_NAME" && echo "Downloading $FILE_NAME..." && wget -O "$DEST_PATH" "$URL" && echo "$FILE_NAME has been downloaded."; done; echo "Starting Glance..." && ./glance --config /app/config/glance.yml'

a year ago

I'm honestly not really that good at making such complex one line shell commands I usually just have chatgpt aid me 🤣


vishalkadam47
HOBBYOP

a year ago

btw even i used chatgpt, but i'm missing the logic will the railway support downloading multiple files to the same volume


a year ago

of course


a year ago

railway should be able to do basically anything the command is able to do


vishalkadam47
HOBBYOP

a year ago

ok will try


vishalkadam47
HOBBYOP

a year ago

this works actually, now i'm able to download multiple yml files, it was my bad i missed one path


a year ago

nice work :D


vishalkadam47
HOBBYOP

a year ago

thanks


a year ago

!s


Status changed to Solved dev about 1 year ago


Loading...