wrongmove/.claude/skills/build-and-push.md
Viktor Barzin c7c3331d30
Migrate CI from Drone to Woodpecker
Replace .drone.yml with .woodpecker/ pipeline configs (frontend.yml, api.yml).
Convert Drone env vars to Woodpecker equivalents (CI_PIPELINE_NUMBER, CI_COMMIT_SHA),
use woodpeckerci/plugin-git for clone with retry, woodpeckerci/plugin-slack for
notifications, and plugins/docker for image builds. Update all docs and skills.
2026-02-23 22:00:09 +00:00

113 lines
3.1 KiB
Markdown

---
name: build-and-push
description: |
Build Docker images for the API and frontend, and push them to Docker Hub.
Use when: (1) user wants to build new Docker images locally, (2) push images
to the registry before deploying, (3) tag images for a release. Covers both
the Python/FastAPI backend and the React/Nginx frontend.
author: Claude Code
version: 1.0.0
date: 2026-02-06
---
# Build and Push Docker Images
All commands run locally. Images are pushed to Docker Hub under the `viktorbarzin` namespace.
## Image Registries
| Component | Docker Hub repo | Dockerfile location |
|-----------|------------------------------------|------------------------------|
| API | `viktorbarzin/realestatecrawler` | `Dockerfile` |
| Frontend | `viktorbarzin/immoweb` | `frontend/Dockerfile` |
## Building Images
### Build API image
```bash
docker build -t viktorbarzin/realestatecrawler:latest .
```
### Build Frontend image
```bash
docker build -t viktorbarzin/immoweb:latest frontend/
```
### Build both
```bash
docker build -t viktorbarzin/realestatecrawler:latest . && \
docker build -t viktorbarzin/immoweb:latest frontend/
```
### Build with a specific tag (recommended for production)
```bash
# Use git commit SHA
GIT_SHA=$(git rev-parse --short HEAD)
docker build -t viktorbarzin/realestatecrawler:${GIT_SHA} -t viktorbarzin/realestatecrawler:latest .
docker build -t viktorbarzin/immoweb:${GIT_SHA} -t viktorbarzin/immoweb:latest frontend/
```
## Pushing Images
### Login to Docker Hub (if not already)
```bash
docker login -u viktorbarzin
```
### Push API image
```bash
docker push viktorbarzin/realestatecrawler:latest
```
### Push Frontend image
```bash
docker push viktorbarzin/immoweb:latest
```
### Push with specific tag
```bash
GIT_SHA=$(git rev-parse --short HEAD)
docker push viktorbarzin/realestatecrawler:${GIT_SHA}
docker push viktorbarzin/realestatecrawler:latest
docker push viktorbarzin/immoweb:${GIT_SHA}
docker push viktorbarzin/immoweb:latest
```
## Build and Push Everything (Full Release)
```bash
GIT_SHA=$(git rev-parse --short HEAD)
# Build
docker build -t viktorbarzin/realestatecrawler:${GIT_SHA} -t viktorbarzin/realestatecrawler:latest .
docker build -t viktorbarzin/immoweb:${GIT_SHA} -t viktorbarzin/immoweb:latest frontend/
# Push
docker push viktorbarzin/realestatecrawler:${GIT_SHA}
docker push viktorbarzin/realestatecrawler:latest
docker push viktorbarzin/immoweb:${GIT_SHA}
docker push viktorbarzin/immoweb:latest
```
## CI/CD Note
Woodpecker CI automatically builds and pushes images on push to `master` (see `.woodpecker/`).
The manual process above is for when you need to build/push outside of CI, such as:
- Hotfix deployments
- Testing image builds locally before pushing
- Deploying from a non-master branch
## Notes
- The API Dockerfile installs system deps (OpenCV, Tesseract, MariaDB client) and Python deps via Poetry
- The Frontend Dockerfile is a multi-stage build: Node builder -> Nginx runtime
- Always tag with both `:latest` and a specific tag (git SHA or version) for traceability
- Use `docker buildx` for cross-platform builds if deploying to ARM nodes