fly deployment issues

flyctl deploy --remote-only --config ../../fly.toml ==> Verifying app config Validating ../../fly.toml ✓ Configuration is valid --> Verified app config ==> Building image ==> Building image with Depot --> build: (​) [+] Building 1.3s (6/9)
=> [internal] load build definition from Dockerfile0.0s => => transferring dockerfile: 3.51kB 0.0s => [internal] load metadata for docker.io/library/node:200.6s => [internal] load .dockerignore 0.0s => => transferring context: 64B 0.0s => [internal] load build context 0.5s => => transferring context: 2B 0.5s => [base 1/5] FROM docker.io/library/node:20@sha256:a5e0ed56f2c20b9689e0f7dd498cac7e08d2a3a283e92d9304e7b9b83e3c6ff30.0s => => resolve docker.io/library/node:20@sha256:a5e0ed56f2c20b9689e0f7dd498cac7e08d2a3a283e92d9304e7b9b83e3c6ff3 0.0s => ERROR [base 2/5] COPY .wasp/build/ /app/ 0.0s -
[base 2/5] COPY .wasp/build/ /app/:
==> Building image Building image with Depot --> build: (​) [+] Building 0.3s (6/9) => [internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 3.51kB 0.0s => [internal] load metadata for docker.io/library/node:20 0.2s => [internal] load .dockerignore 0.0s => => transferring context: 64B 0.0s => [internal] load build context 0.0s => => transferring context: 2B 0.0s => [base 1/5] FROM docker.io/library/node:20@sha256:a5e0ed56f2c20b9689e0f7dd498cac7e08d2a3a283e92d9304e7b9b83e3c6ff3 0.0s => => resolve docker.io/library/node:20@sha256:a5e0ed56f2c20b9689e0f7dd498cac7e08d2a3a283e92d9304e7b9b83e3c6ff3 0.0s => ERROR [base 2/5] COPY .wasp/build/ /app/0.0s
[base 2/5] COPY .wasp/build/ /app/:
Error: failed to fetch an image or build from source: error building: failed to solve: failed to compute cache key: failed to calculate checksum of ref xii15ojevevjrvuc91l38e6gr::binm88k6v471i483hpa3pjput: "/.wasp/build": not found
28 Replies
kapa.ai
kapa.ai3d ago
Hi @ArDev. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- It seems like you're encountering an error when trying to deploy your Wasp app to Fly.io. The error message indicates that the system is unable to find the /.wasp/build directory. This directory is created when you run wasp build and contains the code that is to be deployed. Here are a few things you could try: 1. Ensure that you have run wasp build before attempting to deploy. This command generates the necessary code in the /.wasp/build directory. 2. Check your project structure. The .wasp/build directory should be at the root level of your project. If it's not, you might need to adjust your COPY command in the Dockerfile to match the actual location of the .wasp/build directory. 3. Make sure you are using the correct version of Wasp. In a Discord support thread (https://discord.com/channels/686873244791210014/1223671727943319584), a user was advised to upgrade to at least Wasp 0.12.4 due to a bug fix related to imports. You can check your Wasp version by running wasp version. 4. If you're modifying the server code, ensure that your changes are being correctly copied into the .wasp/build directory. In the same Discord thread (https://discord.com/channels/686873244791210014/1223671727943319584), a user was advised to keep their "patches" folder in the "src" dir because it will get copied to the .wasp/build folder since Wasp needs the src folder. 5. If you're still encountering issues, you might want to consider building locally. According to the Wasp documentation (https://wasp-lang.dev/docs/advanced/deployment/cli#building-locally), you can supply the --build-locally option to wasp deploy fly launch or wasp deploy fly deploy to build locally. If none of these suggestions work, it might be helpful to provide more information about your project structure and the exact steps you're taking to deploy your app. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @ArDev, 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?
ArDev
ArDev3d ago
Error: failed to fetch an image or build from source: error building: failed to solve: failed to compute cache key: failed to calculate checksum of ref xii15ojevevjrvuc91l38e6gr::xb3c84e6tusfzxyi4g3uirmfg: "/.wasp/build": not found @kapa.ai still getting this, why?
kapa.ai
kapa.ai3d ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- The error message you're seeing typically occurs when the Docker build process can't find the specified directory or file. In this case, it's unable to find the /.wasp/build directory. Here are a few things you could try: 1. Run wasp build before deploying: The /.wasp/build directory is created when you run wasp build. This command generates the necessary code in the /.wasp/build directory that is to be deployed. 2. Check your project structure: The .wasp/build directory should be at the root level of your project. If it's not, you might need to adjust your COPY command in the Dockerfile to match the actual location of the .wasp/build directory. 3. Upgrade Wasp: In a Discord support thread (https://discord.com/channels/686873244791210014/1223671727943319584), a user was advised to upgrade to at least Wasp 0.12.4 due to a bug fix related to imports. You can check your Wasp version by running wasp version. 4. Ensure your changes are being correctly copied: If you're modifying the server code, ensure that your changes are being correctly copied into the .wasp/build directory. In the same Discord thread (https://discord.com/channels/686873244791210014/1223671727943319584), a user was advised to keep their "patches" folder in the "src" dir because it will get copied to the .wasp/build folder since Wasp needs the src folder. 5. Build locally: If you're still encountering issues, you might want to consider building locally. According to the Wasp documentation (https://wasp-lang.dev/docs/advanced/deployment/cli#building-locally), you can supply the --build-locally option to wasp deploy fly launch or wasp deploy fly deploy to build locally. If none of these suggestions work, it might be helpful to provide more information about your project structure and the exact steps you're taking to deploy your app. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @ArDev, 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?
ArDev
ArDev3d ago
@kapa.ai how to only deploy sevrer in fly.io? no database or client
kapa.ai
kapa.ai3d ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- To deploy only the server to Fly.io, you can follow these steps: 1. Build the app: Run wasp build in your project root directory. This will generate the necessary code in the .wasp/build directory. 2. Navigate to the build directory: Use the command cd .wasp/build. 3. Set up a new Fly.io app: Run flyctl launch --remote-only. This will create a new Fly.io app and a fly.toml file. 4. Set environment variables: You need to set up several environment variables. Use the following commands:
flyctl secrets set PORT=8080
flyctl secrets set JWT_SECRET=<random_string_at_least_32_characters_long>
flyctl secrets set WASP_WEB_CLIENT_URL=<url_of_where_client_will_be_deployed>
flyctl secrets set WASP_SERVER_URL=<url_of_where_server_will_be_deployed>
flyctl secrets set PORT=8080
flyctl secrets set JWT_SECRET=<random_string_at_least_32_characters_long>
flyctl secrets set WASP_WEB_CLIENT_URL=<url_of_where_client_will_be_deployed>
flyctl secrets set WASP_SERVER_URL=<url_of_where_server_will_be_deployed>
5. Deploy the app: Run flyctl deploy --remote-only --config ../../fly.toml. This will build and deploy the backend of your Wasp app on Fly.io. Please note that you need to replace <random_string_at_least_32_characters_long>, <url_of_where_client_will_be_deployed>, and <url_of_where_server_will_be_deployed> with actual values. For more detailed instructions, you can refer to the Wasp documentation (https://wasp-lang.dev/docs/advanced/deployment/manually#set-up-a-flyio-app). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @ArDev, 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?
ArDev
ArDev3d ago
@kapa.ai will that only deploy server?
kapa.ai
kapa.ai3d ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- Yes, the steps provided will only deploy the server to Fly.io. The wasp build command generates the necessary code for the whole app, but the flyctl deploy command in this context is used to deploy only the server part of your Wasp app. However, please note that the server still needs to know the URLs of the client and itself (for CORS settings), which is why you need to set the WASP_WEB_CLIENT_URL and WASP_SERVER_URL environment variables. These URLs don't have to be on Fly.io - they can be anywhere your client and server will be accessible from. Also, remember that the server will need a database to function properly. If you're not setting up a database on Fly.io, you'll need to provide the server with a DATABASE_URL environment variable pointing to a reachable database. For more information, you can refer to the Wasp documentation (https://wasp-lang.dev/docs/advanced/deployment/manually#set-up-a-flyio-app). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @ArDev, 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?
ArDev
ArDev2d ago
@kapa.ai i deployed to fly.io just the server and when i clikc on the url it says it cant handle the request
kapa.ai
kapa.ai2d ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- The server deployed on Fly.io is designed to handle API requests, not to serve the client-side of your application directly. If you're trying to access the server URL directly in a web browser, you'll likely see an error because the server is not set up to handle such requests. If you have a separate client application (like a React app), it should make requests to the server's API endpoints. The server will then respond to these API requests. If you want to serve your client-side application from the same server, you'll need to build your client-side code and serve it from the server. This is typically done in a Node.js server using Express's express.static middleware to serve the static files. However, in the context of a Wasp application, the client and server are typically deployed separately. The client is a React application that can be deployed to any static file host, and the server is a Node.js API server. If you want to access your server's API endpoints, you can use tools like curl or Postman to send requests to the server. For example, if you have a /api/users endpoint, you can access it by sending a request to <https://your-fly-app-url/api/users.> For more information on deploying Wasp applications, you can refer to the Wasp deployment documentation (https://wasp-lang.dev/docs/advanced/deployment/cli). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @ArDev, 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?
ArDev
ArDev2d ago
Environment variable not found: DATABASE_URL. @kapa.ai
kapa.ai
kapa.ai2d ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- The error message you're seeing indicates that the DATABASE_URL environment variable is not found. This environment variable is required for your Wasp application to connect to a database. Here's how you can set it: 1. In your local environment: You can set the DATABASE_URL environment variable in your local environment by adding it to the .env.server file in the root directory of your Wasp project. If the file doesn't exist, create it. The value of DATABASE_URL should be the connection string to your database. For example:
DATABASE_URL=postgresql://mydbuser:mypass@localhost:5432/nameofmydb
DATABASE_URL=postgresql://mydbuser:mypass@localhost:5432/nameofmydb
2. In your Fly.io app: If you're deploying your app to Fly.io, you can set the DATABASE_URL environment variable using the flyctl secrets set command:
flyctl secrets set DATABASE_URL=postgresql://mydbuser:mypass@localhost:5432/nameofmydb
flyctl secrets set DATABASE_URL=postgresql://mydbuser:mypass@localhost:5432/nameofmydb
Replace postgresql://mydbuser:mypass@localhost:5432/nameofmydb with your actual database connection string. Remember to restart your server after setting the environment variable so it can pick up the new value. For more information, you can refer to the Wasp documentation on environment variables (https://wasp-lang.dev/docs/advanced/deployment/manually#environment-variables) and the Wasp documentation on connecting to a database (https://wasp-lang.dev/docs/data-model/backends#connecting-to-a-database). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @ArDev, 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?
ArDev
ArDev2d ago
@kapa.ai
kapa.ai
kapa.ai2d ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- The error messages you're seeing indicate that the Fly.io proxy is unable to connect to your application because it's not listening on the correct IP address and port. Specifically, it's looking for your app on 0.0.0.0:8080, but it seems your app might be listening on 127.0.0.1:8080 instead. Here's what you can do to fix this: 1. Check your server's listening address: Ensure that your server is set to listen on 0.0.0.0 and not 127.0.0.1. The address 0.0.0.0 means "all IPv4 addresses on the local machine". If a server is set to listen on 0.0.0.0, it will be reachable at all network interfaces, including the public one that Fly.io uses to route external traffic to your app. 2. Check your server's listening port: Make sure your server is listening on port 8080. This is the port you've set in the PORT environment variable. 3. Check your startup logs: As the error message suggests, check your server's startup logs. Servers often print the address and port they're listening on when they start up. This can help you verify whether your server is listening on the correct address and port. 4. Check your Fly.io configuration: Make sure your fly.toml file and any other Fly.io configuration are correctly set up. In particular, check that the services section of your fly.toml file is correctly configured to route incoming requests to your app. If you're still encountering issues, it might be helpful to provide more information about your server setup and any relevant code or configuration files. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @ArDev, 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?
ArDev
ArDev2d ago
@kapa.ai where do i get the jwt secret? how do i get it from supabas
kapa.ai
kapa.ai2d ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- The JWT secret is a key used for signing and verifying JWT tokens. It's not something you get from Supabase or any other service, but rather something you generate yourself and keep secret. Here's how you can generate a JWT secret: 1. Generate a random string: The JWT secret can be any string, but it should be long and random to ensure security. You can generate a random string in many ways. For example, in a Unix-based system, you can use the following command to generate a 32-character random string:
openssl rand -base64 32
openssl rand -base64 32
2. Set the JWT secret as an environment variable: Once you have your JWT secret, you need to set it as an environment variable in your server environment. If you're deploying your app to Fly.io, you can set the JWT_SECRET environment variable using the flyctl secrets set command:
flyctl secrets set JWT_SECRET=<your_jwt_secret>
flyctl secrets set JWT_SECRET=<your_jwt_secret>
Replace <your_jwt_secret> with the actual JWT secret you generated. Remember to never expose your JWT secret publicly, as it can be used to forge JWT tokens and impersonate users. For more information, you can refer to the Wasp documentation on environment variables (https://wasp-lang.dev/docs/advanced/deployment/manually#environment-variables). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @ArDev, 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?
ArDev
ArDev2d ago
WARNING The app is not listening on the expected address and will not be reachable by fly-proxy. You can fix this by configuring your app to listen on the following addresses: - 0.0.0.0:8080d lease for 5683040b540698 @kapa.ai how to do this?
kapa.ai
kapa.ai2d ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- The warning message you're seeing indicates that your application is not listening on the expected IP address (0.0.0.0) and port (8080). This is required for your application to be reachable by the Fly.io proxy. Here's how you can configure your application to listen on 0.0.0.0:8080: 1. Update your server code: In your server code, where you start your server, ensure that you're setting it to listen on 0.0.0.0 and port 8080. The exact code to do this will depend on the server framework you're using. For example, if you're using Express.js, you might have code like this:
app.listen(8080, '0.0.0.0', () => {
console.log('Server is listening on 0.0.0.0:8080');
});
app.listen(8080, '0.0.0.0', () => {
console.log('Server is listening on 0.0.0.0:8080');
});
2. Set the PORT environment variable: Ensure that the PORT environment variable is set to 8080 in your Fly.io app. You can do this with the flyctl secrets set command:
flyctl secrets set PORT=8080
flyctl secrets set PORT=8080
3. Check your Fly.io configuration: Make sure your fly.toml file and any other Fly.io configuration are correctly set up. In particular, check that the services section of your fly.toml file is correctly configured to route incoming requests to your app. After making these changes, redeploy your application and it should now be reachable by the Fly.io proxy. For more information, you can refer to the Wasp documentation on deploying to Fly.io (https://wasp-lang.dev/docs/advanced/deployment/manually#set-up-a-flyio-app). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @ArDev, 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?
ArDev
ArDev2d ago
instance refused connection. is your app listening on 0.0.0.0:8080? 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) @kapa.ai how to look at startup logds
kapa.ai
kapa.ai2d ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- To view the startup logs of your application deployed on Fly.io, you can use the flyctl logs command. This command streams the logs from your running app. Here's how you can use it: 1. Open a terminal. 2. Run the following command:
flyctl logs --app <app-name>
flyctl logs --app <app-name>
Replace <app-name> with the name of your Fly.io app. This command will start streaming the logs from your app. You should be able to see the startup logs, including any messages printed when your server starts up. For more information, you can refer to the Fly.io documentation on viewing logs (https://fly.io/docs/getting-started/logs/). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @ArDev, 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?
ArDev
ArDev2d ago
painpoint.pro/:1 Access to XMLHttpRequest at has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. @kapa.ai
kapa.ai
kapa.ai2d ago
Let me check the knowledge base for you again. One moment! :books:
MEE6
MEE62d ago
Wohooo @ArDev, you just became a Waspeteer level 9!
kapa.ai
kapa.ai2d ago
---------------------- The error message you're seeing is related to Cross-Origin Resource Sharing (CORS). CORS is a security feature that restricts how resources on a web page can be requested from another domain. In your case, it seems like your server at 'https://painpointpro.fly.dev' is not set up to accept requests from your client at 'https://painpoint.pro'. Here's how you can fix this: 1. Set up CORS in your Wasp app: Wasp allows you to configure CORS by defining custom middleware for your APIs in the Wasp file. You can do this by using the apiNamespace declaration to apply a middlewareConfigFn to all APIs under a specific path. Here's an example:
// main.wasp
apiNamespace fooBar {
middlewareConfigFn: import { fooBarNamespaceMiddlewareFn } from "@src/apis",
path: "/foo"
}

// src/apis.js
export const apiMiddleware = (config) => {
return config;
};
// main.wasp
apiNamespace fooBar {
middlewareConfigFn: import { fooBarNamespaceMiddlewareFn } from "@src/apis",
path: "/foo"
}

// src/apis.js
export const apiMiddleware = (config) => {
return config;
};
In this example, the apiMiddleware function is returning the default middleware, which enables CORS for all APIs under the /foo path. For more information, you can refer to the Wasp documentation on enabling CORS (https://wasp-lang.dev/docs/advanced/apis#making-sure-cors-works). 2. Set the WASP_WEB_CLIENT_URL environment variable: You need to set this environment variable to the URL of your client app. This is used to keep the CORS configuration up to date. You can do this with the flyctl secrets set command:
flyctl secrets set WASP_WEB_CLIENT_URL=<https://painpoint.pro>
flyctl secrets set WASP_WEB_CLIENT_URL=<https://painpoint.pro>
After making these changes, redeploy your application and it should now accept requests from your client at 'https://painpoint.pro'. For more information, you can refer to the Wasp documentation on using a custom domain for your app (https://wasp-lang.dev/docs/advanced/deployment/cli#using-a-custom-domain-for-your-app). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @ArDev, 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
miho23h ago
Is there something that a human can help you with?
ArDev
ArDev17h ago
@miho I am getting cors issues when deploying to fly.io which is weird because i am migrating my deployment from railway to fly.io (the server) my client is the same on netlify 2024-10-21T16:39:57.507 proxy[3d8ddedb396d58] lhr [error] [PC01] instance refused connection. is your app listening on 0.0.0.0:8080? 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) 2024-10-21T16:39:57.532 proxy[e286033c440e58] lhr [error] [PC01] instance refused connection. is your app listening on 0.0.0.0:8080? 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) i get this
ArDev
ArDev17h ago
Deploying Manually | Wasp
This document explains how to build and prepare your Wasp app for deployment.
ArDev
ArDev16h ago
ok got it fixed!!!!!!!!!!!!!!!!!!!!!!! - https://discord.com/channels/686873244791210014/1250831665995972729 this solved it ^
miho
miho2h ago
So it was a database issue after all?
Want results from more Discord servers?
Add your server