Containerization
This commit is contained in:
@@ -1,14 +1,12 @@
|
||||
---
|
||||
|
||||
# Setup
|
||||
|
||||
This guide provides instructions on how to set up and run the Python application in a virtual environment.
|
||||
This guide provides instructions on how to set up and run the application.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Ensure you have the following installed on your system:
|
||||
- Python 3.x
|
||||
- pip (Python package installer)
|
||||
- **Docker**: Install Docker from [docker.com](https://www.docker.com/get-started)
|
||||
- **Docker Compose**: Docker Compose is included with Docker Desktop (for macOS/Windows) or can be installed separately on Linux.
|
||||
|
||||
## Steps to Set Up the Application
|
||||
|
||||
@@ -21,52 +19,38 @@ git clone https://github.com/username/repository.git
|
||||
cd repository
|
||||
```
|
||||
|
||||
### 2. Create a Virtual Environment
|
||||
### 2. Run the Application with Docker Compose
|
||||
|
||||
Create a virtual environment to isolate your dependencies:
|
||||
Once you have the repository cloned, you can easily set up and run the application using Docker Compose. Simply execute the following command:
|
||||
|
||||
```bash
|
||||
python3 -m venv venv
|
||||
docker-compose up --build
|
||||
```
|
||||
|
||||
### 3. Activate the Virtual Environment
|
||||
This command will build the Docker image and start the Flask application in a container. By default, the application will be accessible at `http://localhost:5000`.
|
||||
|
||||
Activate the virtual environment:
|
||||
### 3. Health Check
|
||||
|
||||
- **For Windows:**
|
||||
```bash
|
||||
venv\Scripts\activate
|
||||
```
|
||||
|
||||
- **For macOS/Linux:**
|
||||
```bash
|
||||
source venv/bin/activate
|
||||
```
|
||||
|
||||
Once activated, you should see `(venv)` at the beginning of your terminal prompt.
|
||||
|
||||
### 4. Install Dependencies
|
||||
|
||||
Install the required dependencies listed in `requirements.txt`:
|
||||
You can check if the Flask application is running by accessing the `/health` endpoint. To perform a health check, run the following command:
|
||||
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
curl http://localhost:5000/health
|
||||
```
|
||||
|
||||
### 5. Run the Application
|
||||
If the application is running properly, you should receive a response similar to this:
|
||||
|
||||
Start the application:
|
||||
```json
|
||||
{
|
||||
"status": "ok"
|
||||
}
|
||||
```
|
||||
|
||||
### 4. Stop the Application
|
||||
|
||||
To stop the application, use:
|
||||
|
||||
```bash
|
||||
flask run
|
||||
docker-compose down
|
||||
```
|
||||
|
||||
|
||||
|
||||
### 6. Deactivate the Virtual Environment
|
||||
|
||||
When you're done, deactivate the virtual environment:
|
||||
|
||||
```bash
|
||||
deactivate
|
||||
```
|
||||
This will stop and remove the containers created by Docker Compose.
|
||||
|
||||
Reference in New Issue
Block a user