feat(share): add local docker publisher flow

This commit is contained in:
Benjamin Shafii
2026-03-13 13:32:23 -07:00
parent f66d1ded5e
commit 9502137dd4
6 changed files with 143 additions and 5 deletions

View File

@@ -33,10 +33,13 @@ Optional env vars (via `.env` or `export`):
- `OPENWORK_WORKSPACE` — host path to mount as workspace
- `OPENWORK_PORT` — host port to map to container :8787
- `WEB_PORT` — host port to map to container :5173
- `SHARE_PORT` — host port to map to the local share service :3000
- `OPENWORK_DOCKER_DEV_MOUNT_HOST_OPENCODE=1` — import host OpenCode config/auth into the isolated dev state
- `OPENWORK_OPENCODE_CONFIG_DIR` — override the host OpenCode config source used for that optional import
- `OPENWORK_OPENCODE_DATA_DIR` — override the host OpenCode data source used for that optional import
The dev stack also starts the local share service automatically and points the OpenWork app at it, so share-link flows publish to a local service instead of `https://share.openwork.software`.
---
## Den local stack (Docker)

View File

@@ -13,6 +13,7 @@ set -euo pipefail
# Outputs:
# - Web UI URL
# - OpenWork server URL
# - Share service URL
# - Token file path
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
@@ -140,10 +141,15 @@ WEB_PORT="$(pick_port)"
if [ "$WEB_PORT" = "$OPENWORK_PORT" ]; then
WEB_PORT="$(pick_port)"
fi
SHARE_PORT="${SHARE_PORT:-$(pick_port)}"
if [ "$SHARE_PORT" = "$OPENWORK_PORT" ] || [ "$SHARE_PORT" = "$WEB_PORT" ]; then
SHARE_PORT="$(pick_port)"
fi
echo "Starting Docker Compose project: $PROJECT" >&2
echo "- OPENWORK_PORT=$OPENWORK_PORT" >&2
echo "- WEB_PORT=$WEB_PORT" >&2
echo "- SHARE_PORT=$SHARE_PORT" >&2
echo "- OPENWORK_DEV_MODE=1" >&2
if [ "$MOUNT_HOST_OPENCODE" = "1" ]; then
echo "- Host OpenCode import: enabled" >&2
@@ -154,7 +160,7 @@ fi
start_stack() {
local config_dir="$1"
local data_dir="$2"
OPENWORK_DEV_ID="$DEV_ID" OPENWORK_PORT="$OPENWORK_PORT" WEB_PORT="$WEB_PORT" \
OPENWORK_DEV_ID="$DEV_ID" OPENWORK_PORT="$OPENWORK_PORT" WEB_PORT="$WEB_PORT" SHARE_PORT="$SHARE_PORT" \
OPENWORK_DEV_MODE="1" \
OPENWORK_HOST_OPENCODE_CONFIG_DIR="$config_dir" \
OPENWORK_HOST_OPENCODE_DATA_DIR="$data_dir" \
@@ -184,6 +190,7 @@ fi
echo "" >&2
echo "OpenWork web UI: http://localhost:$WEB_PORT" >&2
echo "OpenWork server: http://localhost:$OPENWORK_PORT" >&2
echo "Share service: http://localhost:$SHARE_PORT" >&2
echo "Token file: $ROOT_DIR/tmp/.dev-env-$DEV_ID" >&2
echo "" >&2
echo "To stop this stack:" >&2

View File

@@ -11,6 +11,7 @@
# OPENWORK_WORKSPACE — host path to mount as workspace (default: ./workspace)
# OPENWORK_PORT — host port to map to container :8787 (default: 8787)
# WEB_PORT — host port to map to container :5173 (default: 5173)
# SHARE_PORT — host port to map to the share service :3000 (default: 3006)
# OPENWORK_DEV_ID — unique ID for this stack (default: default)
# OPENWORK_DEV_MODE — enables isolated OpenCode dev state (set by dev-up.sh)
# OPENWORK_DOCKER_DEV_MOUNT_HOST_OPENCODE=1 — import host OpenCode config/auth into the isolated dev state
@@ -151,6 +152,8 @@ services:
depends_on:
orchestrator:
condition: service_healthy
share:
condition: service_healthy
entrypoint: ["/bin/sh", "-c"]
command:
- |
@@ -184,6 +187,7 @@ services:
export VITE_OPENWORK_URL="http://localhost:${OPENWORK_PORT:-8787}"
export VITE_OPENWORK_PORT="${OPENWORK_PORT:-8787}"
export VITE_OPENWORK_PUBLISHER_BASE_URL="http://localhost:${SHARE_PORT:-3006}"
export VITE_ALLOWED_HOSTS="all"
export HOST="0.0.0.0"
export PORT="5173"
@@ -197,6 +201,49 @@ services:
environment:
OPENWORK_DEV_ID: ${OPENWORK_DEV_ID:-default}
share:
<<: *shared
entrypoint: ["/bin/sh", "-c"]
command:
- |
set -e
apt-get update -qq && apt-get install -y -qq --no-install-recommends \
curl ca-certificates >/dev/null 2>&1
corepack enable && corepack prepare pnpm@10.27.0 --activate
echo "[share] Installing dependencies..."
pnpm install --no-frozen-lockfile --network-concurrency 1 --child-concurrency 1
mkdir -p /app/tmp/share-service-blobs
echo "[share] Building Next app..."
pnpm --dir services/openwork-share build
echo ""
echo "============================================"
echo " OpenWork share service"
echo " URL: http://localhost:${SHARE_PORT:-3006}"
echo "============================================"
echo ""
exec pnpm --dir services/openwork-share exec next start --hostname 0.0.0.0 --port 3000
ports:
- "${SHARE_PORT:-3006}:3000"
healthcheck:
test: ["CMD-SHELL", "curl -sf http://localhost:3000/api/health || exit 1"]
interval: 5s
timeout: 10s
retries: 30
start_period: 180s
environment:
CI: "true"
OPENWORK_DEV_MODE: ${OPENWORK_DEV_MODE:-1}
LOCAL_BLOB_DIR: /app/tmp/share-service-blobs
PUBLIC_BASE_URL: http://localhost:${SHARE_PORT:-3006}
PUBLIC_OPENWORK_APP_URL: http://localhost:${WEB_PORT:-5173}
volumes:
pnpm-store:
name: openwork-dev-pnpm-store