You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
3.0 KiB
Markdown
54 lines
3.0 KiB
Markdown
|
3 days ago
|
Based on the provided `fly.toml` configuration file, here's a deployment guide for your `esp32-temp-chart` application on Fly.io. This guide assumes that you have already developed a Flask application that is ready to be deployed.
|
||
|
|
|
||
|
|
### Prerequisites
|
||
|
|
|
||
|
|
1. **Fly.io Account**: Ensure you have a Fly.io account. If not, sign up at [Fly.io](https://fly.io/).
|
||
|
|
2. **Fly CLI**: Install the Fly CLI tool. Instructions can be found on the [Fly.io documentation](https://fly.io/docs/hands-on/installing/).
|
||
|
|
3. **Docker**: Your application must be containerized with Docker. Install Docker if it's not already installed.
|
||
|
|
4. **Local Application Code**: Have your Flask application code ready on your local machine.
|
||
|
|
|
||
|
|
### Step-by-Step Deployment Guide
|
||
|
|
|
||
|
|
#### 1. Initialize Your Fly.io Application
|
||
|
|
|
||
|
|
- Navigate to your project directory in the terminal.
|
||
|
|
- Run `flyctl apps create esp32-temp-chart`. This command creates a new application on Fly.io with the name specified in your `fly.toml` file.
|
||
|
|
|
||
|
|
#### 2. Configure the `fly.toml` File
|
||
|
|
|
||
|
|
- Place your `fly.toml` file in the root of your project directory.
|
||
|
|
- Review the `fly.toml` file to ensure all configurations are correct. Particularly, check the `app` name, `primary_region`, and the `http_service` configurations.
|
||
|
|
|
||
|
|
#### 3. Set Up Docker
|
||
|
|
|
||
|
|
- Create a `Dockerfile` in your project root. This file should contain instructions to build a Docker image for your Flask application.
|
||
|
|
- Ensure that your application listens on the port specified in `fly.toml` (8080 in this case).
|
||
|
|
|
||
|
|
#### 4. Test Your Docker Container Locally (Optional)
|
||
|
|
|
||
|
|
- Build your Docker image: `docker build -t esp32-temp-chart .`
|
||
|
|
- Run your container locally to ensure it works: `docker run --rm -p 8080:8080 esp32-temp-chart`
|
||
|
|
- Test the local deployment by navigating to `http://localhost:8080`.
|
||
|
|
|
||
|
|
#### 5. Deploy Your Application
|
||
|
|
|
||
|
|
- From your project directory, run `flyctl deploy`. This command will build your application's Docker image and deploy it to Fly.io.
|
||
|
|
- Monitor the deployment process in your terminal to ensure it completes successfully.
|
||
|
|
|
||
|
|
#### 6. Verify the Deployment
|
||
|
|
|
||
|
|
- Once deployed, you can access your application using the URL provided by Fly.io.
|
||
|
|
- Test the `/ping` endpoint to ensure your application responds correctly.
|
||
|
|
|
||
|
|
#### 7. Monitoring and Management
|
||
|
|
|
||
|
|
- Use `flyctl logs` to view real-time logs from your application.
|
||
|
|
- Use `flyctl status` to check the status of your application.
|
||
|
|
- To scale your application, use `flyctl scale count <number_of_instances>`.
|
||
|
|
|
||
|
|
### Additional Notes
|
||
|
|
|
||
|
|
- The `[[mounts]]` section in `fly.toml` is used to persist data. Ensure the `source` and `destination` are correctly set for your application's data needs.
|
||
|
|
- The `[checks]` section defines health checks for your application. Adjust the `path`, `interval`, and `headers` as needed for your application's health endpoint.
|
||
|
|
|
||
|
|
Remember, always test your application locally before deploying to ensure it's working as expected. If you encounter issues, the Fly.io documentation and community forums are great resources for troubleshooting.
|