fix: Dockerfile, entrypoint, and CI for multi-repo deployment
Some checks failed
Build and Deploy / build-and-deploy (push) Has been cancelled
Some checks failed
Build and Deploy / build-and-deploy (push) Has been cancelled
- Fix requirements.txt path to shared_lib/requirements.txt - Remove alembic migrations (managed by blog service) - Fix APP_MODULE default to app:app - CI: add git submodule update, deploy shared coop stack from /root/coop Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,7 @@ on:
|
|||||||
env:
|
env:
|
||||||
REGISTRY: registry.rose-ash.com:5000
|
REGISTRY: registry.rose-ash.com:5000
|
||||||
IMAGE: cart
|
IMAGE: cart
|
||||||
|
REPO_DIR: /root/cart
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-deploy:
|
build-and-deploy:
|
||||||
@@ -33,9 +34,10 @@ jobs:
|
|||||||
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
||||||
run: |
|
run: |
|
||||||
ssh "root@$DEPLOY_HOST" "
|
ssh "root@$DEPLOY_HOST" "
|
||||||
cd /root/cart
|
cd ${{ env.REPO_DIR }}
|
||||||
git fetch origin main
|
git fetch origin main
|
||||||
git reset --hard origin/main
|
git reset --hard origin/main
|
||||||
|
git submodule update --init --recursive
|
||||||
"
|
"
|
||||||
|
|
||||||
- name: Build and push image
|
- name: Build and push image
|
||||||
@@ -43,8 +45,10 @@ jobs:
|
|||||||
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
||||||
run: |
|
run: |
|
||||||
ssh "root@$DEPLOY_HOST" "
|
ssh "root@$DEPLOY_HOST" "
|
||||||
cd /root/cart
|
cd ${{ env.REPO_DIR }}
|
||||||
docker build --build-arg CACHEBUST=\$(date +%s) -t ${{ env.REGISTRY }}/${{ env.IMAGE }}:latest -t ${{ env.REGISTRY }}/${{ env.IMAGE }}:${{ github.sha }} .
|
docker build --build-arg CACHEBUST=\$(date +%s) \
|
||||||
|
-t ${{ env.REGISTRY }}/${{ env.IMAGE }}:latest \
|
||||||
|
-t ${{ env.REGISTRY }}/${{ env.IMAGE }}:${{ github.sha }} .
|
||||||
docker push ${{ env.REGISTRY }}/${{ env.IMAGE }}:latest
|
docker push ${{ env.REGISTRY }}/${{ env.IMAGE }}:latest
|
||||||
docker push ${{ env.REGISTRY }}/${{ env.IMAGE }}:${{ github.sha }}
|
docker push ${{ env.REGISTRY }}/${{ env.IMAGE }}:${{ github.sha }}
|
||||||
"
|
"
|
||||||
@@ -54,10 +58,10 @@ jobs:
|
|||||||
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
||||||
run: |
|
run: |
|
||||||
ssh "root@$DEPLOY_HOST" "
|
ssh "root@$DEPLOY_HOST" "
|
||||||
cd /root/cart
|
cd /root/coop
|
||||||
source .env
|
source .env
|
||||||
docker stack deploy -c docker-compose.yml cart
|
docker stack deploy -c docker-compose.yml coop
|
||||||
echo 'Waiting for services to update...'
|
echo 'Waiting for services to update...'
|
||||||
sleep 10
|
sleep 10
|
||||||
docker stack services cart
|
docker stack services coop
|
||||||
"
|
"
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|||||||
postgresql-client \
|
postgresql-client \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
COPY requirements.txt ./requirements.txt
|
COPY shared_lib/requirements.txt ./requirements.txt
|
||||||
RUN pip install -r requirements.txt
|
RUN pip install -r requirements.txt
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|||||||
@@ -10,9 +10,8 @@ if [[ -n "${DATABASE_HOST:-}" && -n "${DATABASE_PORT:-}" ]]; then
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Run DB migrations (uses alembic.ini/env.py to resolve the DB URL)
|
# NOTE: Cart app does NOT run Alembic migrations.
|
||||||
echo "Running Alembic migrations..."
|
# Migrations are managed by the blog app which owns the shared database schema.
|
||||||
alembic upgrade head
|
|
||||||
|
|
||||||
# Clear Redis page cache on deploy
|
# Clear Redis page cache on deploy
|
||||||
if [[ -n "${REDIS_URL:-}" && "${REDIS_URL}" != "no" ]]; then
|
if [[ -n "${REDIS_URL:-}" && "${REDIS_URL}" != "no" ]]; then
|
||||||
@@ -26,6 +25,5 @@ print('Redis cache cleared.')
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Start the app
|
# Start the app
|
||||||
# APP_MODULE can be overridden per-service (e.g. apps.market.app:app)
|
echo "Starting Hypercorn (${APP_MODULE:-app:app})..."
|
||||||
echo "Starting Hypercorn (${APP_MODULE:-suma_browser.app.app:app})..."
|
PYTHONUNBUFFERED=1 exec hypercorn "${APP_MODULE:-app:app}" --bind 0.0.0.0:${PORT:-8000}
|
||||||
PYTHONUNBUFFERED=1 exec hypercorn "${APP_MODULE:-suma_browser.app.app:app}" --bind 0.0.0.0:${PORT:-8000}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user