Skip to content

Commit

Permalink
#763 - added docker compose files.
Browse files Browse the repository at this point in the history
  • Loading branch information
grabdoc committed Jan 23, 2025
1 parent 186af33 commit d9bca78
Show file tree
Hide file tree
Showing 21 changed files with 391 additions and 0 deletions.
17 changes: 17 additions & 0 deletions docker-compose/mariadb/api-interaction.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

# Wait for services to be fully up
sleep 15

# Base URL for DB2Rest API
BASE_URL="http://localhost/emp/employee"

# Insert an employee
echo "Inserting employee..."
curl -X POST $BASE_URL \
-H "Content-Type: application/json" \
-d '{"name":"Jane Smith"}'

# Query all employees
echo -e "\nQuerying all employees..."
curl -X GET $BASE_URL
40 changes: 40 additions & 0 deletions docker-compose/mariadb/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
version: "3.8"
services:
db2rest-service:
image: kdhrubo/db2rest:latest
ports:
- 80:8080
environment:
DB_URL: "jdbc:mariadb://employee-mariadb:3306/empdb"
DB_USER: "db2rest"
DB_PASSWORD: "db2rest"
INCLUDED_SCHEMAS: public,emp
depends_on:
- employee-mariadb
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/actuator/health"]
interval: 30s
timeout: 10s
retries: 3

employee-mariadb:
image: "mariadb:10.6"
container_name: "employee-mariadb"
ports:
- 3306:3306
environment:
- MYSQL_USER=db2rest
- MYSQL_PASSWORD=db2rest
- MYSQL_DATABASE=empdb
- MYSQL_ROOT_PASSWORD=root
volumes:
- mariadb-data:/var/lib/mysql
- ./init:/docker-entrypoint-initdb.d
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
interval: 20s
timeout: 10s
retries: 5

volumes:
mariadb-data:
11 changes: 11 additions & 0 deletions docker-compose/mariadb/init/01-init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-- Create employee table
CREATE TABLE employee (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL
);

-- Insert sample employee
INSERT INTO employee (name) VALUES ('John Doe');

-- Query to verify data
SELECT * FROM employee;
11 changes: 11 additions & 0 deletions docker-compose/mariadb/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# Start services
docker-compose up -d

# Run API interaction script
chmod +x api-interaction.sh
./api-interaction.sh

# Optional: Keep services running
docker-compose logs -f
17 changes: 17 additions & 0 deletions docker-compose/mysql/api-interaction.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

# Wait for services to be fully up
sleep 15

# Base URL for DB2Rest API
BASE_URL="http://localhost/emp/employee"

# Insert an employee
echo "Inserting employee..."
curl -X POST $BASE_URL \
-H "Content-Type: application/json" \
-d '{"name":"Jane Smith"}'

# Query all employees
echo -e "\nQuerying all employees..."
curl -X GET $BASE_URL
40 changes: 40 additions & 0 deletions docker-compose/mysql/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
version: "3.8"
services:
db2rest-service:
image: kdhrubo/db2rest:latest
ports:
- 80:8080
environment:
DB_URL: "jdbc:mysql://employee-mysql:3306/empdb"
DB_USER: "db2rest"
DB_PASSWORD: "db2rest"
INCLUDED_SCHEMAS: public,emp
depends_on:
- employee-mysql
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/actuator/health"]
interval: 30s
timeout: 10s
retries: 3

employee-mysql:
image: "mysql:8.0"
container_name: "employee-mysql"
ports:
- 3306:3306
environment:
- MYSQL_USER=db2rest
- MYSQL_PASSWORD=db2rest
- MYSQL_DATABASE=empdb
- MYSQL_ROOT_PASSWORD=root
volumes:
- mysql-data:/var/lib/mysql
- ./init:/docker-entrypoint-initdb.d
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
interval: 20s
timeout: 10s
retries: 5

volumes:
mysql-data:
11 changes: 11 additions & 0 deletions docker-compose/mysql/init/01-init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-- Create employee table
CREATE TABLE employee (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL
);

-- Insert sample employee
INSERT INTO employee (name) VALUES ('John Doe');

-- Query to verify data
SELECT * FROM employee;
11 changes: 11 additions & 0 deletions docker-compose/mysql/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# Start services
docker-compose up -d

# Run API interaction script
chmod +x api-interaction.sh
./api-interaction.sh

# Optional: Keep services running
docker-compose logs -f
17 changes: 17 additions & 0 deletions docker-compose/oracle/api-interaction.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

# Wait for services to be fully up
sleep 15

# Base URL for DB2Rest API
BASE_URL="http://localhost/emp/employee"

# Insert an employee
echo "Inserting employee..."
curl -X POST $BASE_URL \
-H "Content-Type: application/json" \
-d '{"name":"Jane Smith"}'

# Query all employees
echo -e "\nQuerying all employees..."
curl -X GET $BASE_URL
39 changes: 39 additions & 0 deletions docker-compose/oracle/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
version: "3.8"
services:
db2rest-service:
image: kdhrubo/db2rest:latest
ports:
- 80:8080
environment:
DB_URL: "jdbc:oracle:thin:@employee-oracle:1521/XE"
DB_USER: "system"
DB_PASSWORD: "oracle"
INCLUDED_SCHEMAS: system
depends_on:
- employee-oracle
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/actuator/health"]
interval: 30s
timeout: 10s
retries: 3

