Quick Start
This guide will walk you through quickly deploying CAT Next Generation using Docker Compose, allowing you to easily manage both CAT and MySQL 8 containers.
1. Prerequisites
Make sure your system meets the following requirements:
- Docker: Required for containerized deployment.
- Docker Compose: To manage multi-container applications.
If Docker Compose is not installed, you can install it with the following command:
sudo apt update
sudo apt install docker-compose -y
2. Quick Installation Steps
2.1 Create docker-compose.yml
File
First, create a docker-compose.yml
file in your project directory with the following content:
version: '3'
services:
mysql:
image: mysql:8
container_name: cat-mysql
environment:
MYSQL_ROOT_PASSWORD: rootpassword
MYSQL_DATABASE: cat
MYSQL_USER: cat_user
MYSQL_PASSWORD: cat_password
ports:
- "3306:3306"
volumes:
- mysql-data:/var/lib/mysql
networks:
- cat-network
cat-server:
build: .
container_name: cat-server
ports:
- "8080:8080"
environment:
JAVA_OPTS: "-Xms512m -Xmx1024m"
depends_on:
- mysql
networks:
- cat-network
volumes:
mysql-data:
networks:
cat-network:
2.2 Create a Dockerfile (CAT Service)
In the same directory, create a Dockerfile
for building the CAT service Docker image:
FROM eclipse-temurin:17-jre
WORKDIR /app
COPY cat-home/target/cat.jar /app/cat.jar
EXPOSE 8080
CMD ["java", "-jar", "/app/cat.jar"]
2.3 Start the Services
In the directory containing your docker-compose.yml
, run the following command to start CAT and MySQL:
docker-compose up -d
This command starts both MySQL and CAT services in the background. Use docker-compose logs -f
to monitor logs and ensure the services are running smoothly.
2.4 Initialize the Database
To initialize the CAT database, enter the MySQL container:
docker exec -it cat-mysql mysql -u cat_user -p
Then, run the CAT SQL initialization script:
USE cat;
SOURCE /path/to/cat-home/scripts/cat.sql;
This will set up the necessary database schema for CAT.
3. Access the CAT Console
Once the CAT container is running successfully, access the CAT management console via your browser:
http://<your-server-ip>:8080
4. Common Commands
- Start Services:
docker-compose up -d
- Stop Services:
docker-compose down
- View Logs:
docker-compose logs -f
- Rebuild Containers:
docker-compose up --build
5. Summary
With Docker Compose, you can easily manage the containerized deployment of CAT and MySQL, simplifying the process of starting, configuring, and managing multi-container applications. This method is ideal for quickly launching and scaling CAT systems with minimal overhead.