#!/bin/bash
set -e

cd "$(dirname "$0")"

BASE_IMAGE=jobarg-server-base
BASE_TAG=rhel9
COMMON_TAG=rhel9-6.2.2

MARIA_IMAGE=jobarg-server-maria
MYSQL_IMAGE=jobarg-server-mysql
PGSQL_IMAGE=jobarg-server-postgres

### 1. Build base image
docker build -f Dockerfile -t ${BASE_IMAGE}:${BASE_TAG} .

### 2. Build Docker Maria image (FROM base)
docker build -f ./db/maria/Dockerfile.maria -t ${MARIA_IMAGE}:${COMMON_TAG} .

### 3. Build Docker MySQL image (FROM base)
docker build -f ./db/mysql/Dockerfile.mysql -t ${MYSQL_IMAGE}:${COMMON_TAG} .

### 4. Build Docker PostgreSQL image (FROM base)
docker build -f ./db/postgres/Dockerfile.postgres -t ${PGSQL_IMAGE}:${COMMON_TAG} .

### 5. Check Successfully done or not 
docker images

echo "Docker images create successfully done."