-
Notifications
You must be signed in to change notification settings - Fork 10
feat: Updated for podman support #82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
aneillans
wants to merge
1
commit into
Portabase:main
Choose a base branch
from
aneillans:feat/podman_support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| # ============================================================================= | ||
| # Portabase Agent — local dev environment | ||
| # Copy to `.env` and adjust. `.env` is git-ignored. | ||
| # cp .env.example .env | ||
| # | ||
| # This file is consumed by: | ||
| # - docker compose (variable interpolation, e.g. EDGE_KEY) | ||
| # - the justfile (`set dotenv-load := true` — used by the `seed-*` recipes) | ||
| # ============================================================================= | ||
|
|
||
| # ── Agent → Portabase Server backend ──────────────────────────────────────── | ||
| # Base64 of {"serverUrl","agentId","masterKeyB64"}. Get this from YOUR deployed | ||
| # Portabase Server (Server UI → Agents → your agent → reveal EDGE_KEY). | ||
| # Only needed to run the AGENT (`just up`). Tests do NOT need this. | ||
| # Leave unset to fall back to the sample key baked into docker-compose.yml | ||
| # (targets http://localhost:8887). | ||
| EDGE_KEY= | ||
|
|
||
| # ── Seed targets (host-side; match docker-compose.databases.yml) ───────────── | ||
| # Used only by `just seed-*`. These are host-reachable values. | ||
|
|
||
| # Postgres (service db-postgres) | ||
| PG_CONTAINER=db-postgres | ||
| PG_USER=devuser | ||
| PG_DB=devdb | ||
| PG_PASSWORD=changeme | ||
|
|
||
| # MySQL (service db-mysql, published on host port 3312) | ||
| MYSQL_PORT=3312 | ||
| MYSQL_USER=mysqldb | ||
| MYSQL_PASSWORD=changeme | ||
| MYSQL_DB=mysqldb | ||
|
|
||
| # MSSQL (service db-mssql) | ||
| MSSQL_SA_PASSWORD=Portabase!Strong1 | ||
|
|
||
| # ── Optional: Podman rootless socket ───────────────────────────────────────── | ||
| # If you use rootless Podman, the app-dev-entrypoint.sh sets DOCKER_SOCK for you. | ||
| # Uncomment to override the socket the containers bind-mount as /var/run/docker.sock. | ||
| # DOCKER_SOCK=/run/user/1000/podman/podman.sock |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,15 +11,28 @@ services: | |
| - cargo-git:/usr/local/cargo/git | ||
| - ./databases.json:/config/config.json | ||
| #- ./databases.toml:/config/config.toml | ||
| - /var/run/docker.sock:/var/run/docker.sock | ||
| - ${DOCKER_SOCK:-/var/run/docker.sock}:/var/run/docker.sock | ||
| # - cargo-target:/app/target | ||
| - databases_sqlite-data:/sqlite-data/workspace/data | ||
| - ./scripts/sqlite/test-db:/sqlite-data-2/workspace/data | ||
| environment: | ||
| APP_ENV: development | ||
| LOG: debug | ||
| TZ: "Europe/Paris" | ||
| EDGE_KEY: "eyJzZXJ2ZXJVcmwiOiJodHRwOi8vbG9jYWxob3N0Ojg4ODciLCJhZ2VudElkIjoiZWZhYTM0YTQtZDY1NC00OGQ3LTgwNDYtNjRkMWExYTA1M2FlIiwibWFzdGVyS2V5QjY0IjoiMUh0djdtWCtYVkJxL0IzUEV2WDlZZjlQeUdVZW5oRHlXemo5THRqNW90WT0ifQ==" | ||
| # Reach the container-local Redis by IP; "localhost" is remapped to the | ||
| # host by the extra_hosts entry below, which would break the connection. | ||
| CELERY_BROKER_URL: "redis://127.0.0.1:65515/" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why? @RambokDev |
||
| # Image used for ephemeral docker-volume backup helpers. The agent can | ||
| # normally auto-detect its own image, but that self-detection relies on | ||
| # Docker-style /proc markers that rootless Podman doesn't expose, so we set | ||
| # it explicitly. Any tiny image works (it's only mounted, never run) and it | ||
| # must already be present locally: `docker pull busybox`. | ||
| PORTABASE_HELPER_IMAGE: "${PORTABASE_HELPER_IMAGE:-docker.io/library/busybox:latest}" | ||
| # Points the agent at your Portabase Server. Set EDGE_KEY in .env to the | ||
| # key from your deployed backend; the fallback below targets a local | ||
| # server at http://localhost:8887 (the agent just logs connection errors | ||
| # if nothing is listening there). | ||
| EDGE_KEY: "${EDGE_KEY:-eyJzZXJ2ZXJVcmwiOiJodHRwOi8vbG9jYWxob3N0Ojg4ODciLCJhZ2VudElkIjoiZWZhYTM0YTQtZDY1NC00OGQ3LTgwNDYtNjRkMWExYTA1M2FlIiwibWFzdGVyS2V5QjY0IjoiMUh0djdtWCtYVkJxL0IzUEV2WDlZZjlQeUdVZW5oRHlXemo5THRqNW90WT0ifQ==}" | ||
| #CHUNK_SIZE_MB: "1" | ||
| #POOLING: 1 | ||
| #DATABASES_CONFIG_FILE: "config.toml" | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,44 +1,151 @@ | ||
| #!/bin/bash | ||
| set -euo pipefail | ||
|
|
||
| check_docker() { | ||
| if ! docker info > /dev/null 2>&1; then | ||
| echo "Docker is not running. Attempting to start Docker..." | ||
| if [[ "$OSTYPE" == "darwin"* ]]; then | ||
| open -a Docker | ||
| echo "Waiting for Docker to start..." | ||
| until docker info > /dev/null 2>&1; do | ||
| sleep 2 | ||
| done | ||
| elif command -v systemctl >/dev/null 2>&1; then | ||
| sudo systemctl start docker | ||
| else | ||
| echo "Cannot start Docker automatically. Please start Docker manually." | ||
| exit 1 | ||
| # Container engine + compose command, resolved by detect_engine/detect_compose. | ||
| ENGINE="" | ||
| COMPOSE="" | ||
|
|
||
| # True if the given engine binary exists and its daemon/service answers. | ||
| # Bounded with `timeout` (when available) so a wedged/slow daemon fails the | ||
| # check quickly instead of hanging the whole script on `<engine> info`. | ||
| engine_ready() { | ||
| command -v "$1" >/dev/null 2>&1 || return 1 | ||
| if command -v timeout >/dev/null 2>&1; then | ||
| timeout 15 "$1" info >/dev/null 2>&1 | ||
| else | ||
| "$1" info >/dev/null 2>&1 | ||
| fi | ||
| } | ||
|
|
||
| # Best-effort start of the Docker daemon (macOS app or systemd service). | ||
| try_start_docker() { | ||
| if [[ "$OSTYPE" == "darwin"* ]]; then | ||
| open -a Docker >/dev/null 2>&1 || return 1 | ||
| echo "Waiting for Docker to start..." | ||
| local count=0 | ||
| until docker info >/dev/null 2>&1; do | ||
| sleep 2 | ||
| count=$((count + 1)) | ||
| [ "$count" -ge 30 ] && return 1 | ||
| done | ||
| return 0 | ||
| elif command -v systemctl >/dev/null 2>&1; then | ||
| sudo systemctl start docker >/dev/null 2>&1 || return 1 | ||
| docker info >/dev/null 2>&1 | ||
| else | ||
| return 1 | ||
| fi | ||
| } | ||
|
|
||
| # Pick a container engine, preferring one that is already running. | ||
| detect_engine() { | ||
| if engine_ready docker; then | ||
| ENGINE="docker" | ||
| elif engine_ready podman; then | ||
| ENGINE="podman" | ||
| elif command -v docker >/dev/null 2>&1; then | ||
| echo "Docker is installed but not running. Attempting to start it..." | ||
| if try_start_docker; then | ||
| ENGINE="docker" | ||
| elif command -v podman >/dev/null 2>&1; then | ||
| echo "Could not start Docker; falling back to Podman." | ||
| ENGINE="podman" | ||
| fi | ||
| elif command -v podman >/dev/null 2>&1; then | ||
| # Podman CLI works without a running daemon for most commands. | ||
| ENGINE="podman" | ||
| fi | ||
|
|
||
| if [ -z "$ENGINE" ]; then | ||
| echo "No working container engine found (need docker or podman)." >&2 | ||
| exit 1 | ||
| fi | ||
| echo "Using container engine: ${ENGINE}" | ||
| } | ||
|
|
||
| # Resolve a compose implementation compatible with the chosen engine. | ||
| detect_compose() { | ||
| if $ENGINE compose version >/dev/null 2>&1; then | ||
| COMPOSE="$ENGINE compose" | ||
| elif command -v docker-compose >/dev/null 2>&1; then | ||
| COMPOSE="docker-compose" | ||
| elif command -v podman-compose >/dev/null 2>&1; then | ||
| COMPOSE="podman-compose" | ||
| else | ||
| echo "Docker is running." | ||
| echo "No compose command found (${ENGINE} compose / docker-compose / podman-compose)." >&2 | ||
| exit 1 | ||
| fi | ||
| echo "Using compose command: ${COMPOSE}" | ||
| } | ||
|
|
||
| # Ensure the external network referenced by the compose files exists. | ||
| # `inspect` is a more reliable existence test than parsing `ls`, and the create | ||
| # is made idempotent so a concurrent/pre-existing network doesn't abort the run | ||
| # (podman's `network create` errors on an existing name; docker's does not). | ||
| check_network() { | ||
| local network_name="portabase_network" | ||
| if ! docker network ls --format '{{.Name}}' | grep -q "^${network_name}$"; then | ||
| echo "Docker network '${network_name}' not found. Creating..." | ||
| docker network create "${network_name}" | ||
| else | ||
| echo "Docker network '${network_name}' already exists." | ||
| if $ENGINE network inspect "${network_name}" >/dev/null 2>&1; then | ||
| echo "Network '${network_name}' already exists." | ||
| return 0 | ||
| fi | ||
| echo "Network '${network_name}' not found. Creating..." | ||
| $ENGINE network create "${network_name}" >/dev/null 2>&1 \ | ||
| || echo "Network '${network_name}' already exists (created concurrently)." | ||
| } | ||
|
|
||
| # Ensure the external volume declared in docker-compose.yml exists. | ||
| check_volume() { | ||
| local volume_name="databases_sqlite-data" | ||
| if $ENGINE volume inspect "${volume_name}" >/dev/null 2>&1; then | ||
| echo "Volume '${volume_name}' already exists." | ||
| return 0 | ||
| fi | ||
| echo "Volume '${volume_name}' not found. Creating..." | ||
| $ENGINE volume create "${volume_name}" >/dev/null 2>&1 \ | ||
| || echo "Volume '${volume_name}' already exists (created concurrently)." | ||
| } | ||
|
|
||
| # Resolve the Podman socket and expose it to compose via DOCKER_SOCK. | ||
| # The compose files bind-mount ${DOCKER_SOCK:-/var/run/docker.sock} into the | ||
| # agent so it can drive containers (testcontainers). Under rootless Podman the | ||
| # real socket lives under $XDG_RUNTIME_DIR, not /var/run/docker.sock, so we point | ||
| # the mount at it here. Without a socket, backup/restore can't connect. | ||
| check_podman_socket() { | ||
| [ "$ENGINE" = "podman" ] || return 0 | ||
|
|
||
| local rootless_sock="${XDG_RUNTIME_DIR:-/run/user/$(id -u)}/podman/podman.sock" | ||
| local sock="" | ||
| if [ -S "$rootless_sock" ]; then | ||
| sock="$rootless_sock" | ||
| elif [ -S /var/run/docker.sock ]; then | ||
| sock="/var/run/docker.sock" | ||
| fi | ||
|
|
||
| if [ -n "$sock" ]; then | ||
| export DOCKER_SOCK="$sock" | ||
| echo "Using Podman socket: ${sock}" | ||
| return 0 | ||
| fi | ||
|
|
||
| echo "[WARN] Running in Podman mode but no Podman socket was found." >&2 | ||
| echo "[WARN] Checked: ${rootless_sock} and /var/run/docker.sock" >&2 | ||
| echo "[WARN] The agent mounts this socket to manage containers; without it," >&2 | ||
| echo "[WARN] backup/restore operations will fail to connect." >&2 | ||
| echo "[WARN] Enable it with: systemctl --user enable --now podman.socket" >&2 | ||
| echo "[WARN] (then re-run 'just up'). Continuing anyway..." >&2 | ||
| } | ||
|
|
||
| check_docker | ||
| detect_engine | ||
| detect_compose | ||
| check_network | ||
| check_volume | ||
| check_podman_socket | ||
|
|
||
| echo "Stopping old database containers..." | ||
| docker compose -f ./docker-compose.databases.yml down | ||
| $COMPOSE -f ./docker-compose.databases.yml down | ||
|
|
||
| echo "Starting database containers..." | ||
| docker compose -f ./docker-compose.databases.yml up -d | ||
| $COMPOSE -f ./docker-compose.databases.yml up -d | ||
|
|
||
| echo "Starting main services..." | ||
| docker compose -f ./docker-compose.yml up | ||
| $COMPOSE -f ./docker-compose.yml up |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.