Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 83a30fad4a | |||
| 8062a44544 | |||
| f742afc659 | |||
| 27475870d0 |
+2
-2
@@ -24,9 +24,9 @@ flowchart TD
|
|||||||
|
|
||||||
## Gitea release to the existing host
|
## Gitea release to the existing host
|
||||||
|
|
||||||
PostgreSQL on the existing host uses Gitea Actions variables `BEDROCK_PG_HOST`, `BEDROCK_PG_PORT`, `BEDROCK_PG_DATABASE`, `BEDROCK_PG_USER` and secret `BEDROCK_PG_PASSWORD`. The release invokes `python3 deploy/gitea/render-postgres.py /path/to/private/bedrock.yaml --deployment production --config-version RELEASE_ID`. The renderer writes a private file. The database must already exist and present a trusted certificate for the selected endpoint.
|
PostgreSQL on the existing host uses Gitea Actions variables `BEDROCK_PG_HOST`, `BEDROCK_PG_PORT`, `BEDROCK_PG_DATABASE`, `BEDROCK_PG_USER` and secret `BEDROCK_PG_PASSWORD`. The release invokes `deploy/gitea/render-postgres.py` to write a private configuration file. The database must already exist.
|
||||||
|
|
||||||
Gitea builds a release on `ces-control` when a commit lands on `main`. The deploy step renders the private PostgreSQL configuration and runs `backend --init-storage` through the published `bedrock` executable on the existing `endoleap-dev_default` network. It publishes releases under `/opt/endoleap-infra/bedrock-rust/releases` and switches `/opt/endoleap-infra/bedrock-rust/current` after successful initialization. The Go service retains its own containers and routes.
|
Gitea builds a release on `ces-control` when a commit lands on `main`. The deploy step renders the private PostgreSQL configuration and runs `backend --init-storage` through the published `bedrock` executable. For `127.0.0.1` or `::1`, the initialization container uses the runner's host network and connects without TLS to the loopback port. Other endpoints use the `endoleap-dev_default` network and require a trusted certificate matching the configured host. The deploy step publishes releases under `/opt/endoleap-infra/bedrock-rust/releases` and switches `/opt/endoleap-infra/bedrock-rust/current` after successful initialization. The Go service retains its own containers and routes.
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
flowchart TD
|
flowchart TD
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ mkdir -p "$output"
|
|||||||
docker run --rm \
|
docker run --rm \
|
||||||
--mount "type=bind,source=$PWD,target=/work,readonly" \
|
--mount "type=bind,source=$PWD,target=/work,readonly" \
|
||||||
--mount "type=bind,source=$output,target=/out" \
|
--mount "type=bind,source=$output,target=/out" \
|
||||||
|
--mount type=volume,source=bedrock-cargo-target,target=/tmp/bedrock-target \
|
||||||
|
--mount type=volume,source=bedrock-cargo-registry,target=/usr/local/cargo/registry \
|
||||||
-w /work -e CARGO_TARGET_DIR=/tmp/bedrock-target \
|
-w /work -e CARGO_TARGET_DIR=/tmp/bedrock-target \
|
||||||
rust:1.91.1-bookworm sh -ec '
|
rust:1.91.1-bookworm sh -ec '
|
||||||
cargo build --locked --release -p backend
|
cargo build --locked --release -p backend
|
||||||
|
|||||||
@@ -12,6 +12,13 @@ fi
|
|||||||
infra=/opt/endoleap-infra
|
infra=/opt/endoleap-infra
|
||||||
root=$infra/bedrock-rust
|
root=$infra/bedrock-rust
|
||||||
network=endoleap-dev_default
|
network=endoleap-dev_default
|
||||||
|
render_options=()
|
||||||
|
case ${BEDROCK_PG_HOST:-} in
|
||||||
|
127.0.0.1|::1|'[::1]')
|
||||||
|
network=host
|
||||||
|
render_options+=(--runner-loopback)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
test -d "$infra"
|
test -d "$infra"
|
||||||
test ! -L "$root"
|
test ! -L "$root"
|
||||||
docker network inspect "$network" >/dev/null
|
docker network inspect "$network" >/dev/null
|
||||||
@@ -23,7 +30,7 @@ trap cleanup EXIT
|
|||||||
install -m 755 "$binary" "$stage/bedrock"
|
install -m 755 "$binary" "$stage/bedrock"
|
||||||
release="$revision.${stage##*.}"
|
release="$revision.${stage##*.}"
|
||||||
python3 "$(dirname "$0")/render-postgres.py" "$stage/bedrock.yaml" \
|
python3 "$(dirname "$0")/render-postgres.py" "$stage/bedrock.yaml" \
|
||||||
--deployment production --config-version "$release"
|
--deployment production --config-version "$release" "${render_options[@]}"
|
||||||
|
|
||||||
# Run storage initialization as a one-shot command in the release container.
|
# Run storage initialization as a one-shot command in the release container.
|
||||||
docker run --rm --network "$network" \
|
docker run --rm --network "$network" \
|
||||||
|
|||||||
@@ -18,8 +18,10 @@ def required(variable):
|
|||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
def database_url():
|
def database_url(runner_loopback):
|
||||||
host = required("BEDROCK_PG_HOST").removeprefix("[").removesuffix("]")
|
host = required("BEDROCK_PG_HOST").removeprefix("[").removesuffix("]")
|
||||||
|
if runner_loopback and host not in ("127.0.0.1", "::1"):
|
||||||
|
raise SystemExit("--runner-loopback requires a loopback IP literal")
|
||||||
if ":" in host:
|
if ":" in host:
|
||||||
try:
|
try:
|
||||||
host = f"[{ipaddress.IPv6Address(host)}]"
|
host = f"[{ipaddress.IPv6Address(host)}]"
|
||||||
@@ -46,6 +48,10 @@ def main():
|
|||||||
parser.add_argument("output", type=Path)
|
parser.add_argument("output", type=Path)
|
||||||
parser.add_argument("--deployment", default="default")
|
parser.add_argument("--deployment", default="default")
|
||||||
parser.add_argument("--config-version", default="local")
|
parser.add_argument("--config-version", default="local")
|
||||||
|
parser.add_argument(
|
||||||
|
"--runner-loopback", action="store_true",
|
||||||
|
help="connect without TLS to a loopback IP from the runner's host network",
|
||||||
|
)
|
||||||
options = parser.parse_args()
|
options = parser.parse_args()
|
||||||
if not re.fullmatch(r"[A-Za-z0-9._-]{1,128}", options.deployment):
|
if not re.fullmatch(r"[A-Za-z0-9._-]{1,128}", options.deployment):
|
||||||
parser.error("invalid deployment name")
|
parser.error("invalid deployment name")
|
||||||
@@ -61,8 +67,10 @@ def main():
|
|||||||
" postgres:\n"
|
" postgres:\n"
|
||||||
" kind: sql\n"
|
" kind: sql\n"
|
||||||
" driver: postgres\n"
|
" driver: postgres\n"
|
||||||
f" primary: {json.dumps(database_url())}\n"
|
f" primary: {json.dumps(database_url(options.runner_loopback))}\n"
|
||||||
)
|
)
|
||||||
|
if options.runner_loopback:
|
||||||
|
config += " tls: disabled\n"
|
||||||
|
|
||||||
# Write with owner-only permissions, then replace the destination atomically.
|
# Write with owner-only permissions, then replace the destination atomically.
|
||||||
file = tempfile.NamedTemporaryFile(mode="w", dir=options.output.parent, delete=False)
|
file = tempfile.NamedTemporaryFile(mode="w", dir=options.output.parent, delete=False)
|
||||||
|
|||||||
Reference in New Issue
Block a user