Files
openfront/setup.sh
Bernhard Blieninger 26d4c7aca6 Initial commit: self-hosted Docker setup for OpenFrontIO
Includes docker-compose, setup script, nginx reverse proxy docs,
and GAME_ENV configuration notes for self-hosted deployments.
2026-03-16 00:47:17 +01:00

55 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
set -e
REPO_URL="https://github.com/openfrontio/OpenFrontIO.git"
REPO_DIR="./OpenFrontIO"
echo "=== OpenFrontIO Docker Setup ==="
# Clone repo if not already present
if [ ! -d "$REPO_DIR/.git" ]; then
echo "[1/4] Cloning OpenFrontIO repository..."
git clone "$REPO_URL" "$REPO_DIR"
else
echo "[1/4] Repository already cloned. Pulling latest changes..."
git -C "$REPO_DIR" pull
fi
# Initialize git submodules (proprietary assets etc.)
echo "[2/4] Initializing submodules..."
git -C "$REPO_DIR" submodule update --init --recursive 2>/dev/null || true
# The 'proprietary' directory may be a private submodule.
# If it doesn't exist after submodule init, create an empty one so Docker COPY doesn't fail.
if [ ! -d "$REPO_DIR/proprietary" ]; then
echo " Note: 'proprietary' submodule not available (private). Creating empty placeholder."
mkdir -p "$REPO_DIR/proprietary"
fi
# Set up .env from example if it doesn't exist yet
echo "[3/4] Setting up .env..."
if [ ! -f ".env" ]; then
cp .env.example .env
echo " .env created from .env.example — edit it before starting!"
else
echo " .env already exists, skipping."
fi
# Capture git commit hash for reproducible builds
GIT_COMMIT=$(git -C "$REPO_DIR" rev-parse --short HEAD 2>/dev/null || echo "unknown")
# Update GIT_COMMIT in .env if placeholder
if grep -q "^GIT_COMMIT=unknown" .env 2>/dev/null; then
sed -i "s/^GIT_COMMIT=unknown/GIT_COMMIT=${GIT_COMMIT}/" .env
fi
echo "[4/4] Setup complete!"
echo ""
echo "Next steps:"
echo " 1. Edit .env (at minimum set HOST_PORT if port 80 is taken)"
echo " 2. docker compose build"
echo " 3. docker compose up -d"
echo " 4. Open http://localhost (or your HOST_PORT)"
echo ""
echo " Optional: Set CF_API_TOKEN, CF_ACCOUNT_ID, SUBDOMAIN, DOMAIN in .env"
echo " for automatic Cloudflare Tunnel setup."