Merge pull request #5 from Dvorinka/feat/standalone-install

feat: standalone curl-pipe installer, no clone required
This commit is contained in:
Tomáš Dvořák authored and GitHub committed 2026-09-21 16:51:11 +02:00
commit 3f6e506445
3 files changed
+81 -21

No files matched your search

+19 -9
View File
@@ -86,19 +86,29 @@ docs/ Guides, OpenAPI spec, design documents
### Easy install (recommended)
Requires Docker with the Compose plugin, `openssl`, and `curl`.
Requires Docker with the Compose plugin, `openssl`, and `curl`. One-liner,
no clone needed:
```bash
git clone https://github.com/Dvorinka/Containr.git
cd Containr
./install.sh
curl -fsSL https://raw.githubusercontent.com/Dvorinka/Containr/main/install.sh | bash
```
The script creates `.env` from `.env.example`, fills in all required secrets
with random values, pulls the published `:latest` images from GHCR, and
starts the stack. It keeps an existing `.env` untouched, so it is safe to
re-run. Set `CONTAINR_BUILD=1` to build from source instead, or
`CONTAINR_VERSION` in `.env` to pin a release tag (e.g. `0.1.1`).
Installs into `./containr`, generates secrets, pulls the published `:latest`
images from GHCR, and starts the stack. Non-interactive — configure with
env vars:
```bash
curl -fsSL https://raw.githubusercontent.com/Dvorinka/Containr/main/install.sh | \
HTTP_PORT=8080 API_PORT=8082 CONTAINR_DIR=/opt/containr bash
```
`CONTAINR_VERSION` pins a release tag (e.g. `0.1.1`), `CONTAINR_REF` selects
the git ref for downloaded files, and `CONTAINR_BUILD=1` skips the registry
and builds from source — the installer downloads the source tarball when it
needs to build. An existing `.env` is never overwritten, so it is safe to
re-run.
From a git checkout, `./install.sh` does the same thing in place.
Frontend at `http://localhost:3000`, API at `http://localhost:8082`.
-2
View File
@@ -1,5 +1,3 @@
name: containr
services:
postgres:
image: postgres:15-alpine
+62 -10
View File
@@ -1,20 +1,62 @@
#!/usr/bin/env bash
# Containr one-shot installer: creates .env with generated secrets, pulls the
# published images (or builds from source), boots the stack, and waits for
# the API to report healthy.
# Containr installer. Works from a source checkout, or standalone:
# curl -fsSL https://raw.githubusercontent.com/Dvorinka/Containr/main/install.sh | bash
#
# Creates .env with generated secrets, pulls the published images (or builds
# from source), boots the stack, and waits for the API to report healthy.
#
# Env overrides (all optional):
# CONTAINR_DIR install dir when not run from a clone (default ./containr)
# CONTAINR_VERSION image tag to pull (default latest, e.g. 0.1.1)
# CONTAINR_REF git ref for downloaded files (default main)
# CONTAINR_BUILD=1 force building images from source
# HTTP_PORT API_PORT POSTGRES_PORT REDIS_PORT host port remaps
set -euo pipefail
cd "$(dirname "$0")"
cd "$(dirname "$0")" 2>/dev/null || true
info() { printf '\033[1;34m==>\033[0m %s\n' "$*"; }
err() { printf '\033[1;31mError:\033[0m %s\n' "$*" >&2; }
CONTAINR_REF="${CONTAINR_REF:-main}"
RAW_BASE="https://raw.githubusercontent.com/Dvorinka/Containr/${CONTAINR_REF}"
# Dependencies
command -v docker >/dev/null 2>&1 || { err "docker not found. Install Docker: https://docs.docker.com/get-docker/"; exit 1; }
docker compose version >/dev/null 2>&1 || { err "docker compose (v2) not found. Update Docker or install the compose plugin."; exit 1; }
docker info >/dev/null 2>&1 || { err "docker daemon is not running or not reachable."; exit 1; }
command -v openssl >/dev/null 2>&1 || { err "openssl not found (needed to generate secrets)."; exit 1; }
command -v curl >/dev/null 2>&1 || { err "curl not found (needed for the health check)."; exit 1; }
command -v curl >/dev/null 2>&1 || { err "curl not found (needed for downloads and the health check)."; exit 1; }
# Install location: explicit CONTAINR_DIR wins; otherwise reuse the current
# dir when it already looks like a checkout/install, else ./containr.
if [[ -n "${CONTAINR_DIR:-}" ]]; then
mkdir -p "$CONTAINR_DIR"
cd "$CONTAINR_DIR"
elif [[ ! -f docker-compose.yml || ! -f .env.example ]]; then
CONTAINR_DIR="./containr"
mkdir -p "$CONTAINR_DIR"
cd "$CONTAINR_DIR"
fi
# Fetch compose file and env template when running standalone. Existing
# files are kept so re-runs stay idempotent.
if [[ ! -f docker-compose.yml ]]; then
info "Downloading docker-compose.yml (${CONTAINR_REF})..."
curl -fsSL "$RAW_BASE/docker-compose.yml" -o docker-compose.yml
fi
if [[ ! -f .env.example ]]; then
info "Downloading .env.example (${CONTAINR_REF})..."
curl -fsSL "$RAW_BASE/.env.example" -o .env.example
fi
# Source tarball, only needed when building images locally.
ensure_source() {
[[ -d app/backend ]] && return 0
command -v tar >/dev/null 2>&1 || { err "tar not found (needed to unpack the source)."; exit 1; }
info "Downloading source (${CONTAINR_REF})..."
curl -fsSL "https://codeload.github.com/Dvorinka/Containr/tar.gz/${CONTAINR_REF}" | tar xz --strip-components=1
}
# Env file
if [[ -f .env ]]; then
@@ -38,22 +80,32 @@ else
# POSTGRES_PASSWORD, DATABASE_URL and DB_PASSWORD stay in sync.
sed -i.bak "s|your_secure_postgres_password|$PG_PASS|g" .env
sed -i.bak "s|your_secure_redis_password|$REDIS_PASS|g" .env
# Persist any overrides passed via the environment.
for v in HTTP_PORT API_PORT POSTGRES_PORT REDIS_PORT CONTAINR_VERSION; do
[[ -n "${!v:-}" ]] && setvar "$v" "${!v}"
done
rm -f .env.bak
info ".env created with random secrets."
fi
# Ports (overridable via environment, matching docker-compose.yml vars)
# Ports for the health wait: environment first, then .env, then defaults.
HTTP_PORT="${HTTP_PORT:-$(grep -E '^HTTP_PORT=' .env | cut -d= -f2)}"
API_PORT="${API_PORT:-$(grep -E '^API_PORT=' .env | cut -d= -f2)}"
HTTP_PORT="${HTTP_PORT:-3000}"
API_PORT="${API_PORT:-8082}"
# Boot: pull published :latest images by default (CONTAINR_VERSION pins a
# release). Build from source instead with CONTAINR_BUILD=1, or as fallback
# when the registry is unreachable.
# Boot: pull published images by default (CONTAINR_VERSION pins a release).
# Build from source with CONTAINR_BUILD=1, or as fallback when the registry
# is unreachable.
if [[ "${CONTAINR_BUILD:-}" == "1" ]]; then
info "CONTAINR_BUILD=1 - building images from source..."
ensure_source
docker compose build
elif ! docker compose pull; then
info "Image pull failed - building from source instead..."
ensure_source
docker compose build
fi
info "Starting the stack..."
@@ -79,4 +131,4 @@ info "Containr is running."
echo " UI: http://localhost:${HTTP_PORT}"
echo " API: http://localhost:${API_PORT}"
echo ""
echo "Manage with: docker compose logs -f | docker compose down"
echo "Manage with: (cd ${CONTAINR_DIR:-.} && docker compose logs -f | docker compose down)"