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.
127 lines
2.8 KiB
Markdown
127 lines
2.8 KiB
Markdown
# Docker Setup for Digital Twin Monitoring
|
|
|
|
This document provides instructions for setting up and running the Digital Twin Monitoring application using Docker.
|
|
|
|
## Prerequisites
|
|
|
|
- Ubuntu server
|
|
- Internet connection
|
|
- Basic knowledge of terminal commands
|
|
|
|
## Quick Start
|
|
|
|
The easiest way to get started is to run the provided installation script:
|
|
|
|
```bash
|
|
chmod +x install.sh
|
|
./install.sh
|
|
```
|
|
|
|
This script will:
|
|
1. Check if Docker is installed and install it if needed
|
|
2. Build the Docker image
|
|
3. Stop any existing containers with the same name
|
|
4. Start a new container with the application
|
|
|
|
Alternatively, you can use Docker Compose:
|
|
|
|
```bash
|
|
cd Docker
|
|
docker compose up -d
|
|
```
|
|
|
|
After running either method, the application will be available at `http://[server-ip]:5003`.
|
|
|
|
## Manual Setup
|
|
|
|
If you prefer to set up manually, follow these steps:
|
|
|
|
### 1. Build the Docker image
|
|
|
|
```bash
|
|
docker build -t digital-twin-monitoring -f Docker/Dockerfile .
|
|
```
|
|
|
|
### 2. Run the Docker container
|
|
|
|
```bash
|
|
docker run -d \
|
|
--name digital-twin-monitoring \
|
|
--restart unless-stopped \
|
|
-p 5003:5003 \
|
|
--env-file .env \
|
|
digital-twin-monitoring
|
|
```
|
|
|
|
## Environment Variables
|
|
|
|
The application uses the following environment variables from the `.env` file:
|
|
|
|
- `TELEGRAM_BOT_TOKEN`: Token for Telegram bot notifications
|
|
- `TELEGRAM_CHAT_ID`: Chat ID for Telegram notifications
|
|
- `DB_HOST_1`: PostgreSQL host for tables: pf_parts, ms_equipment_master
|
|
- `DB_HOST_2`: PostgreSQL host for table: dl_pi_fetch_last
|
|
- `DB_PORT`: PostgreSQL port
|
|
- `DB_USER`: PostgreSQL username
|
|
- `DB_PASS`: PostgreSQL password
|
|
- `DB_NAME`: PostgreSQL database name
|
|
|
|
Make sure your `.env` file is properly configured before running the container.
|
|
|
|
## Maintenance
|
|
|
|
### Viewing logs
|
|
|
|
```bash
|
|
docker logs digital-twin-monitoring
|
|
```
|
|
|
|
### Stopping the container
|
|
|
|
```bash
|
|
docker stop digital-twin-monitoring
|
|
```
|
|
|
|
### Restarting the container
|
|
|
|
```bash
|
|
docker restart digital-twin-monitoring
|
|
```
|
|
|
|
### Removing the container
|
|
|
|
```bash
|
|
docker stop digital-twin-monitoring
|
|
docker rm digital-twin-monitoring
|
|
```
|
|
|
|
### Updating the application
|
|
|
|
#### Using Docker Compose (Recommended)
|
|
|
|
To update the application using Docker Compose, simply pull the latest code and restart the services:
|
|
|
|
```bash
|
|
git pull
|
|
cd Docker
|
|
docker compose up -d
|
|
```
|
|
|
|
This will automatically rebuild the image if needed and restart the container with the updated code.
|
|
|
|
#### Using Docker Commands
|
|
|
|
Alternatively, you can update using individual Docker commands:
|
|
|
|
```bash
|
|
git pull
|
|
docker build -t digital-twin-monitoring -f Docker/Dockerfile .
|
|
docker stop digital-twin-monitoring
|
|
docker rm digital-twin-monitoring
|
|
docker run -d \
|
|
--name digital-twin-monitoring \
|
|
--restart unless-stopped \
|
|
-p 5003:5003 \
|
|
--env-file .env \
|
|
digital-twin-monitoring
|
|
``` |