normogen/backend/DOCKER-COMMANDS.md

52 lines
1.5 KiB
Markdown

# Quick Fix Commands
## The Problem
Docker is using cached layers from the old Dockerfile. Even though we updated the file,
Docker's build cache still has the old `FROM rust:latest` with `apk` commands.
## Solution Options
### Option 1: Rebuild without cache (RECOMMENDED)
```bash
cd /home/asoliver/desarrollo/normogen/backend
docker compose -f docker-compose.dev.yml build --no-cache
docker compose -f docker-compose.dev.yml up -d
```
### Option 2: Clear all Docker build cache first
```bash
# Clear Docker's build cache
docker builder prune -af
# Then rebuild
cd /home/asoliver/desarrollo/normogen/backend
docker compose -f docker-compose.dev.yml up -d --build
```
### Option 3: Use the provided script
```bash
cd /home/asoliver/desarrollo/normogen/backend
chmod +x fix-docker-build.sh
./fix-docker-build.sh
```
## Why This Happened
- Docker caches build layers to speed up subsequent builds
- When we changed `FROM rust:latest` to `FROM rust:1.93-slim`, Docker should have invalidated the cache
- But sometimes Docker's cache gets confused, especially with `latest` tags
- The `--no-cache` flag forces Docker to ignore all cached layers
## What Changed in the Dockerfile
```dockerfile
# OLD (cached):
FROM rust:latest
RUN apk add --no-cache musl-dev pkgconf openssl-dev...
# NEW (current):
FROM rust:1.93-slim
RUN apt-get update && apt-get install -y pkg-config libssl-dev...
```
The new image uses:
- `rust:1.93-slim` (supports Edition 2024)
- `apt-get` (Debian/Ubuntu package manager) instead of `apk` (Alpine)