Refactor Dockerfile and CI workflow for improved dependency management and cleanup
All checks were successful
CI/CD / test-backend (pull_request) Successful in 30s
CI/CD / test-frontend (pull_request) Successful in 11s
CI/CD / build-and-deploy (pull_request) Successful in 5m38s
CI/CD Pipeline / Overall Status ✅ Все проверки прошли успешно
CI/CD / pr-status (pull_request) Successful in 1s

- Updated Dockerfile to optimize layer caching by copying requirements.txt before application code.
- Added caching for pip packages in CI workflow to speed up dependency installation.
- Implemented cleanup of dangling Docker images post-deployment.
This commit is contained in:
2026-04-02 18:50:50 +03:00
parent 4e8300f6f0
commit cc14322c12
2 changed files with 20 additions and 16 deletions

View File

@@ -20,6 +20,12 @@ jobs:
with:
python-version: '3.11'
- name: Cache pip packages
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('api/requirements.txt') }}
- name: Установка зависимостей
run: |
cd api
@@ -112,6 +118,7 @@ jobs:
while [ $elapsed -lt $timeout ]; do
if docker logs fastapi-container 2>&1 | grep -q "Application startup complete"; then
echo "Application startup detected in logs"
echo "Deployment successful!"
exit 0
fi
echo "Waiting for startup log... ($elapsed/$timeout sec)"
@@ -120,8 +127,14 @@ jobs:
done
echo "Timeout: Application startup not detected in logs"
docker logs fastapi-container
echo "Deployment successful!"
exit 1
- name: Clean up dangling images
run: |
echo "Removing old dangling images..."
docker image prune -f
echo "Current images after cleanup:"
docker images
# Явный статус для PR
pr-status: