# Docker Usage

The default compose file pulls the image from the Gitea Container Registry:

```powershell
docker compose pull
docker compose up -d
```

Default image:

```text
gitea.mouse84.com/kim.kanghee/idrac-info:latest
```

Use a specific image tag:

```powershell
$env:IDRAC_INFO_IMAGE = "gitea.mouse84.com/kim.kanghee/idrac-info:<commit-sha>"
docker compose pull
docker compose up -d
```

Build locally instead of pulling:

```powershell
docker compose -f docker-compose.yml -f docker-compose.build.yml up --build -d
```

Build only:

```powershell
docker build -t gitea.mouse84.com/kim.kanghee/idrac-info:local .
```

Run the pulled image without Compose:

```powershell
docker run --rm --network host `
  -e FLASK_PORT=6050 `
  -e APP_DATA_DIR=/app/data `
  -e AUTO_BOOTSTRAP_DB=true `
  -v ${PWD}/backend/instance:/app/backend/instance `
  gitea.mouse84.com/kim.kanghee/idrac-info:latest
```

Open the app:

```text
http://localhost:6050
```

The compose service uses host networking:

```yaml
network_mode: "host"
```

Because of that, `ports:` mappings are not used. Change `FLASK_PORT` if another
process already uses `6050` on the host.

Run in the background:

```powershell
docker compose up -d
```

Stop the container:

```powershell
docker compose down
```

View logs:

```powershell
docker compose logs -f idrac-info
```

## Persistent Data

The image includes the committed `data` directory, including scripts and
server-list files, so the default compose file does not mount `./data` over
`/app/data`.

The compose file only mounts the Flask instance directory:

```text
./backend/instance  -> /app/backend/instance
```

This preserves the default SQLite database and other instance files across
container restarts.

## Environment

The container defaults to port `6050`. To use a different host port:

```powershell
$env:FLASK_PORT = "8080"
docker compose up -d
```

Then open:

```text
http://localhost:8080
```

Common variables:

```text
SECRET_KEY=change-me
AUTO_BOOTSTRAP_DB=true
REDFISH_VERIFY_SSL=false
REDFISH_TIMEOUT=15
TELEGRAM_BOT_TOKEN=
TELEGRAM_CHAT_ID=
```

## Notes

The image is based on Ubuntu 24.04 and installs Dell iDRAC Tools from the local
`iDRACTools` directory during image build. It also copies the committed `data`
directory into `/app/data` during image build:

```text
iDRACTools/racadm/UBUNTU24/x86_64/*.deb
iDRACTools/ipmitool/UBUNTU24_x86_64/*.deb
data/ -> /app/data
```

`racadm` is expected on:

```text
/opt/dell/srvadmin/sbin/racadm
```

The Dockerfile adds `/opt/dell/srvadmin/sbin` to `PATH`, so existing scripts can
call `racadm` directly.

After building, verify the tools inside the image:

```powershell
docker run --rm gitea.mouse84.com/kim.kanghee/idrac-info:latest sh -lc "command -v racadm && command -v ipmitool && ipmitool -V"
```

## Registry

Gitea Actions builds and pushes these tags on `main`:

```text
gitea.mouse84.com/kim.kanghee/idrac-info:latest
gitea.mouse84.com/kim.kanghee/idrac-info:<short-sha>
```

If the package is private, log in before pulling:

```powershell
docker login gitea.mouse84.com
```

Host networking works as expected on Linux Docker hosts. Docker Desktop on
Windows can behave differently, so production deployment should use a Linux host
or runner when direct access to the iDRAC network is required.
