# ── Docker build & run reference ────────────────────────────────────────────
  # Edit APP_PORT in .env before building/running.
  # The same .env is baked into the image AND passed at runtime so the port is
  # consistent everywhere (Dockerfile EXPOSE, gunicorn --bind, Apache proxy, etc.)

  # Remove old container + image
  docker stop onconvert_container || true
  docker rm   onconvert_container || true
  docker rmi  onlinett            || true

  # Build (picks up .env — including APP_PORT — into the image)
  docker build --no-cache -t onlinett .

  # Run — --env-file overrides any baked-in values at runtime
  # Change APP_PORT in .env and this command stays the same forever.
  APP_PORT=$(grep -E '^APP_PORT=' .env | head -1 | cut -d= -f2)
  APP_PORT=${APP_PORT:-6001}

  docker run -d \
    --name onconvert_container \
    --link redis:redis \
    -p ${APP_PORT}:${APP_PORT} \
    --env-file .env \
    -v /home/username/uploads:/website/uploads \
    -v /home/username/logs:/website/logs \
    -e REDIS_HOST=redis \
    -e REDIS_PORT=6379 \
    -e REDIS_PASSWORD= \
    --restart unless-stopped \
    --cpus=12 --memory=16g --memory-swap=20g \
    onlinett
  