deploy only client with fly

How do I deploy only the client with fly.io? I already have the server and database setup with fly, but want to migrate the client from Netlify.
6 Replies
kapa.ai
kapa.ai4d ago
Hi @Ricardo Batista. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- To deploy only the client with Fly.io when you already have the server and database set up, you can follow these steps: 1. First, build your client:
cd .wasp/build/web-app
npm install && REACT_APP_API_URL=<url_to_wasp_backend> npm run build

cd .wasp/build/web-app
npm install && REACT_APP_API_URL=<url_to_wasp_backend> npm run build

Replace <url_to_wasp_backend> with the URL of your already deployed Wasp server. 2. Create a Dockerfile in the web-app directory with the following content:
FROM pierrezemb/gostatic
CMD [ "-fallback", "index.html" ]
COPY ./dist/ /srv/http/

FROM pierrezemb/gostatic
CMD [ "-fallback", "index.html" ]
COPY ./dist/ /srv/http/

3. Create a .dockerignore file in the same directory with:
node_modules/

node_modules/

4. Copy the build folder to dist:
cp -r build dist

cp -r build dist

5. Use the Fly.io CLI to deploy the client:
flyctl launch --remote-only

flyctl launch --remote-only

This will create a new Fly.io app for your client. 6. Set the PORT environment variable:
flyctl secrets set PORT=8043

flyctl secrets set PORT=8043

7. Deploy the client:
flyctl deploy

flyctl deploy

After deployment, make sure to update the WASP_WEB_CLIENT_URL environment variable on your server app to point to the new Fly.io client URL:
flyctl secrets set WASP_WEB_CLIENT_URL=<new_client_url> --app <your-server-app-name>
flyctl secrets set WASP_WEB_CLIENT_URL=<new_client_url> --app <your-server-app-name>
Replace <new_client_url> with the URL of your newly deployed client on Fly.io, and <your-server-app-name> with the name of your server app on Fly.io. These steps are adapted from the manual deployment process described in the Wasp documentation for deploying to Railway, but modified for Fly.io. Remember to update any necessary configuration files or environment variables to ensure your client communicates correctly with your server on Fly.io. Wasp Docs: Deploying the Client Wasp Docs: Deploying the Web Client (frontend) ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Ricardo Batista, 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?
Ricardo Batista
Ricardo BatistaOP4d ago
@kapa.ai Great tutorial there. I followed the steps, and now am getting the live logs:
2025-01-23 22:25:12.223
[PR04] could not find a good candidate within 21 attempts at load balancing
2025-01-23 22:25:08.215
[PC01] instance refused connection. is your app listening on 0.0.0.0:3000? make sure it is not only listening on 127.0.0.1 (hint: look at your startup logs, servers often print the address they are listening on)
2025-01-23 22:25:07.201
[PC01] instance refused connection. is your app listening on 0.0.0.0:3000? make sure it is not only listening on 127.0.0.1 (hint: look at your startup logs, servers often print the address they are listening on)
2025-01-23 22:24:57.032
[PC01] instance refused connection. is your app listening on 0.0.0.0:3000? make sure it is not only listening on 127.0.0.1 (hint: look at your startup logs, servers often print the address they are listening on)
2025-01-23 22:24:56.999
[PC01] instance refused connection. is your app listening on 0.0.0.0:3000? make sure it is not only listening on 127.0.0.1 (hint: look at your startup logs, servers often print the address they are listening on)
2025-01-23 22:24:11.768
2025/01/23 21:24:11 INFO SSH listening listen_address=[fdaa:9:1bf6:a7b:33b:df47:cc8f:2]:22 dns_server=[fdaa::3]:53
2025-01-23 22:24:11.609
9:24PM INF Listening at http://0.0.0.0:8043 /...
2025-01-23 22:25:12.223
[PR04] could not find a good candidate within 21 attempts at load balancing
2025-01-23 22:25:08.215
[PC01] instance refused connection. is your app listening on 0.0.0.0:3000? make sure it is not only listening on 127.0.0.1 (hint: look at your startup logs, servers often print the address they are listening on)
2025-01-23 22:25:07.201
[PC01] instance refused connection. is your app listening on 0.0.0.0:3000? make sure it is not only listening on 127.0.0.1 (hint: look at your startup logs, servers often print the address they are listening on)
2025-01-23 22:24:57.032
[PC01] instance refused connection. is your app listening on 0.0.0.0:3000? make sure it is not only listening on 127.0.0.1 (hint: look at your startup logs, servers often print the address they are listening on)
2025-01-23 22:24:56.999
[PC01] instance refused connection. is your app listening on 0.0.0.0:3000? make sure it is not only listening on 127.0.0.1 (hint: look at your startup logs, servers often print the address they are listening on)
2025-01-23 22:24:11.768
2025/01/23 21:24:11 INFO SSH listening listen_address=[fdaa:9:1bf6:a7b:33b:df47:cc8f:2]:22 dns_server=[fdaa::3]:53
2025-01-23 22:24:11.609
9:24PM INF Listening at http://0.0.0.0:8043 /...
kapa.ai
kapa.ai4d ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- Based on the logs you've provided, it seems that there's a mismatch between the port Fly.io is expecting your application to listen on and the port your application is actually using. Let's address this issue: 1. Your application is listening on port 8043, as indicated by the last log line:
9:24PM INF Listening at <http://0.0.0.0:8043> /...

9:24PM INF Listening at <http://0.0.0.0:8043> /...

2. However, Fly.io is trying to connect to port 3000, as shown in the error messages:
[PC01] instance refused connection. is your app listening on 0.0.0.0:3000?

[PC01] instance refused connection. is your app listening on 0.0.0.0:3000?

To resolve this, you need to update your Fly.io configuration to use the correct port. Here's what you should do: 1. Open your fly.toml file in the root of your project. 2. Look for a section that specifies the internal port. It might look something like this:
[http_service]
internal_port = 3000

[http_service]
internal_port = 3000

3. Change the internal_port to 8043 to match the port your application is using:
[http_service]
internal_port = 8043

[http_service]
internal_port = 8043

4. Save the fly.toml file. 5. Redeploy your application:
flyctl deploy

flyctl deploy

This should resolve the port mismatch issue. After redeploying, Fly.io should be able to connect to your application correctly. If you're still experiencing issues after making this change, you might want to double-check your Dockerfile to ensure it's correctly setting up and running your static file server on port 8043. Wasp Docs: Deploy to a Fly.io App Remember, when deploying static sites, it's crucial to ensure that your static file server (in this case, gostatic) is configured to listen on the correct port and that this port matches what's specified in your Fly.io configuration. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Ricardo Batista, 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?
Ricardo Batista
Ricardo BatistaOP4d ago
@kapa.ai thanks, it works!
kapa.ai
kapa.ai4d ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- You're welcome! I'm glad to hear that the solution worked for you and you were able to successfully deploy your client to Fly.io. If you have any more questions about Wasp or need assistance with anything else related to the framework, feel free to ask. Happy coding! ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Ricardo Batista, 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?
miho
miho4d ago
Nice 👍

Did you find this page helpful?