# JAZ2 Docker Image Development Guide

This repository contains scripts and Dockerfiles required to build **JAZ2 (Job Arranger Server)** Docker images for different database backends.

Supported databases:

- MariaDB
- MySQL
- PostgreSQL

---

# Table of Contents

- [Prerequisites](#prerequisites)
- [Project Structure](#project-structure)
- [Build Docker Images](#build-docker-images)
- [Verify Built Images](#verify-built-images)
- [Generate Distribution Package](#generate-distribution-package)
- [Verify Generated Packages](#verify-generated-packages)
- [Provide Images to Testers](#provide-images-to-testers)
- [Cleanup](#cleanup)
- [Version Update](#version-update)
- [Configuration Updates](#configuration-updates)
- [Database Client Fixes](#database-client-fixes)
- [Main Docker Container Fix](#main-docker-container-fix)

---

# Prerequisites

Before building the Docker images, ensure the following:

- Docker is **installed and running**
- You have the correct **EL9 RPM package**

## RPM Requirements

The RPM file must:

- Be built for **EL9**
- Be placed in the **`jobarg_server` root directory**
- Be located at the **same directory level as `build.sh`**

---

# Project Structure

Example directory structure:

```text
jobarg_server/
│
├── artifacts/
│   ├── epel-release-9-10.el9.noarch.rpm
│   ├── mariadb_repo_setup
│   ├── mysql84-community-release-el9.rpm
│   ├── pgdg-redhat-repo-latest.noarch.rpm
│   ├── tini
│   └── zabbix-release-latest-8.0.el9.noarch.rpm
│
├── db/
│   ├── maria/
│   │   ├── docker-build-maria.sh
│   │   └── Dockerfile.maria
│   │
│   ├── mysql/
│   │   ├── docker-build-mysql.sh
│   │   └── Dockerfile.mysql
│   │
│   └── postgres/
│       ├── docker-build-postgres.sh
│       └── Dockerfile.postgres
│
├── entrypoint/
│   ├── docker-entrypoint-maria.sh
│   ├── docker-entrypoint-mysql.sh
│   ├── docker-entrypoint-postgres.sh
│   └── docker-entrypoint.sh
│
├── build.sh
├── Dockerfile
├── generate_tar.gz.sh
├── jobarranger-server-<version>.el9.x86_64.rpm
├── remove.sh
└── README.md
```

---

# Build Docker Images

Run the following command to build **all Docker images**:

```bash
./build.sh
```

---

# Verify Built Images

To confirm that Docker images were successfully built:

```bash
docker images
```

---

# Generate Distribution Package

Create compressed Docker image packages (`.tar.gz`) for testers:

```bash
./generate_tar.gz.sh
```

---

# Verify Generated Packages

Check that the `.tar.gz` files were generated correctly:

```bash
ls -l ./db/maria ./db/mysql ./db/postgres | grep .tar.gz
```

---

# Provide Images to Testers

When providing the **Job Arranger server** to testers:

1. Ask which **database type** they will use.
2. Provide the corresponding package from:

```
db/<db_type>/
```

Example directories:

```
db/maria/
db/mysql/
db/postgres/
```

Provide the following files:

- `docker-build-<dbtype>.sh`
- `jobarg-server-*****.tar.gz`

---

# Cleanup

## Remove All Containers and Images

```bash
./remove.sh
```

## Remove Containers, Images, and `.tar.gz` Files

The `-rt` flag means **remove tar files as well**.

```bash
./remove.sh -rt
```

---

# Version Update

When updating the **Job Arranger version**, update the following files:

- `build.sh`
- `Dockerfile`
- `generate_tar.gz.sh`
- `remove.sh`
- `db/maria/docker-build-maria.sh`
- `db/mysql/docker-build-mysql.sh`
- `db/postgres/docker-build-postgres.sh`

---

# Configuration Updates

## Changes Not Related to Database

Modify:

```bash
docker-entrypoint.sh
```

## Changes Related to Database

Modify the appropriate file:

```bash
docker-entrypoint-maria.sh
docker-entrypoint-mysql.sh
docker-entrypoint-postgres.sh
```

---

# Database Client Fixes

If you need to update database client configurations, modify:

```dockerfile
db/maria/Dockerfile.maria
db/mysql/Dockerfile.mysql
db/postgres/Dockerfile.postgres
```

---

# Main Docker Container Fix

To modify the **main container configuration**, update:

```dockerfile
Dockerfile
```
