# Quick Start Guide

## One-Time Setup

Works with both **Podman** and **Docker** - the scripts auto-detect which one you have installed.

```bash
cd k8s/base-image

# Login to registries
make login            # GitLab registry
make login-dockerhub  # Docker Hub

# Build the base image
make build

# Test it works
make test

# Push to both registries
make push
```

## Update Main Dockerfile

Edit `k8s/Dockerfile`:

```dockerfile
# Change this line:
ARG RUNNER_IMAGE="docker.io/debian:${DEBIAN_VERSION}"

# To this:
ARG RUNNER_IMAGE="registry.gitlab.com/towerops/towerops/elixir-runtime:28.3-elixir-1.19.5-debian-trixie"
```

Remove these lines (already in base image):

```dockerfile
# DELETE THESE:
RUN apt-get update \
    && DEBIAN_FRONTEND=noninteractive apt-get upgrade -y \
    && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
       libstdc++6 openssl libncurses6 locales ca-certificates iputils-ping \
    && rm -rf /var/lib/apt/lists/*

RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen \
    && locale-gen

ENV LANG=en_US.UTF-8
ENV LANGUAGE=en_US:en
ENV LC_ALL=en_US.UTF-8

WORKDIR "/app"
RUN chown nobody /app
```

## Weekly/Monthly Maintenance

```bash
# Rebuild with latest security updates
cd k8s/base-image
make update
make push
```

## Common Commands

```bash
make help          # Show all commands
make build         # Build base image
make test          # Test base image
make push          # Push to registry
make inspect       # Show image details
make clean         # Remove local images
```

## Expected Results

- **Build time**: 2-3 minutes (first time)
- **Image size**: ~150-200 MB
- **CI/CD speedup**: 30-60 seconds saved per build

## Troubleshooting

**Build fails:**
```bash
# Try with verbose output (use podman or docker)
podman build --progress=plain --no-cache -f Dockerfile .
# or
docker build --progress=plain --no-cache -f Dockerfile .
```

**Can't push to registry:**
```bash
# Re-login
make login
make login-dockerhub
```

**Application crashes with missing library:**
```bash
# Add to Dockerfile, then rebuild
RUN apt-get install -y your-package
make build && make push
```
