Update and syc dev branch #3
95
Dockerfile.unified
Normal file
95
Dockerfile.unified
Normal file
@@ -0,0 +1,95 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
# =============================================================================
|
||||
# OmniOil Workspace - Unified Build Pipeline
|
||||
# =============================================================================
|
||||
|
||||
# 1. BASE: Entorno común con todas las dependencias del SO
|
||||
FROM lukemathwalker/cargo-chef:latest-rust-1.93-slim-bookworm AS base
|
||||
WORKDIR /app
|
||||
# Instalar dependencias necesarias para compilar crates de C y GUI (GTK, etc)
|
||||
RUN apt-get update && apt-get install -y \
|
||||
cmake nasm pkg-config libssl-dev libglib2.0-dev libatk1.0-dev libgtk-3-dev build-essential ca-certificates lld \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
# Linker LLD para reducir el tiempo de linkeado significativamente
|
||||
ENV RUSTFLAGS="-C link-arg=-fuse-ld=lld"
|
||||
ENV CARGO_INCREMENTAL=0
|
||||
|
||||
# 2. PLANNER: Analiza todo el workspace de una vez
|
||||
FROM base AS planner
|
||||
COPY . .
|
||||
RUN cargo chef prepare --recipe-path recipe.json
|
||||
|
||||
# 3. CACHER: El motor que compila TODAS las librerías del workspace UNA sola vez
|
||||
FROM base AS cacher
|
||||
COPY --from=planner /app/recipe.json recipe.json
|
||||
# Usamos monturas de caché para el registro (descargas rápidas),
|
||||
# pero dejamos que /app/target se guarde en la imagen para poder copiarla
|
||||
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
||||
--mount=type=cache,target=/usr/local/cargo/git \
|
||||
cargo chef cook --release --recipe-path recipe.json
|
||||
|
||||
# 4. BUILDER-BASE: Etapa base para los builders con el código real y el caché "caliente"
|
||||
FROM base AS builder
|
||||
COPY . .
|
||||
# Copiamos las dependencias ya cocinadas (esto es instantáneo porque ya están en el cacher)
|
||||
COPY --from=cacher /app/target /app/target
|
||||
|
||||
# =============================================================================
|
||||
# INDIVIDUAL SERVICE TARGETS
|
||||
# =============================================================================
|
||||
|
||||
# --- BACKEND-API ---
|
||||
FROM builder AS builder-backend-api
|
||||
RUN cargo build --release -p backend-api
|
||||
|
||||
FROM debian:bookworm-slim AS backend-api
|
||||
WORKDIR /app
|
||||
RUN apt-get update && apt-get install -y libssl3 ca-certificates && rm -rf /var/lib/apt/lists/*
|
||||
COPY --from=builder-backend-api /app/target/release/backend-api .
|
||||
ENV RUST_LOG=info
|
||||
EXPOSE 8000
|
||||
CMD ["./backend-api"]
|
||||
|
||||
# --- DATA-COLLECTOR ---
|
||||
FROM builder AS builder-data-collector
|
||||
RUN cargo build --release -p data-collector
|
||||
|
||||
FROM debian:bookworm-slim AS data-collector
|
||||
WORKDIR /app
|
||||
RUN apt-get update && apt-get install -y libssl3 ca-certificates && rm -rf /var/lib/apt/lists/*
|
||||
COPY --from=builder-data-collector /app/target/release/data-collector .
|
||||
ENV RUST_LOG=info
|
||||
CMD ["./data-collector"]
|
||||
|
||||
# --- JSON-GENERATOR ---
|
||||
FROM builder AS builder-json-generator
|
||||
RUN cargo build --release -p json-generator
|
||||
|
||||
FROM debian:bookworm-slim AS json-generator
|
||||
WORKDIR /app
|
||||
RUN apt-get update && apt-get install -y libssl3 ca-certificates && rm -rf /var/lib/apt/lists/*
|
||||
COPY --from=builder-json-generator /app/target/release/json-generator .
|
||||
ENV RUST_LOG=info
|
||||
CMD ["./json-generator"]
|
||||
|
||||
# --- EVENTS-RELAY ---
|
||||
FROM builder AS builder-events-relay
|
||||
RUN cargo build --release -p events-relay
|
||||
|
||||
FROM debian:bookworm-slim AS events-relay
|
||||
WORKDIR /app
|
||||
RUN apt-get update && apt-get install -y libssl3 ca-certificates && rm -rf /var/lib/apt/lists/*
|
||||
COPY --from=builder-events-relay /app/target/release/events-relay .
|
||||
ENV RUST_LOG=info
|
||||
CMD ["./events-relay"]
|
||||
|
||||
# --- BUILD-ORCHESTRATOR ---
|
||||
FROM builder AS builder-build-orchestrator
|
||||
RUN cargo build --release -p build-orchestrator
|
||||
|
||||
FROM debian:bookworm-slim AS build-orchestrator
|
||||
WORKDIR /app
|
||||
RUN apt-get update && apt-get install -y libssl3 ca-certificates && rm -rf /var/lib/apt/lists/*
|
||||
COPY --from=builder-build-orchestrator /app/target/release/build-orchestrator .
|
||||
ENV RUST_LOG=info
|
||||
CMD ["./build-orchestrator"]
|
||||
@@ -61,7 +61,8 @@ services:
|
||||
restart: always
|
||||
build:
|
||||
context: .
|
||||
dockerfile: services/backend-api/Dockerfile
|
||||
dockerfile: Dockerfile.unified
|
||||
target: backend-api
|
||||
expose:
|
||||
- "8000"
|
||||
environment:
|
||||
@@ -78,7 +79,8 @@ services:
|
||||
restart: always
|
||||
build:
|
||||
context: .
|
||||
dockerfile: services/data-collector/Dockerfile
|
||||
dockerfile: Dockerfile.unified
|
||||
target: data-collector
|
||||
environment:
|
||||
- DATABASE_URL=postgres://${DB_USER:-adminomnioil}:${DB_PASSWORD:-admin123}@timescaledb:5432/${DB_NAME:-omnioil}
|
||||
depends_on:
|
||||
@@ -91,7 +93,8 @@ services:
|
||||
restart: always
|
||||
build:
|
||||
context: .
|
||||
dockerfile: services/events-relay/Dockerfile
|
||||
dockerfile: Dockerfile.unified
|
||||
target: events-relay
|
||||
environment:
|
||||
- DATABASE_URL=postgres://${DB_USER:-adminomnioil}:${DB_PASSWORD:-admin123}@timescaledb:5432/${DB_NAME:-omnioil}
|
||||
- REDIS_URL=redis://redis:6379
|
||||
@@ -106,7 +109,8 @@ services:
|
||||
restart: always
|
||||
build:
|
||||
context: .
|
||||
dockerfile: services/json-generator/Dockerfile
|
||||
dockerfile: Dockerfile.unified
|
||||
target: json-generator
|
||||
environment:
|
||||
- DATABASE_URL=postgres://${DB_USER:-adminomnioil}:${DB_PASSWORD:-admin123}@timescaledb:5432/${DB_NAME:-omnioil}
|
||||
- MINIO_ENDPOINT=http://minio:9000
|
||||
@@ -170,7 +174,8 @@ services:
|
||||
container_name: anh_build_orchestrator
|
||||
build:
|
||||
context: .
|
||||
dockerfile: services/build-orchestrator/Dockerfile
|
||||
dockerfile: Dockerfile.unified
|
||||
target: build-orchestrator
|
||||
environment:
|
||||
- DATABASE_URL=postgres://${DB_USER:-adminomnioil}:${DB_PASSWORD:-admin123}@timescaledb:5432/${DB_NAME:-omnioil}
|
||||
- MQTT_HOST=mosquitto
|
||||
|
||||
@@ -13,21 +13,40 @@ ENV RUSTFLAGS="-C link-arg=-fuse-ld=lld"
|
||||
ENV CARGO_INCREMENTAL=0
|
||||
|
||||
# =============================================================================
|
||||
# 1. PLANNER
|
||||
# 1. PLANNER: Genera el archivo recipe.json para cachear dependencias
|
||||
# =============================================================================
|
||||
FROM base AS planner
|
||||
# Copiar el código fuente para que cargo chef pueda analizar las dependencias
|
||||
COPY . .
|
||||
# Copiamos solo los archivos que definen dependencias (workspace y miembros)
|
||||
COPY Cargo.toml Cargo.lock ./
|
||||
COPY services/shared-lib/Cargo.toml services/shared-lib/Cargo.toml
|
||||
COPY services/flow-generator/Cargo.toml services/flow-generator/Cargo.toml
|
||||
COPY services/backend-api/Cargo.toml services/backend-api/Cargo.toml
|
||||
COPY services/data-collector/Cargo.toml services/data-collector/Cargo.toml
|
||||
COPY services/json-generator/Cargo.toml services/json-generator/Cargo.toml
|
||||
COPY services/events-relay/Cargo.toml services/events-relay/Cargo.toml
|
||||
COPY services/build-orchestrator/Cargo.toml services/build-orchestrator/Cargo.toml
|
||||
COPY services/edge-agent/Cargo.toml services/edge-agent/Cargo.toml
|
||||
|
||||
# Filtrar solo las dependencias necesarias para este binario específico
|
||||
# Creamos estructuras dummy para que cargo metadata no falle (muy importante para la caché)
|
||||
RUN mkdir -p services/shared-lib/src && touch services/shared-lib/src/lib.rs && \
|
||||
mkdir -p services/flow-generator/src && touch services/flow-generator/src/lib.rs && \
|
||||
mkdir -p services/backend-api/src && echo "fn main() {}" > services/backend-api/src/main.rs && \
|
||||
mkdir -p services/data-collector/src && echo "fn main() {}" > services/data-collector/src/main.rs && \
|
||||
mkdir -p services/json-generator/src && echo "fn main() {}" > services/json-generator/src/main.rs && \
|
||||
mkdir -p services/events-relay/src && echo "fn main() {}" > services/events-relay/src/main.rs && \
|
||||
mkdir -p services/build-orchestrator/src && echo "fn main() {}" > services/build-orchestrator/src/main.rs && \
|
||||
mkdir -p services/edge-agent/src && echo "fn main() {}" > services/edge-agent/src/main.rs
|
||||
|
||||
# Generamos la receta solo para este binario
|
||||
RUN cargo chef prepare --recipe-path recipe.json --bin backend-api
|
||||
|
||||
# =============================================================================
|
||||
# 2. CACHER
|
||||
# 2. CACHER: Descarga y compila las dependencias (etapa lenta)
|
||||
# =============================================================================
|
||||
FROM base AS cacher
|
||||
COPY --from=planner /app/recipe.json recipe.json
|
||||
RUN cargo chef cook --release --recipe-path recipe.json
|
||||
# Cook solo lo necesario para este binario para máxima velocidad
|
||||
RUN cargo chef cook --release --recipe-path recipe.json --bin backend-api
|
||||
|
||||
# =============================================================================
|
||||
# 3. BUILDER
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// Dummy comment to verify Docker cache hitting
|
||||
// Second comment for extra verification
|
||||
// Third comment for unified build verification
|
||||
use axum::{
|
||||
http::StatusCode,
|
||||
response::{IntoResponse, Json, Response},
|
||||
|
||||
@@ -12,21 +12,40 @@ ENV RUSTFLAGS="-C link-arg=-fuse-ld=lld"
|
||||
ENV CARGO_INCREMENTAL=0
|
||||
|
||||
# =============================================================================
|
||||
# 1. PLANNER
|
||||
# 1. PLANNER: Genera el archivo recipe.json para cachear dependencias
|
||||
# =============================================================================
|
||||
FROM base AS planner
|
||||
# Copiar el código fuente para que cargo chef pueda analizar las dependencias
|
||||
COPY . .
|
||||
# Copiamos solo los archivos que definen dependencias (workspace y miembros)
|
||||
COPY Cargo.toml Cargo.lock ./
|
||||
COPY services/shared-lib/Cargo.toml services/shared-lib/Cargo.toml
|
||||
COPY services/flow-generator/Cargo.toml services/flow-generator/Cargo.toml
|
||||
COPY services/backend-api/Cargo.toml services/backend-api/Cargo.toml
|
||||
COPY services/data-collector/Cargo.toml services/data-collector/Cargo.toml
|
||||
COPY services/json-generator/Cargo.toml services/json-generator/Cargo.toml
|
||||
COPY services/events-relay/Cargo.toml services/events-relay/Cargo.toml
|
||||
COPY services/build-orchestrator/Cargo.toml services/build-orchestrator/Cargo.toml
|
||||
COPY services/edge-agent/Cargo.toml services/edge-agent/Cargo.toml
|
||||
|
||||
# Filtrar solo las dependencias necesarias para este binario específico
|
||||
# Creamos estructuras dummy para que cargo metadata no falle (muy importante para la caché)
|
||||
RUN mkdir -p services/shared-lib/src && touch services/shared-lib/src/lib.rs && \
|
||||
mkdir -p services/flow-generator/src && touch services/flow-generator/src/lib.rs && \
|
||||
mkdir -p services/backend-api/src && echo "fn main() {}" > services/backend-api/src/main.rs && \
|
||||
mkdir -p services/data-collector/src && echo "fn main() {}" > services/data-collector/src/main.rs && \
|
||||
mkdir -p services/json-generator/src && echo "fn main() {}" > services/json-generator/src/main.rs && \
|
||||
mkdir -p services/events-relay/src && echo "fn main() {}" > services/events-relay/src/main.rs && \
|
||||
mkdir -p services/build-orchestrator/src && echo "fn main() {}" > services/build-orchestrator/src/main.rs && \
|
||||
mkdir -p services/edge-agent/src && echo "fn main() {}" > services/edge-agent/src/main.rs
|
||||
|
||||
# Generamos la receta solo para este binario
|
||||
RUN cargo chef prepare --recipe-path recipe.json --bin build-orchestrator
|
||||
|
||||
# =============================================================================
|
||||
# 2. CACHER
|
||||
# 2. CACHER: Descarga y compila las dependencias (etapa lenta)
|
||||
# =============================================================================
|
||||
FROM base AS cacher
|
||||
COPY --from=planner /app/recipe.json recipe.json
|
||||
RUN cargo chef cook --release --recipe-path recipe.json
|
||||
# Cook solo lo necesario para este binario para máxima velocidad
|
||||
RUN cargo chef cook --release --recipe-path recipe.json --bin build-orchestrator
|
||||
|
||||
# =============================================================================
|
||||
# 3. BUILDER
|
||||
|
||||
@@ -12,21 +12,40 @@ ENV RUSTFLAGS="-C link-arg=-fuse-ld=lld"
|
||||
ENV CARGO_INCREMENTAL=0
|
||||
|
||||
# =============================================================================
|
||||
# 1. PLANNER
|
||||
# 1. PLANNER: Genera el archivo recipe.json para cachear dependencias
|
||||
# =============================================================================
|
||||
FROM base AS planner
|
||||
# Copiar el código fuente para que cargo chef pueda analizar las dependencias
|
||||
COPY . .
|
||||
# Copiamos solo los archivos que definen dependencias (workspace y miembros)
|
||||
COPY Cargo.toml Cargo.lock ./
|
||||
COPY services/shared-lib/Cargo.toml services/shared-lib/Cargo.toml
|
||||
COPY services/flow-generator/Cargo.toml services/flow-generator/Cargo.toml
|
||||
COPY services/backend-api/Cargo.toml services/backend-api/Cargo.toml
|
||||
COPY services/data-collector/Cargo.toml services/data-collector/Cargo.toml
|
||||
COPY services/json-generator/Cargo.toml services/json-generator/Cargo.toml
|
||||
COPY services/events-relay/Cargo.toml services/events-relay/Cargo.toml
|
||||
COPY services/build-orchestrator/Cargo.toml services/build-orchestrator/Cargo.toml
|
||||
COPY services/edge-agent/Cargo.toml services/edge-agent/Cargo.toml
|
||||
|
||||
# Filtrar solo las dependencias necesarias para este binario específico
|
||||
# Creamos estructuras dummy para que cargo metadata no falle (muy importante para la caché)
|
||||
RUN mkdir -p services/shared-lib/src && touch services/shared-lib/src/lib.rs && \
|
||||
mkdir -p services/flow-generator/src && touch services/flow-generator/src/lib.rs && \
|
||||
mkdir -p services/backend-api/src && echo "fn main() {}" > services/backend-api/src/main.rs && \
|
||||
mkdir -p services/data-collector/src && echo "fn main() {}" > services/data-collector/src/main.rs && \
|
||||
mkdir -p services/json-generator/src && echo "fn main() {}" > services/json-generator/src/main.rs && \
|
||||
mkdir -p services/events-relay/src && echo "fn main() {}" > services/events-relay/src/main.rs && \
|
||||
mkdir -p services/build-orchestrator/src && echo "fn main() {}" > services/build-orchestrator/src/main.rs && \
|
||||
mkdir -p services/edge-agent/src && echo "fn main() {}" > services/edge-agent/src/main.rs
|
||||
|
||||
# Generamos la receta solo para este binario
|
||||
RUN cargo chef prepare --recipe-path recipe.json --bin data-collector
|
||||
|
||||
# =============================================================================
|
||||
# 2. CACHER
|
||||
# 2. CACHER: Descarga y compila las dependencias (etapa lenta)
|
||||
# =============================================================================
|
||||
FROM base AS cacher
|
||||
COPY --from=planner /app/recipe.json recipe.json
|
||||
RUN cargo chef cook --release --recipe-path recipe.json
|
||||
# Cook solo lo necesario para este binario para máxima velocidad
|
||||
RUN cargo chef cook --release --recipe-path recipe.json --bin data-collector
|
||||
|
||||
# =============================================================================
|
||||
# 3. BUILDER
|
||||
|
||||
@@ -2,11 +2,31 @@
|
||||
# MULTI-STAGE Dockerfile: Edge Agent MSI Builder (Optimized with cargo-chef)
|
||||
# =============================================================================
|
||||
|
||||
# --- ETAPA 1: PLANNER ---
|
||||
# --- ETAPA 1: PLANNER: Genera el archivo recipe.json para cachear dependencias ---
|
||||
FROM lukemathwalker/cargo-chef:latest-rust-1.93-slim-bookworm AS planner
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
RUN cargo chef prepare --recipe-path recipe.json
|
||||
# Copiamos solo los archivos que definen dependencias (workspace y miembros)
|
||||
COPY Cargo.toml Cargo.lock ./
|
||||
COPY services/shared-lib/Cargo.toml services/shared-lib/Cargo.toml
|
||||
COPY services/flow-generator/Cargo.toml services/flow-generator/Cargo.toml
|
||||
COPY services/backend-api/Cargo.toml services/backend-api/Cargo.toml
|
||||
COPY services/data-collector/Cargo.toml services/data-collector/Cargo.toml
|
||||
COPY services/json-generator/Cargo.toml services/json-generator/Cargo.toml
|
||||
COPY services/events-relay/Cargo.toml services/events-relay/Cargo.toml
|
||||
COPY services/build-orchestrator/Cargo.toml services/build-orchestrator/Cargo.toml
|
||||
COPY services/edge-agent/Cargo.toml services/edge-agent/Cargo.toml
|
||||
|
||||
# Creamos estructuras dummy para que cargo metadata no falle (muy importante para la caché)
|
||||
RUN mkdir -p services/shared-lib/src && touch services/shared-lib/src/lib.rs && \
|
||||
mkdir -p services/flow-generator/src && touch services/flow-generator/src/lib.rs && \
|
||||
mkdir -p services/backend-api/src && echo "fn main() {}" > services/backend-api/src/main.rs && \
|
||||
mkdir -p services/data-collector/src && echo "fn main() {}" > services/data-collector/src/main.rs && \
|
||||
mkdir -p services/json-generator/src && echo "fn main() {}" > services/json-generator/src/main.rs && \
|
||||
mkdir -p services/events-relay/src && echo "fn main() {}" > services/events-relay/src/main.rs && \
|
||||
mkdir -p services/build-orchestrator/src && echo "fn main() {}" > services/build-orchestrator/src/main.rs && \
|
||||
mkdir -p services/edge-agent/src && echo "fn main() {}" > services/edge-agent/src/main.rs
|
||||
|
||||
RUN cargo chef prepare --recipe-path recipe.json --bin edge-agent
|
||||
|
||||
# --- ETAPA 2: CACHER (Cross-Compilation) ---
|
||||
FROM lukemathwalker/cargo-chef:latest-rust-1.93-slim-bookworm AS cacher
|
||||
|
||||
@@ -12,21 +12,40 @@ ENV RUSTFLAGS="-C link-arg=-fuse-ld=lld"
|
||||
ENV CARGO_INCREMENTAL=0
|
||||
|
||||
# =============================================================================
|
||||
# 1. PLANNER
|
||||
# 1. PLANNER: Genera el archivo recipe.json para cachear dependencias
|
||||
# =============================================================================
|
||||
FROM base AS planner
|
||||
# Copiar el código fuente para que cargo chef pueda analizar las dependencias
|
||||
COPY . .
|
||||
# Copiamos solo los archivos que definen dependencias (workspace y miembros)
|
||||
COPY Cargo.toml Cargo.lock ./
|
||||
COPY services/shared-lib/Cargo.toml services/shared-lib/Cargo.toml
|
||||
COPY services/flow-generator/Cargo.toml services/flow-generator/Cargo.toml
|
||||
COPY services/backend-api/Cargo.toml services/backend-api/Cargo.toml
|
||||
COPY services/data-collector/Cargo.toml services/data-collector/Cargo.toml
|
||||
COPY services/json-generator/Cargo.toml services/json-generator/Cargo.toml
|
||||
COPY services/events-relay/Cargo.toml services/events-relay/Cargo.toml
|
||||
COPY services/build-orchestrator/Cargo.toml services/build-orchestrator/Cargo.toml
|
||||
COPY services/edge-agent/Cargo.toml services/edge-agent/Cargo.toml
|
||||
|
||||
# Filtrar solo las dependencias necesarias para este binario específico
|
||||
# Creamos estructuras dummy para que cargo metadata no falle (muy importante para la caché)
|
||||
RUN mkdir -p services/shared-lib/src && touch services/shared-lib/src/lib.rs && \
|
||||
mkdir -p services/flow-generator/src && touch services/flow-generator/src/lib.rs && \
|
||||
mkdir -p services/backend-api/src && echo "fn main() {}" > services/backend-api/src/main.rs && \
|
||||
mkdir -p services/data-collector/src && echo "fn main() {}" > services/data-collector/src/main.rs && \
|
||||
mkdir -p services/json-generator/src && echo "fn main() {}" > services/json-generator/src/main.rs && \
|
||||
mkdir -p services/events-relay/src && echo "fn main() {}" > services/events-relay/src/main.rs && \
|
||||
mkdir -p services/build-orchestrator/src && echo "fn main() {}" > services/build-orchestrator/src/main.rs && \
|
||||
mkdir -p services/edge-agent/src && echo "fn main() {}" > services/edge-agent/src/main.rs
|
||||
|
||||
# Generamos la receta solo para este binario
|
||||
RUN cargo chef prepare --recipe-path recipe.json --bin events-relay
|
||||
|
||||
# =============================================================================
|
||||
# 2. CACHER
|
||||
# 2. CACHER: Descarga y compila las dependencias (etapa lenta)
|
||||
# =============================================================================
|
||||
FROM base AS cacher
|
||||
COPY --from=planner /app/recipe.json recipe.json
|
||||
RUN cargo chef cook --release --recipe-path recipe.json
|
||||
# Cook solo lo necesario para este binario para máxima velocidad
|
||||
RUN cargo chef cook --release --recipe-path recipe.json --bin events-relay
|
||||
|
||||
# =============================================================================
|
||||
# 3. BUILDER
|
||||
|
||||
@@ -12,21 +12,40 @@ ENV RUSTFLAGS="-C link-arg=-fuse-ld=lld"
|
||||
ENV CARGO_INCREMENTAL=0
|
||||
|
||||
# =============================================================================
|
||||
# 1. PLANNER
|
||||
# 1. PLANNER: Genera el archivo recipe.json para cachear dependencias
|
||||
# =============================================================================
|
||||
FROM base AS planner
|
||||
# Copiar el código fuente para que cargo chef pueda analizar las dependencias
|
||||
COPY . .
|
||||
# Copiamos solo los archivos que definen dependencias (workspace y miembros)
|
||||
COPY Cargo.toml Cargo.lock ./
|
||||
COPY services/shared-lib/Cargo.toml services/shared-lib/Cargo.toml
|
||||
COPY services/flow-generator/Cargo.toml services/flow-generator/Cargo.toml
|
||||
COPY services/backend-api/Cargo.toml services/backend-api/Cargo.toml
|
||||
COPY services/data-collector/Cargo.toml services/data-collector/Cargo.toml
|
||||
COPY services/json-generator/Cargo.toml services/json-generator/Cargo.toml
|
||||
COPY services/events-relay/Cargo.toml services/events-relay/Cargo.toml
|
||||
COPY services/build-orchestrator/Cargo.toml services/build-orchestrator/Cargo.toml
|
||||
COPY services/edge-agent/Cargo.toml services/edge-agent/Cargo.toml
|
||||
|
||||
# Filtrar solo las dependencias necesarias para este binario específico
|
||||
# Creamos estructuras dummy para que cargo metadata no falle (muy importante para la caché)
|
||||
RUN mkdir -p services/shared-lib/src && touch services/shared-lib/src/lib.rs && \
|
||||
mkdir -p services/flow-generator/src && touch services/flow-generator/src/lib.rs && \
|
||||
mkdir -p services/backend-api/src && echo "fn main() {}" > services/backend-api/src/main.rs && \
|
||||
mkdir -p services/data-collector/src && echo "fn main() {}" > services/data-collector/src/main.rs && \
|
||||
mkdir -p services/json-generator/src && echo "fn main() {}" > services/json-generator/src/main.rs && \
|
||||
mkdir -p services/events-relay/src && echo "fn main() {}" > services/events-relay/src/main.rs && \
|
||||
mkdir -p services/build-orchestrator/src && echo "fn main() {}" > services/build-orchestrator/src/main.rs && \
|
||||
mkdir -p services/edge-agent/src && echo "fn main() {}" > services/edge-agent/src/main.rs
|
||||
|
||||
# Generamos la receta solo para este binario
|
||||
RUN cargo chef prepare --recipe-path recipe.json --bin json-generator
|
||||
|
||||
# =============================================================================
|
||||
# 2. CACHER
|
||||
# 2. CACHER: Descarga y compila las dependencias (etapa lenta)
|
||||
# =============================================================================
|
||||
FROM base AS cacher
|
||||
COPY --from=planner /app/recipe.json recipe.json
|
||||
RUN cargo chef cook --release --recipe-path recipe.json
|
||||
# Cook solo lo necesario para este binario para máxima velocidad
|
||||
RUN cargo chef cook --release --recipe-path recipe.json --bin json-generator
|
||||
|
||||
# =============================================================================
|
||||
# 3. BUILDER
|
||||
|
||||
Reference in New Issue
Block a user