mirror of
https://github.com/Dvorinka/Containr.git
synced 2026-10-28 07:41:27 +00:00
feat: standalone curl-pipe installer, no clone required
- install.sh works outside a checkout: installs into CONTAINR_DIR (default ./containr), downloads docker-compose.yml + .env.example from the repo, generates secrets, pulls published images - CONTAINR_REF selects the git ref for downloads; CONTAINR_BUILD=1 or a failed pull fetches the source tarball and builds locally - env-var overrides (HTTP_PORT/API_PORT/...) are persisted into .env; health-wait ports resolve env -> .env -> defaults - drop fixed `name: containr` from root compose so installs in different directories get distinct project names - README: curl one-liner is the primary install path Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
ec1555cbe4
commit
a0141ae552
3 files changed
+81
-21
No files matched your search
@@ -86,19 +86,29 @@ docs/ Guides, OpenAPI spec, design documents
|
|||||||
|
|
||||||
### Easy install (recommended)
|
### 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
|
```bash
|
||||||
git clone https://github.com/Dvorinka/Containr.git
|
curl -fsSL https://raw.githubusercontent.com/Dvorinka/Containr/main/install.sh | bash
|
||||||
cd Containr
|
|
||||||
./install.sh
|
|
||||||
```
|
```
|
||||||
|
|
||||||
The script creates `.env` from `.env.example`, fills in all required secrets
|
Installs into `./containr`, generates secrets, pulls the published `:latest`
|
||||||
with random values, pulls the published `:latest` images from GHCR, and
|
images from GHCR, and starts the stack. Non-interactive — configure with
|
||||||
starts the stack. It keeps an existing `.env` untouched, so it is safe to
|
env vars:
|
||||||
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`).
|
```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`.
|
Frontend at `http://localhost:3000`, API at `http://localhost:8082`.
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
name: containr
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:15-alpine
|
image: postgres:15-alpine
|
||||||
|
|||||||
+62
-10
@@ -1,20 +1,62 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Containr one-shot installer: creates .env with generated secrets, pulls the
|
# Containr installer. Works from a source checkout, or standalone:
|
||||||
# published images (or builds from source), boots the stack, and waits for
|
# curl -fsSL https://raw.githubusercontent.com/Dvorinka/Containr/main/install.sh | bash
|
||||||
# the API to report healthy.
|
#
|
||||||
|
# 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
|
set -euo pipefail
|
||||||
|
|
||||||
cd "$(dirname "$0")"
|
cd "$(dirname "$0")" 2>/dev/null || true
|
||||||
|
|
||||||
info() { printf '\033[1;34m==>\033[0m %s\n' "$*"; }
|
info() { printf '\033[1;34m==>\033[0m %s\n' "$*"; }
|
||||||
err() { printf '\033[1;31mError:\033[0m %s\n' "$*" >&2; }
|
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
|
# Dependencies
|
||||||
command -v docker >/dev/null 2>&1 || { err "docker not found. Install Docker: https://docs.docker.com/get-docker/"; exit 1; }
|
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 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; }
|
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 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
|
# Env file
|
||||||
if [[ -f .env ]]; then
|
if [[ -f .env ]]; then
|
||||||
@@ -38,22 +80,32 @@ else
|
|||||||
# POSTGRES_PASSWORD, DATABASE_URL and DB_PASSWORD stay in sync.
|
# 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_postgres_password|$PG_PASS|g" .env
|
||||||
sed -i.bak "s|your_secure_redis_password|$REDIS_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
|
rm -f .env.bak
|
||||||
info ".env created with random secrets."
|
info ".env created with random secrets."
|
||||||
fi
|
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}"
|
HTTP_PORT="${HTTP_PORT:-3000}"
|
||||||
API_PORT="${API_PORT:-8082}"
|
API_PORT="${API_PORT:-8082}"
|
||||||
|
|
||||||
# Boot: pull published :latest images by default (CONTAINR_VERSION pins a
|
# Boot: pull published images by default (CONTAINR_VERSION pins a release).
|
||||||
# release). Build from source instead with CONTAINR_BUILD=1, or as fallback
|
# Build from source with CONTAINR_BUILD=1, or as fallback when the registry
|
||||||
# when the registry is unreachable.
|
# is unreachable.
|
||||||
if [[ "${CONTAINR_BUILD:-}" == "1" ]]; then
|
if [[ "${CONTAINR_BUILD:-}" == "1" ]]; then
|
||||||
info "CONTAINR_BUILD=1 - building images from source..."
|
info "CONTAINR_BUILD=1 - building images from source..."
|
||||||
|
ensure_source
|
||||||
docker compose build
|
docker compose build
|
||||||
elif ! docker compose pull; then
|
elif ! docker compose pull; then
|
||||||
info "Image pull failed - building from source instead..."
|
info "Image pull failed - building from source instead..."
|
||||||
|
ensure_source
|
||||||
docker compose build
|
docker compose build
|
||||||
fi
|
fi
|
||||||
info "Starting the stack..."
|
info "Starting the stack..."
|
||||||
@@ -79,4 +131,4 @@ info "Containr is running."
|
|||||||
echo " UI: http://localhost:${HTTP_PORT}"
|
echo " UI: http://localhost:${HTTP_PORT}"
|
||||||
echo " API: http://localhost:${API_PORT}"
|
echo " API: http://localhost:${API_PORT}"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Manage with: docker compose logs -f | docker compose down"
|
echo "Manage with: (cd ${CONTAINR_DIR:-.} && docker compose logs -f | docker compose down)"
|
||||||
Reference in new issue
Block a user