Long story short, before 21st November 2024 and some weeks backwards, there has been issue with the implementation of the media storage. Therefore, I implemented a more production ready storage system, using a external MinIO bucket instead of @local-file
If you have an older project launched with this template, and you want to add the MinIO storage, follow this guide.
Change name of service to Bucket
Then go to settings and modify the start command: /bin/sh -c "exec minio server --address [::]:$MINIO_PRIVATE_PORT $RAILWAY_VOLUME_MOUNT_PATH"
Modify health check path: /minio/health/ready
Make sure Networking is set to HTTP
Once finished, it should look like this:
Finally, left click on the Bucket container on the cavas and attach a storage volume. Set the mount path to /data
Under the service should appear a little disk icon followed by /data - (see first image of the layout)
2. Add Bucket url to Railway storefront service variables:NEXT_PUBLIC_MINIO_ENDPOINT="${{Bucket.MINIO_PUBLIC_HOST}}"
Once this is added, you shuold see an arrow from the storefront container pointing to the Bucket container
Optionally, add Bucket console (web interface for your bucket media)
Once these are set, you should see the final arrow, from the Console container to the Bucker container
3. configure settings
Make sure Networking it is set to HTTP
Change name to Console
Change start command to: /bin/sh -c "exec console server --host 0.0.0.0 --port $PORT"
Change healthcheck endpoint to: /login
Long story short, before 21st November 2024 and some weeks backwards, there has been issue with the implementation of the media storage. Therefore, I implemented a more production ready storage system, using a external MinIO bucket instead of
@local-file
If you have an older project launched with this template, and you want to add the MinIO storage, follow this guide.
Backend
1. Add the minio storage module Add backend directory:
backend/src/modules/minio-file
Add all the files and their content from: https://github.com/rpuls/medusajs-2.0-for-railway-boilerplate/tree/master/backend/src/modules/minio-file2. Add the medusa configuration Replace existing file module with:
3. Install required
/bacend
dependencies Add the following two dependencies tobackend/package.json
"minio": "^8.0.2",
and"ulid": "^2.3.0"
Your dependencies shuold look like this:Replace
/backend/pnpm-lock.yaml
with the content of https://github.com/rpuls/medusajs-2.0-for-railway-boilerplate/blob/master/backend/pnpm-lock.yaml to ensure exact dependency versions.4. Add the MinIO services in Railway We are aiming for this layout:
First Click "add new" choose "Docker Image", search of:
minio/minio:latest
Once it added, change variables:
Change name of service to
Bucket
Then go to settings and modify the start command:/bin/sh -c "exec minio server --address [::]:$MINIO_PRIVATE_PORT $RAILWAY_VOLUME_MOUNT_PATH"
Modify health check path:/minio/health/ready
Make sure Networking is set toHTTP
Once finished, it should look like this:
Finally, left click on the Bucket container on the cavas and attach a storage volume. Set the mount path to
/data
Under the service should appear a little disk icon followed by /data - (see first image of the layout)5. Update Backend variables: Add the following:
Now you should see an arrow from the backend Container pointing to the Bucket container.
storefront
1. add Bucket URL to next image remote path
Verify that it looks identical to: https://github.com/rpuls/medusajs-2.0-for-railway-boilerplate/blob/master/storefront/next.config.js
2. Add Bucket url to Railway storefront service variables:
NEXT_PUBLIC_MINIO_ENDPOINT="${{Bucket.MINIO_PUBLIC_HOST}}"
Once this is added, you shuold see an arrow from the storefront container pointing to the Bucket containerOptionally, add Bucket console (web interface for your bucket media)
1. Add service In Railway, once again click "add new", this time choose "github repo" Enter git url: https://github.com/railwayapp-templates/minio-console
2. Add variables
Once these are set, you should see the final arrow, from the Console container to the Bucker container
3. configure settings Make sure Networking it is set to
HTTP
Change name toConsole
Change start command to:/bin/sh -c "exec console server --host 0.0.0.0 --port $PORT"
Change healthcheck endpoint to:/login
Apply changes
Click deploy changes in Railway Push Git changes