W
Wasp4w ago
Landyn

How to deploy to an existing Railway Project?

What do I need to do to deploy to an existing railway project? I am able to launch a new project without issue. However, I want to launch into an existing project, where I can take advantage of internal API calls between apps/databases.
7 Replies
kapa.ai
kapa.ai4w ago
Hi @Landyn. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- To deploy your Wasp app to an existing Railway project, you need to link your local build directory to the existing Railway project and service, rather than creating a new one. Here’s how you can do it based on the official Wasp documentation: 1. Build your Wasp app:
wasp build

wasp build

2. Link to your existing Railway project: - Navigate to the appropriate build directory: - For the server:
cd .wasp/build

cd .wasp/build

- For the client:
cd .wasp/build/web-app

cd .wasp/build/web-app

- Run:
railway link

railway link

- When prompted, select your existing Railway project and the correct service (e.g., server or client). This step is crucial for deploying to an existing project instead of creating a new one. 3. Set environment variables: - In the Railway dashboard, go to your project, select the relevant service, and set the required environment variables (e.g., DATABASE_URL, WASP_WEB_CLIENT_URL, WASP_SERVER_URL, JWT_SECRET, etc.) as described in the docs. This ensures your app is correctly configured for the Railway environment. 4. Deploy: - For the server:
railway up

railway up

Select the server service when prompted. - For the client, follow the steps to build and deploy the frontend, including copying the build to dist, creating the appropriate Dockerfile, and running:
railway up

railway up

Select the client service when prompted. Note: If you want to automate the client deployment, you can use the provided deploy_client.sh script from the docs, making sure to set the REACT_APP_API_URL environment variable before running it. This process allows you to deploy to an existing Railway project and take advantage of internal networking between your services and databases within the same project. You do not need to create a new project each time—just link and deploy to the existing one as described above. For more details and step-by-step instructions, see the official Wasp documentation: Deploying Manually to Railway and Deploying the Server and Deploying the Client. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Landyn, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
Carlos
Carlos4w ago
I'll pass this onto @miho who did extensive testing with Railway, do you have an idea?
miho
miho4w ago
@Landyn could you maybe share a screenshot of an existing projects dashboard e.g. to see the name of the services? 🙂
Landyn
LandynOP4w ago
Hi @miho , Here is a fresh railway project that I was easily able to deploy using CLI wasp deploy railway deploy retail-analytics
No description
Landyn
LandynOP4w ago
Here is the larger project that I was unable to get working using CLI: My gut was telling me that the issue was that my main App also has a database called Postgres that my wasp project was trying to automatically link to. I just don't have enough experience in deployment to know how to define the database in the wasp build process. I deleted the app/server on the second screenshot as I was trying to iterate on solutions, so it is not present in the screenshot. I kept getting build errors in the larger project
No description
miho
miho4w ago
@Landyn the trick is to follow the Wasp conventions of: - server app name <project-name>-server - client app name <project-name>-client - database name Postgres So for redeployments - the <project-name> is the value you'll pass to the wasp deploy railway deploy <project-name> command. And then Wasp will try to link correct dirs to the server and client services and deploy them using railway up command. So in your case, let's say you'll define the <project-name> as calculator-app this means that when you call wasp deploy railway deploy calculator-app Wasp expects to see two services in your project called: calculator-app-server and calculator-app-client (You should create those as empty services with correct names in your Railway project and it should work 🙂 ) Let me know if you need more help!
Carlos
Carlos4w ago
@Landyn let me know if that is useful and i'll mark this as solved 😊 and thanks @miho 🙏

Did you find this page helpful?