mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-09-09 11:47:14 +02:00
Cleaned up bridgy fed
This commit is contained in:
@@ -9,7 +9,7 @@ This role builds and runs Bridgy Fed as a Docker container and (optionally) star
|
|||||||
Upstream docs & dev notes:
|
Upstream docs & dev notes:
|
||||||
- User & developer docs: https://fed.brid.gy and https://bridgy-fed.readthedocs.io/
|
- User & developer docs: https://fed.brid.gy and https://bridgy-fed.readthedocs.io/
|
||||||
- Source: https://github.com/snarfed/bridgy-fed
|
- Source: https://github.com/snarfed/bridgy-fed
|
||||||
- Local run (reference): `flask run -p 8080` with APPVIEW_HOST/PLC_HOST/BGS_HOST/PDS_HOST set, and Datastore emulator envs
|
- Local run (reference): `flask run -p 8080` with BRIDGY_APPVIEW_HOST/BRIDGY_PLC_HOST/BRIDGY_BGS_HOST/BRIDGY_PDS_HOST set, and Datastore emulator envs
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
- Dockerized Flask app (gunicorn)
|
- Dockerized Flask app (gunicorn)
|
||||||
|
@@ -17,18 +17,13 @@ server:
|
|||||||
docker:
|
docker:
|
||||||
services:
|
services:
|
||||||
database:
|
database:
|
||||||
enabled: false
|
enabled: false
|
||||||
emulator:
|
|
||||||
enabled: true
|
|
||||||
image: 'gcr.io/google.com/cloudsdktool/google-cloud-cli:latest'
|
|
||||||
application:
|
application:
|
||||||
image: "python"
|
image: "python"
|
||||||
version: "3.12-bookworm"
|
version: "3.12-bookworm"
|
||||||
name: "web-app-bridgy-fed"
|
name: "web-app-bridgy-fed"
|
||||||
|
repository: "https://github.com/snarfed/bridgy-fed.git"
|
||||||
|
branch: "main"
|
||||||
rbac:
|
rbac:
|
||||||
roles: {}
|
roles: {}
|
||||||
|
|
||||||
source:
|
|
||||||
repo: "https://github.com/snarfed/bridgy-fed.git"
|
|
||||||
ref: "main"
|
|
||||||
|
@@ -3,7 +3,7 @@ ARG PY_BASE="python:3.12-bookworm"
|
|||||||
FROM ${PY_BASE} AS build
|
FROM ${PY_BASE} AS build
|
||||||
|
|
||||||
ARG BRIDGY_REPO_URL
|
ARG BRIDGY_REPO_URL
|
||||||
ARG BRIDGY_REPO_REF
|
ARG BRIDGY_REPO_BRANCH
|
||||||
|
|
||||||
# System deps: git, build tools, curl for healthchecks, and gunicorn
|
# System deps: git, build tools, curl for healthchecks, and gunicorn
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
@@ -11,7 +11,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|||||||
rm -rf /var/lib/apt/lists/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN git clone --depth=1 --branch "${BRIDGY_REPO_REF}" "${BRIDGY_REPO_URL}" ./
|
RUN git clone --depth=1 --branch "${BRIDGY_REPO_BRANCH}" "${BRIDGY_REPO_URL}" ./
|
||||||
|
|
||||||
# Python deps
|
# Python deps
|
||||||
RUN pip install --upgrade pip && \
|
RUN pip install --upgrade pip && \
|
||||||
@@ -35,7 +35,7 @@ PY
|
|||||||
FROM ${PY_BASE}
|
FROM ${PY_BASE}
|
||||||
|
|
||||||
ARG CONTAINER_PORT
|
ARG CONTAINER_PORT
|
||||||
ENV PORT=${CONTAINER_PORT:-8080}
|
ENV PORT=${CONTAINER_PORT}
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=build /app /app
|
COPY --from=build /app /app
|
||||||
|
0
roles/web-app-bridgy-fed/schema/main.yml
Normal file
0
roles/web-app-bridgy-fed/schema/main.yml
Normal file
@@ -2,20 +2,8 @@
|
|||||||
include_role:
|
include_role:
|
||||||
name: sys-stk-full-stateless
|
name: sys-stk-full-stateless
|
||||||
|
|
||||||
- name: "Include front proxy for {{ container_hostname }}:{{ ports.localhost.http[application_id] }}"
|
- name: "Include front proxy for {{ container_hostname}}:{{ ports.localhost.http[application_id] }}"
|
||||||
include_role:
|
include_role:
|
||||||
name: sys-stk-front-proxy
|
name: sys-stk-front-proxy
|
||||||
vars:
|
|
||||||
domain: "{{ container_hostname }}"
|
|
||||||
http_port: "{{ ports.localhost.http[application_id] }}"
|
|
||||||
|
|
||||||
- name: "Provide Dockerfile"
|
- include_tasks: utils/run_once.yml
|
||||||
copy:
|
|
||||||
src: "Dockerfile"
|
|
||||||
dest: "{{ docker_compose.directories.instance }}/Dockerfile"
|
|
||||||
notify:
|
|
||||||
- docker compose build
|
|
||||||
|
|
||||||
- name: "Run once marker"
|
|
||||||
set_fact:
|
|
||||||
run_once_web_app_bridgy_fed: true
|
|
@@ -1,20 +0,0 @@
|
|||||||
# Administration
|
|
||||||
|
|
||||||
## Local dev shell (inside container)
|
|
||||||
```bash
|
|
||||||
docker compose exec application bash
|
|
||||||
```
|
|
||||||
|
|
||||||
## Logs
|
|
||||||
```bash
|
|
||||||
docker compose logs -f application
|
|
||||||
docker compose logs -f emulator # if enabled
|
|
||||||
```
|
|
||||||
|
|
||||||
## Notes
|
|
||||||
- Upstream dev run example:
|
|
||||||
```bash
|
|
||||||
export APPVIEW_HOST=api.bsky.app PLC_HOST=plc.directory BGS_HOST=bsky.network PDS_HOST=atproto.brid.gy
|
|
||||||
flask --debug run -p 8080
|
|
||||||
```
|
|
||||||
(We run via gunicorn in this role.)
|
|
@@ -6,38 +6,15 @@
|
|||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
args:
|
args:
|
||||||
BRIDGY_REPO_URL: "{{ BRIDGY_REPO_URL }}"
|
BRIDGY_REPO_URL: "{{ BRIDGY_REPO_URL }}"
|
||||||
BRIDGY_REPO_REF: "{{ BRIDGY_REPO_REF }}"
|
BRIDGY_REPO_BRANCH: "{{ BRIDGY_REPO_BRANCH }}"
|
||||||
CONTAINER_PORT: "{{ container_port | string }}"
|
CONTAINER_PORT: "{{ container_port | string }}"
|
||||||
image: "{{ BRIDGY_IMAGE }}"
|
image: "{{ BRIDGY_IMAGE }}:{{ BRIDGY_VERSION }}"
|
||||||
container_name: "{{ BRIDGY_CONTAINER }}"
|
container_name: "{{ BRIDGY_CONTAINER }}"
|
||||||
hostname: "{{ container_hostname }}"
|
hostname: "{{ container_hostname }}"
|
||||||
env_file:
|
|
||||||
- "{{ docker_compose.files.env }}"
|
|
||||||
ports:
|
ports:
|
||||||
- "127.0.0.1:{{ ports.localhost.http[application_id] }}:{{ container_port }}"
|
- "127.0.0.1:{{ http_port }}:{{ container_port }}"
|
||||||
{% include 'roles/docker-container/templates/healthcheck/tcp.yml.j2' %}
|
{% include 'roles/docker-container/templates/healthcheck/tcp.yml.j2' %}
|
||||||
{% include 'roles/docker-container/templates/base.yml.j2' %}
|
{% include 'roles/docker-container/templates/base.yml.j2' %}
|
||||||
depends_on:
|
|
||||||
{% if EMULATOR_ENABLED | bool %}
|
|
||||||
- emulator
|
|
||||||
{% endif %}
|
|
||||||
{% include 'roles/docker-container/templates/networks.yml.j2' %}
|
{% include 'roles/docker-container/templates/networks.yml.j2' %}
|
||||||
|
|
||||||
{% if EMULATOR_ENABLED | bool %}
|
|
||||||
emulator:
|
|
||||||
image: "{{ EMULATOR_IMAGE }}"
|
|
||||||
container_name: "{{ BRIDGY_CONTAINER }}_emulator"
|
|
||||||
command: >
|
|
||||||
gcloud emulators firestore start
|
|
||||||
--host-port=0.0.0.0:{{ EMULATOR_PORT }}
|
|
||||||
--database-mode=datastore-mode
|
|
||||||
--quiet
|
|
||||||
ports:
|
|
||||||
- "127.0.0.1:{{ EMULATOR_PORT }}:{{ EMULATOR_PORT }}"
|
|
||||||
environment:
|
|
||||||
- CLOUDSDK_CORE_DISABLE_PROMPTS=1
|
|
||||||
restart: unless-stopped
|
|
||||||
{% include 'roles/docker-container/templates/networks.yml.j2' %}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
|
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
|
||||||
|
@@ -1,18 +1,13 @@
|
|||||||
# Flask / Gunicorn basics
|
# Flask / Gunicorn basics
|
||||||
FLASK_ENV="{{ ENVIRONMENT | default('production') }}"
|
FLASK_ENV="{{ ENVIRONMENT }}"
|
||||||
PORT="{{ container_port }}"
|
PORT="{{ container_port }}"
|
||||||
BRIDGY_ADMIN_EMAIL="{{ BRIDGY_ADMIN_EMAIL }}"
|
BRIDGY_ADMIN_EMAIL="{{ BRIDGY_ADMIN_EMAIL }}"
|
||||||
|
|
||||||
# Bridgy Fed upstream knobs (see README @ GitHub)
|
# Bridgy Fed upstream knobs (see README @ GitHub)
|
||||||
APPVIEW_HOST="{{ APPVIEW_HOST }}"
|
BRIDGY_APPVIEW_HOST="{{ BRIDGY_APPVIEW_HOST }}"
|
||||||
PLC_HOST="{{ PLC_HOST }}"
|
BRIDGY_PLC_HOST="{{ BRIDGY_PLC_HOST }}"
|
||||||
BGS_HOST="{{ BGS_HOST }}"
|
BRIDGY_BGS_HOST="{{ BRIDGY_BGS_HOST }}"
|
||||||
PDS_HOST="{{ PDS_HOST }}"
|
BRIDGY_PDS_HOST="{{ BRIDGY_PDS_HOST }}"
|
||||||
|
|
||||||
# Datastore emulator (Datastore-mode Firestore). If sidecar enabled, point here.
|
|
||||||
GOOGLE_CLOUD_PROJECT="{{ EMULATOR_PROJECT_ID }}"
|
|
||||||
DATASTORE_EMULATOR_HOST="{{ EMULATOR_ENABLED | ternary(EMULATOR_HOST_INTERNAL, '') }}"
|
|
||||||
# DATASTORE_DATASET not needed when GOOGLE_CLOUD_PROJECT is set
|
|
||||||
|
|
||||||
# Optional:
|
# Optional:
|
||||||
# GUNICORN_CMD_ARGS="--log-level info"
|
# GUNICORN_CMD_ARGS="--log-level info"
|
||||||
|
@@ -1,27 +1,25 @@
|
|||||||
# General
|
# General
|
||||||
application_id: "web-app-bridgy-fed"
|
application_id: "web-app-bridgy-fed"
|
||||||
|
|
||||||
|
# Container
|
||||||
|
container_port: 8080
|
||||||
|
domain: "{{ container_hostname }}"
|
||||||
|
http_port: "{{ ports.localhost.http[application_id] }}"
|
||||||
|
container_hostname: "{{ domains | get_domain(application_id) }}"
|
||||||
|
|
||||||
# App container
|
# App container
|
||||||
BRIDGY_CONTAINER: "{{ applications | get_app_conf(application_id, 'docker.services.application.name') }}"
|
BRIDGY_CONTAINER: "{{ applications | get_app_conf(application_id, 'docker.services.application.name') }}"
|
||||||
BRIDGY_IMAGE: "{{ applications | get_app_conf(application_id, 'docker.services.application.image') }}"
|
BRIDGY_IMAGE: "{{ applications | get_app_conf(application_id, 'docker.services.application.image') }}"
|
||||||
#BRIDGY_VERSION: "{{ applications | get_app_conf(application_id, 'docker.services.application.version')}}"
|
BRIDGY_VERSION: "{{ applications | get_app_conf(application_id, 'docker.services.application.version')}}"
|
||||||
container_port: 8080
|
|
||||||
container_hostname: "{{ domains | get_domain(application_id) }}"
|
BRIDGY_ADMIN_EMAIL: "{{ users.administrator.email }}"
|
||||||
BRIDGY_ADMIN_EMAIL: "{{ users.administrator.email }}"
|
|
||||||
|
|
||||||
# Source
|
# Source
|
||||||
BRIDGY_REPO_URL: "{{ applications | get_app_conf(application_id, 'source.repo') }}"
|
BRIDGY_REPO_URL: "{{ applications | get_app_conf(application_id, 'docker.services.application.repository') }}"
|
||||||
BRIDGY_REPO_REF: "{{ applications | get_app_conf(application_id, 'source.ref') }}"
|
BRIDGY_REPO_BRANCH: "{{ applications | get_app_conf(application_id, 'docker.services.application.branch') }}"
|
||||||
|
|
||||||
# Emulator sidecar (Datastore-mode Firestore)
|
|
||||||
EMULATOR_ENABLED: "{{ applications | get_app_conf(application_id, 'docker.services.emulator.enabled') }}"
|
|
||||||
EMULATOR_IMAGE: "{{ applications | get_app_conf(application_id, 'docker.services.emulator.image') }}"
|
|
||||||
EMULATOR_PORT: 8089
|
|
||||||
EMULATOR_HOST_INTERNAL: "emulator:8089"
|
|
||||||
EMULATOR_PROJECT_ID: "bridgy-federated-local"
|
|
||||||
|
|
||||||
# Runtime env defaults for Bridgy Fed (see upstream README)
|
# Runtime env defaults for Bridgy Fed (see upstream README)
|
||||||
APPVIEW_HOST: "api.bsky.app"
|
BRIDGY_APPVIEW_HOST: "api.bsky.app"
|
||||||
PLC_HOST: "plc.directory"
|
BRIDGY_PLC_HOST: "plc.directory"
|
||||||
BGS_HOST: "bsky.network"
|
BRIDGY_BGS_HOST: "bsky.network"
|
||||||
PDS_HOST: "atproto.brid.gy"
|
BRIDGY_PDS_HOST: "atproto.brid.gy"
|
||||||
|
Reference in New Issue
Block a user