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.
117 lines
2.7 KiB
Markdown
117 lines
2.7 KiB
Markdown
# Docker Setup for Digital Twin Monitoring Application
|
|
|
|
This folder contains Docker configuration files for deploying the Digital Twin Monitoring application in a production environment.
|
|
|
|
## Files
|
|
|
|
- `Dockerfile`: Defines how to build the application container
|
|
- `docker-compose.yml`: Defines the services and their configurations
|
|
|
|
## Prerequisites
|
|
|
|
- Docker and Docker Compose installed on your production server
|
|
- Access to PostgreSQL databases (configured in environment variables)
|
|
|
|
## Deployment Instructions
|
|
|
|
### Option 1: Using Docker Compose (Recommended)
|
|
|
|
1. Copy the entire project to your production server
|
|
2. Navigate to the project root directory
|
|
3. Make sure your `.env` file is properly configured with:
|
|
- `TELEGRAM_BOT_TOKEN`
|
|
- `TELEGRAM_CHAT_ID`
|
|
- Database connection details (optional, defaults are provided)
|
|
4. Run the following command:
|
|
|
|
```bash
|
|
cd Docker
|
|
docker-compose up -d
|
|
```
|
|
|
|
This will:
|
|
- Build the Docker image using the Dockerfile
|
|
- Start the container in detached mode
|
|
- Map port 5003 to the host
|
|
- Configure environment variables
|
|
- Set up restart policies
|
|
|
|
### Option 2: Using Docker Directly
|
|
|
|
If you prefer to use Docker without Docker Compose:
|
|
|
|
1. Copy the entire project to your production server
|
|
2. Navigate to the project root directory
|
|
3. Build the Docker image:
|
|
|
|
```bash
|
|
docker build -t digital-twin-monitoring -f Docker/Dockerfile .
|
|
```
|
|
|
|
4. Run the container:
|
|
|
|
```bash
|
|
docker run -d \
|
|
--name digital-twin-app \
|
|
-p 5003:5003 \
|
|
-e DB_HOST_1=192.168.1.85 \
|
|
-e DB_HOST_2=192.168.1.86 \
|
|
-e DB_PORT=5432 \
|
|
-e DB_USER=postgres \
|
|
-e DB_PASS=postgres \
|
|
-e DB_NAME=digital_twin \
|
|
-e TELEGRAM_BOT_TOKEN=your_token \
|
|
-e TELEGRAM_CHAT_ID=your_chat_id \
|
|
--restart unless-stopped \
|
|
digital-twin-monitoring
|
|
```
|
|
|
|
Replace `your_token` and `your_chat_id` with your actual Telegram credentials.
|
|
|
|
## Accessing the Application
|
|
|
|
Once deployed, the application will be available at:
|
|
|
|
```
|
|
http://your-server-ip:5003
|
|
```
|
|
|
|
## Maintenance
|
|
|
|
### Viewing Logs
|
|
|
|
```bash
|
|
# Using Docker Compose
|
|
docker-compose logs -f
|
|
|
|
# Using Docker directly
|
|
docker logs -f digital-twin-app
|
|
```
|
|
|
|
### Stopping the Application
|
|
|
|
```bash
|
|
# Using Docker Compose
|
|
docker-compose down
|
|
|
|
# Using Docker directly
|
|
docker stop digital-twin-app
|
|
docker rm digital-twin-app
|
|
```
|
|
|
|
### Updating the Application
|
|
|
|
1. Pull the latest code changes
|
|
2. Rebuild and restart:
|
|
|
|
```bash
|
|
# Using Docker Compose
|
|
docker-compose down
|
|
docker-compose up -d --build
|
|
|
|
# Using Docker directly
|
|
docker stop digital-twin-app
|
|
docker rm digital-twin-app
|
|
docker build -t digital-twin-monitoring -f Docker/Dockerfile .
|
|
# Then run the container again with the same parameters as above
|
|
``` |