employee-oracle:
image: "gvenzl/oracle-xe:latest"
container_name: "employee-oracle"
ports:
- 1521:1521
environment:
- ORACLE_PASSWORD=oracle
- APP_USER=system
- APP_USER_PASSWORD=oracle
volumes:
- oracle-data:/opt/oracle/oradata
- ./init:/container-entrypoint-initdb.d
healthcheck:
test: ["CMD", "/bin/bash", "-c", "echo 'SELECT 1 FROM DUAL;' | sqlplus -s system/oracle@localhost/XE"]
interval: 20s
timeout: 10s
retries: 5

volumes:
oracle-data:
11 changes: 11 additions & 0 deletions docker-compose/oracle/init/01-init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-- Create employee table
CREATE TABLE employee (
id NUMBER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
name VARCHAR2(100) NOT NULL
);

-- Insert sample employee
INSERT INTO employee (name) VALUES ('John Doe');

-- Query to verify data
SELECT * FROM employee;
11 changes: 11 additions & 0 deletions docker-compose/oracle/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# Start services
docker-compose up -d

# Run API interaction script
chmod +x api-interaction.sh
./api-interaction.sh

# Optional: Keep services running
docker-compose logs -f
17 changes: 17 additions & 0 deletions docker-compose/postgresql/api-interaction.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

# Wait for services to be fully up
sleep 15

# Base URL for DB2Rest API
BASE_URL="http://localhost/emp/employee"

# Insert an employee
echo "Inserting employee..."
curl -X POST $BASE_URL \
-H "Content-Type: application/json" \
-d '{"name":"Jane Smith"}'

# Query all employees
echo -e "\nQuerying all employees..."
curl -X GET $BASE_URL
18 changes: 18 additions & 0 deletions docker-compose/postgresql/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ services:
DB_USER: "db2rest"
DB_PASSWORD: "db2rest"
INCLUDED_SCHEMAS: public,emp
depends_on:
- employee-postgres
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/actuator/health"]
interval: 30s
timeout: 10s
retries: 3

employee-postgres:
image: "postgres:14.4"
Expand All @@ -19,3 +26,14 @@ services:
- POSTGRES_USER=db2rest
- POSTGRES_PASSWORD=db2rest
- POSTGRES_DB=empdb
volumes:
- postgres-data:/var/lib/postgresql/data
- ./init:/docker-entrypoint-initdb.d
healthcheck:
test: ["CMD-SHELL", "pg_isready -U db2rest"]
interval: 20s
timeout: 10s
retries: 5

volumes:
postgres-data:
11 changes: 11 additions & 0 deletions docker-compose/postgresql/init/01-init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-- Create employee table
CREATE TABLE employee (
id SERIAL PRIMARY KEY,
name VARCHAR(100) NOT NULL
);

-- Insert sample employee
INSERT INTO employee (name) VALUES ('John Doe');

-- Query to verify data
SELECT * FROM employee;
11 changes: 11 additions & 0 deletions docker-compose/postgresql/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# Start services
docker-compose up -d

# Run API interaction script
chmod +x api-interaction.sh
./api-interaction.sh

# Optional: Keep services running
docker-compose logs -f
17 changes: 17 additions & 0 deletions docker-compose/sqlserver/api-interaction.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

# Wait for services to be fully up
sleep 15

# Base URL for DB2Rest API
BASE_URL="http://localhost/emp/employee"

# Insert an employee
echo "Inserting employee..."
curl -X POST $BASE_URL \
-H "Content-Type: application/json" \
-d '{"name":"Jane Smith"}'

# Query all employees
echo -e "\nQuerying all employees..."
curl -X GET $BASE_URL
38 changes: 38 additions & 0 deletions docker-compose/sqlserver/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
version: "3.8"
services:
db2rest-service:
image: kdhrubo/db2rest:latest
ports:
- 80:8080
environment:
DB_URL: "jdbc:sqlserver://employee-sqlserver:1433;databaseName=empdb"
DB_USER: "sa"
DB_PASSWORD: "Strong@Password123"
INCLUDED_SCHEMAS: dbo
depends_on:
- employee-sqlserver
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/actuator/health"]
interval: 30s
timeout: 10s
retries: 3

employee-sqlserver:
image: "mcr.microsoft.com/mssql/server:2019-latest"
container_name: "employee-sqlserver"
ports:
- 1433:1433
environment:
- SA_PASSWORD=Strong@Password123
- ACCEPT_EULA=Y
volumes:
- sqlserver-data:/var/opt/mssql
- ./init:/docker-entrypoint-initdb.d
healthcheck:
test: ["CMD-SHELL", "/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P Strong@Password123 -Q 'SELECT 1'"]
interval: 20s
timeout: 10s
retries: 5

volumes:
sqlserver-data:
11 changes: 11 additions & 0 deletions docker-compose/sqlserver/init/01-init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-- Create employee table
CREATE TABLE employee (
id INT IDENTITY(1,1) PRIMARY KEY,
name NVARCHAR(100) NOT NULL
);

-- Insert sample employee
INSERT INTO employee (name) VALUES ('John Doe');

-- Query to verify data
SELECT * FROM employee;
11 changes: 11 additions & 0 deletions docker-compose/sqlserver/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# Start services
docker-compose up -d

# Run API interaction script
chmod +x api-interaction.sh
./api-interaction.sh

# Optional: Keep services running
docker-compose logs -f
Loading

0 comments on commit d9bca78

Please sign in to comment.