Skip to content
Merged
53 changes: 46 additions & 7 deletions .github/workflows/06-railway-preview-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,35 @@ jobs:
run: |
PR="${{ github.event.pull_request.number || inputs.pr_number }}"
SHA="$(git rev-parse --short HEAD)"
TAG="pr-${PR}-${SHA}"

if [ -n "$PR" ]; then
TAG="pr-${PR}-${SHA}"
else
TAG="manual-${SHA}"
fi

echo "image_tag=${TAG}" >> "$GITHUB_OUTPUT"
echo "pr_number=${PR}" >> "$GITHUB_OUTPUT"
echo "Image tag: ${TAG}"

- name: Determine cache scope
id: cache
run: |
PR="${{ steps.tag.outputs.pr_number }}"
if [ -n "$PR" ]; then
CACHE_SCOPE="pr-${PR}"
else
REF="$(printf "%s" "${GITHUB_REF_NAME}" | tr '[:upper:]' '[:lower:]' | tr -cs 'a-z0-9._-' '-')"
REF="${REF#-}"
REF="${REF%-}"
CACHE_SCOPE="${REF:-manual}"
fi

CACHE_SCOPE="${CACHE_SCOPE:0:80}"

echo "cache_scope=${CACHE_SCOPE}" >> "$GITHUB_OUTPUT"
echo "Cache scope: ${CACHE_SCOPE}"

- name: Log in to GHCR
uses: docker/login-action@v3
with:
Expand All @@ -63,8 +87,12 @@ jobs:
file: api/oss/docker/Dockerfile.gh
push: true
tags: ghcr.io/agenta-ai/agenta-api:${{ steps.tag.outputs.image_tag }}
cache-from: type=gha,scope=api
cache-to: type=gha,mode=max,scope=api
cache-from: |
type=registry,ref=ghcr.io/agenta-ai/agenta-api:buildcache-shared
type=registry,ref=ghcr.io/agenta-ai/agenta-api:buildcache-${{ steps.cache.outputs.cache_scope }}
cache-to: |
type=registry,ref=ghcr.io/agenta-ai/agenta-api:buildcache-shared,mode=max
type=registry,ref=ghcr.io/agenta-ai/agenta-api:buildcache-${{ steps.cache.outputs.cache_scope }},mode=max

- name: Build and push Web image
uses: docker/build-push-action@v6
Expand All @@ -73,8 +101,12 @@ jobs:
file: web/oss/docker/Dockerfile.gh
push: true
tags: ghcr.io/agenta-ai/agenta-web:${{ steps.tag.outputs.image_tag }}
cache-from: type=gha,scope=web
cache-to: type=gha,mode=max,scope=web
cache-from: |
type=registry,ref=ghcr.io/agenta-ai/agenta-web:buildcache-shared
type=registry,ref=ghcr.io/agenta-ai/agenta-web:buildcache-${{ steps.cache.outputs.cache_scope }}
cache-to: |
type=registry,ref=ghcr.io/agenta-ai/agenta-web:buildcache-shared,mode=max
type=registry,ref=ghcr.io/agenta-ai/agenta-web:buildcache-${{ steps.cache.outputs.cache_scope }},mode=max

- name: Build and push Services image
uses: docker/build-push-action@v6
Expand All @@ -83,8 +115,12 @@ jobs:
file: services/oss/docker/Dockerfile.gh
push: true
tags: ghcr.io/agenta-ai/agenta-services:${{ steps.tag.outputs.image_tag }}
cache-from: type=gha,scope=services
cache-to: type=gha,mode=max,scope=services
cache-from: |
type=registry,ref=ghcr.io/agenta-ai/agenta-services:buildcache-shared
type=registry,ref=ghcr.io/agenta-ai/agenta-services:buildcache-${{ steps.cache.outputs.cache_scope }}
cache-to: |
type=registry,ref=ghcr.io/agenta-ai/agenta-services:buildcache-shared,mode=max
type=registry,ref=ghcr.io/agenta-ai/agenta-services:buildcache-${{ steps.cache.outputs.cache_scope }},mode=max

- name: Summary
run: |
Expand All @@ -96,6 +132,9 @@ jobs:
echo "| agenta-api | \`${TAG}\` |" >> "$GITHUB_STEP_SUMMARY"
echo "| agenta-web | \`${TAG}\` |" >> "$GITHUB_STEP_SUMMARY"
echo "| agenta-services | \`${TAG}\` |" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "- Cache scope: \`${{ steps.cache.outputs.cache_scope }}\`" >> "$GITHUB_STEP_SUMMARY"
echo "- Shared cache: \`buildcache-shared\`" >> "$GITHUB_STEP_SUMMARY"

deploy:
needs: build-and-push
Expand Down
5 changes: 4 additions & 1 deletion hosting/railway/oss/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ The API image defaults to docker-compose hostnames for Redis (`redis-durable:638

First deploys on Railway take longer because Docker layer caches are cold. The app settle window (`RAILWAY_APP_SETTLE_SECONDS`, default 60) may not be enough on very slow builds. If smoke fails because services are still DEPLOYING, wait and re-run smoke manually.

For GitHub preview builds, CI now uses shared BuildKit registry cache tags (`buildcache-shared`) plus PR-scoped tags (`buildcache-pr-<number>`). This keeps repeated PR builds fast and also improves first builds on new PRs by reusing layers from previous runs. Manual workflow dispatches without a PR number use `manual-<sha>` image tags and skip deploy.

### Smoke check options

The smoke script supports these environment variables:
Expand Down Expand Up @@ -249,7 +251,8 @@ the deploy flow grows or back-to-back deploys hit the 1,000 RPH Hobby ceiling.

## Notes

- This fast-start flow keeps auth minimal (`AGENTA_LICENSE=oss`) and does not wire CI yet.
- This fast-start flow keeps auth minimal (`AGENTA_LICENSE=oss`).
- CI is wired for Railway preview environments via `.github/workflows/06-railway-preview-build.yml`, `.github/workflows/07-railway-preview-deploy.yml`, and `.github/workflows/08-railway-preview-cleanup.yml`.
- Postgres and Redis are provisioned as image-backed services with explicit volume mounts.
- Redis now gets a `/data` volume during bootstrap for persistence.
- Alembic now creates `agenta_oss_core`, `agenta_oss_tracing`, and `agenta_oss_supertokens` automatically before running migrations.
Expand Down
Loading