perf: optimize CI pipeline — eliminate double dependency installs, use local registry cache

- Frontend Dockerfile: split into deps/test/builder/nginx stages so npm ci
  runs once (cached when package-lock.json unchanged), tests run in build
- Backend Dockerfile: add test stage that runs pytest inside the build,
  eliminating separate test image build
- .drone.yml: remove separate test steps (now inside Dockerfile builds),
  point cache_from/cache_repo at local registry (10.0.20.10:5000) instead
  of Docker Hub for faster layer cache pulls
This commit is contained in:
Viktor Barzin 2026-02-21 15:10:55 +00:00
parent 68859ae577
commit b1be4d4170
No known key found for this signature in database
GPG key ID: 0EB088298288D958
3 changed files with 68 additions and 49 deletions

View file

@ -30,17 +30,7 @@ steps:
exit 1
- git checkout "$DRONE_COMMIT"
- name: Run frontend tests
image: node:24-alpine
resources:
limits:
memory: 2048MiB
commands:
- cd frontend
- npm ci
- npx vitest run
- name: Build frontend image
- name: Build and test frontend image
image: plugins/kaniko
resources:
limits:
@ -53,10 +43,30 @@ steps:
dockerfile: frontend/Dockerfile
context: frontend
enable_cache: true
cache_repo: viktorbarzin/immoweb-cache
cache_repo: 10.0.20.10:5000/immoweb-cache
registry: 10.0.20.10:5000
insecure: true
tags:
- latest
- ${DRONE_BUILD_NUMBER}
- "${DRONE_BUILD_NUMBER}"
- name: Push to Docker Hub
image: plugins/kaniko
resources:
limits:
memory: 512MiB
settings:
username: viktorbarzin
password:
from_secret: dockerhub-token
repo: viktorbarzin/immoweb
dockerfile: frontend/Dockerfile
context: frontend
enable_cache: true
cache_repo: 10.0.20.10:5000/immoweb-cache
tags:
- latest
- "${DRONE_BUILD_NUMBER}"
- name: Update deployment
image: alpine
@ -131,42 +141,38 @@ steps:
exit 1
- git checkout "$DRONE_COMMIT"
- name: Cache test image
- name: Build and test API image
image: plugins/docker
settings:
username: viktorbarzin
password:
from_secret: dockerhub-token
repo: viktorbarzin/realestatecrawler
repo: 10.0.20.10:5000/viktorbarzin/realestatecrawler
dockerfile: Dockerfile
context: .
target: test
insecure: true
cache_from:
- viktorbarzin/realestatecrawler:test
- viktorbarzin/realestatecrawler:builder
tags:
- test
- name: Run backend tests
image: viktorbarzin/realestatecrawler:test
commands:
- pytest tests/ -x -q
- name: Build API image
image: plugins/docker
settings:
username: viktorbarzin
password:
from_secret: dockerhub-token
repo: viktorbarzin/realestatecrawler
dockerfile: Dockerfile
context: .
cache_from:
- viktorbarzin/realestatecrawler:builder
- viktorbarzin/realestatecrawler:latest
- 10.0.20.10:5000/viktorbarzin/realestatecrawler:latest
- 10.0.20.10:5000/viktorbarzin/realestatecrawler:builder
tags:
- latest
- ${DRONE_BUILD_NUMBER}
- builder
- "${DRONE_BUILD_NUMBER}"
- name: Push to Docker Hub
image: plugins/docker
settings:
username: viktorbarzin
password:
from_secret: dockerhub-token
repo: viktorbarzin/realestatecrawler
dockerfile: Dockerfile
context: .
cache_from:
- 10.0.20.10:5000/viktorbarzin/realestatecrawler:latest
tags:
- latest
- "${DRONE_BUILD_NUMBER}"
- name: Update deployment
image: alpine