diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 2a2208e..11ad91f 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -7,6 +7,7 @@ on: env: REGISTRY: registry.rose-ash.com:5000 IMAGE: blog + REPO_DIR: /root/blog jobs: build-and-deploy: @@ -33,9 +34,10 @@ jobs: DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }} run: | ssh "root@$DEPLOY_HOST" " - cd /root/blog + cd ${{ env.REPO_DIR }} git fetch origin main git reset --hard origin/main + git submodule update --init --recursive " - name: Build and push image @@ -43,8 +45,10 @@ jobs: DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }} run: | ssh "root@$DEPLOY_HOST" " - cd /root/blog - docker build --build-arg CACHEBUST=\$(date +%s) -t ${{ env.REGISTRY }}/${{ env.IMAGE }}:latest -t ${{ env.REGISTRY }}/${{ env.IMAGE }}:${{ github.sha }} . + 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 push ${{ env.REGISTRY }}/${{ env.IMAGE }}:latest docker push ${{ env.REGISTRY }}/${{ env.IMAGE }}:${{ github.sha }} " @@ -54,10 +58,10 @@ jobs: DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }} run: | ssh "root@$DEPLOY_HOST" " - cd /root/blog + cd /root/coop source .env - docker stack deploy -c docker-compose.yml blog + docker stack deploy -c docker-compose.yml coop echo 'Waiting for services to update...' sleep 10 - docker stack services blog + docker stack services coop " diff --git a/Dockerfile b/Dockerfile index b5ff8d0..1cc07b8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,7 +16,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ postgresql-client \ && rm -rf /var/lib/apt/lists/* -COPY requirements.txt ./requirements.txt +COPY shared_lib/requirements.txt ./requirements.txt RUN pip install -r requirements.txt COPY . . diff --git a/entrypoint.sh b/entrypoint.sh index dd1352c..54265f5 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -10,9 +10,11 @@ if [[ -n "${DATABASE_HOST:-}" && -n "${DATABASE_PORT:-}" ]]; then done fi -# Run DB migrations (uses alembic.ini/env.py to resolve the DB URL) -echo "Running Alembic migrations..." -alembic upgrade head +# Run DB migrations only if RUN_MIGRATIONS=true (blog service only) +if [[ "${RUN_MIGRATIONS:-}" == "true" ]]; then + echo "Running Alembic migrations..." + alembic upgrade head +fi # Clear Redis page cache on deploy if [[ -n "${REDIS_URL:-}" && "${REDIS_URL}" != "no" ]]; then @@ -26,6 +28,5 @@ print('Redis cache cleared.') fi # Start the app -# APP_MODULE can be overridden per-service (e.g. apps.market.app:app) -echo "Starting Hypercorn (${APP_MODULE:-suma_browser.app.app:app})..." -PYTHONUNBUFFERED=1 exec hypercorn "${APP_MODULE:-suma_browser.app.app:app}" --bind 0.0.0.0:${PORT:-8000} +echo "Starting Hypercorn (${APP_MODULE:-app:app})..." +PYTHONUNBUFFERED=1 exec hypercorn "${APP_MODULE:-app:app}" --bind 0.0.0.0:${PORT:-8000}