fix: devcontainer build and setup on fresh clones
This commit is contained in:
parent
1e8050611c
commit
c2125f063b
7 changed files with 70 additions and 15 deletions
|
|
@ -2,10 +2,19 @@
|
|||
# Dev-only setup (runs via postCreateCommand in the attached `api` container).
|
||||
# Production needs none of this: images carry their dependencies and the
|
||||
# api entrypoint migrates on every start.
|
||||
set -e
|
||||
set -eo pipefail
|
||||
|
||||
REPO=/srv/kirche-einfach
|
||||
|
||||
# Run a command as vscode with the current environment intact.
|
||||
# (`su vscode -c` resets the environment, which used to drop
|
||||
# UV_PROJECT_ENVIRONMENT/UV_PYTHON_INSTALL_DIR plus every compose-provided
|
||||
# variable — uv then created a project-local backend/.venv in the bind-mount
|
||||
# instead of using /opt/venv, and sync_flows.py ran without its settings.)
|
||||
as_vscode() {
|
||||
sudo -u vscode -E bash -c "$*"
|
||||
}
|
||||
|
||||
# Venv lives outside the bind-mount (see backend/Dockerfile).
|
||||
export UV_PYTHON_INSTALL_DIR=/opt/python UV_PROJECT_ENVIRONMENT=/opt/venv
|
||||
|
||||
|
|
@ -33,22 +42,26 @@ chown -R vscode:vscode "$REPO/backend/data" \
|
|||
# the editor; uv resolves at setup time, no lockfile is committed).
|
||||
echo "--- Installing Python dependencies ---"
|
||||
cd "$REPO/backend"
|
||||
su vscode -c "uv sync"
|
||||
as_vscode "uv sync"
|
||||
|
||||
# opencode CLI (dev tooling; intentionally not baked into the image).
|
||||
if [ ! -x /home/vscode/.opencode/bin/opencode ]; then
|
||||
echo "--- Installing opencode ---"
|
||||
su vscode -c "curl -fsSL https://opencode.ai/install | bash"
|
||||
as_vscode "curl -fsSL https://opencode.ai/install | bash"
|
||||
ln -sf /home/vscode/.opencode/bin/opencode /usr/local/bin/opencode
|
||||
fi
|
||||
|
||||
# Compose services (langflow, lfx) must be up; fail loudly otherwise.
|
||||
# (api/frontend are starting alongside this script.)
|
||||
echo "--- Waiting for compose services ---"
|
||||
# Fresh clones have no `.env` (gitignored) and compose `env_file` is
|
||||
# optional, so provision one from the example instead of failing setup.
|
||||
# Fill in real secrets afterwards; empty SMTP_* means the API logs mail.
|
||||
if [ ! -f "$REPO/.env" ]; then
|
||||
echo "ERROR: $REPO/.env is missing. Copy .env.example to .env and fill in secrets." >&2
|
||||
exit 1
|
||||
echo "WARN: $REPO/.env missing — copying .env.example (fill in secrets)."
|
||||
cp "$REPO/.env.example" "$REPO/.env"
|
||||
chown vscode:vscode "$REPO/.env" 2>/dev/null || true
|
||||
fi
|
||||
echo "--- Waiting for compose services ---"
|
||||
python3 - <<'EOF'
|
||||
import socket
|
||||
import sys
|
||||
|
|
@ -79,7 +92,7 @@ EOF
|
|||
# entrypoint on every start).
|
||||
echo "--- Syncing canonical flows ---"
|
||||
cd "$REPO/backend"
|
||||
su vscode -c "uv run python scripts/sync_flows.py --sync" || echo "WARN: flow sync failed (check backend/flows and LFX)"
|
||||
as_vscode "uv run python scripts/sync_flows.py --sync" || echo "WARN: flow sync failed (check backend/flows and LFX)"
|
||||
|
||||
echo ""
|
||||
echo "=== Setup complete ==="
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue