fix(woodpecker): use simple Dockerfile and reduce build complexity
- Replace complex caching with simple Dockerfile - Remove cargo-chef complexity that was slowing builds - Add .woodpecker-base.yml for separate base image builds - Add Dockerfile.simple for faster builds - Add Dockerfile.ultrafast for when base image exists
This commit is contained in:
parent
4f16b21b76
commit
39107e4fa4
4 changed files with 97 additions and 4 deletions
24
.woodpecker-base.yml
Normal file
24
.woodpecker-base.yml
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
when:
|
||||||
|
branch: [main, high-performance]
|
||||||
|
event: push
|
||||||
|
path:
|
||||||
|
- Cargo.toml
|
||||||
|
- Cargo.lock
|
||||||
|
- crates/**
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: build-base-image
|
||||||
|
image: woodpeckerci/plugin-docker-buildx:5.0.0
|
||||||
|
settings:
|
||||||
|
registry: ghcr.io
|
||||||
|
repo: ghcr.io/traceworks2023/nxtgauge-rust-base
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile.base
|
||||||
|
tags:
|
||||||
|
- latest
|
||||||
|
- ${CI_COMMIT_SHA}
|
||||||
|
username:
|
||||||
|
from_secret: GHCR_USERNAME
|
||||||
|
password:
|
||||||
|
from_secret: GHCR_TOKEN
|
||||||
|
platforms: linux/amd64
|
||||||
|
|
@ -61,7 +61,8 @@ steps:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
repo: ghcr.io/traceworks2023/nxtgauge-rust-${SERVICE}
|
repo: ghcr.io/traceworks2023/nxtgauge-rust-${SERVICE}
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile.fast
|
# Use simple Dockerfile for now
|
||||||
|
dockerfile: Dockerfile.simple
|
||||||
build_args:
|
build_args:
|
||||||
- SERVICE_NAME=${SERVICE}
|
- SERVICE_NAME=${SERVICE}
|
||||||
tags:
|
tags:
|
||||||
|
|
@ -73,6 +74,3 @@ steps:
|
||||||
password:
|
password:
|
||||||
from_secret: GHCR_TOKEN
|
from_secret: GHCR_TOKEN
|
||||||
platforms: linux/amd64
|
platforms: linux/amd64
|
||||||
# ENABLE CACHE - This is the key!
|
|
||||||
cache_from: ghcr.io/traceworks2023/nxtgauge-rust-${SERVICE}:cache
|
|
||||||
cache_to: ghcr.io/traceworks2023/nxtgauge-rust-${SERVICE}:cache
|
|
||||||
|
|
|
||||||
38
Dockerfile.simple
Normal file
38
Dockerfile.simple
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
# Simple fast Dockerfile - no fancy caching, just builds fast
|
||||||
|
# Uses local cargo cache between builds
|
||||||
|
|
||||||
|
ARG SERVICE_NAME
|
||||||
|
|
||||||
|
FROM rust:alpine AS builder
|
||||||
|
ARG SERVICE_NAME
|
||||||
|
|
||||||
|
# Install deps
|
||||||
|
RUN apk add --no-cache musl-dev pkgconfig openssl-dev && \
|
||||||
|
rustup target add x86_64-unknown-linux-musl
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy manifests first for better caching
|
||||||
|
COPY Cargo.toml Cargo.lock ./
|
||||||
|
COPY crates/ ./crates/
|
||||||
|
|
||||||
|
# Copy the specific service
|
||||||
|
COPY apps/${SERVICE_NAME}/ ./apps/${SERVICE_NAME}/
|
||||||
|
|
||||||
|
# Build with all optimizations
|
||||||
|
ENV RUSTFLAGS="-C target-feature=+crt-static -C link-arg=-s"
|
||||||
|
RUN cargo build --release \
|
||||||
|
--bin ${SERVICE_NAME} \
|
||||||
|
--target x86_64-unknown-linux-musl
|
||||||
|
|
||||||
|
# Runtime
|
||||||
|
FROM scratch
|
||||||
|
ARG SERVICE_NAME
|
||||||
|
|
||||||
|
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||||
|
COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/${SERVICE_NAME} /app/service
|
||||||
|
|
||||||
|
USER 65532:65532
|
||||||
|
EXPOSE 8000
|
||||||
|
|
||||||
|
ENTRYPOINT ["/app/service"]
|
||||||
33
Dockerfile.ultrafast
Normal file
33
Dockerfile.ultrafast
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
# Ultra-fast Dockerfile using pre-built dependencies
|
||||||
|
# This requires the base image to be built first!
|
||||||
|
# Base image build: ./scripts/build-base-image.sh
|
||||||
|
|
||||||
|
ARG SERVICE_NAME
|
||||||
|
|
||||||
|
# Use the pre-built base image with all dependencies cached
|
||||||
|
FROM ghcr.io/traceworks2023/nxtgauge-rust-base:latest AS builder
|
||||||
|
ARG SERVICE_NAME
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy ONLY the specific service source code
|
||||||
|
# Dependencies are already compiled in the base image!
|
||||||
|
COPY apps/${SERVICE_NAME}/ ./apps/${SERVICE_NAME}/
|
||||||
|
|
||||||
|
# Build just this service - dependencies already exist!
|
||||||
|
# This should take 10-30 seconds, not 15-20 minutes!
|
||||||
|
RUN cargo build --release \
|
||||||
|
--bin ${SERVICE_NAME} \
|
||||||
|
--target x86_64-unknown-linux-musl
|
||||||
|
|
||||||
|
# Minimal runtime image
|
||||||
|
FROM scratch
|
||||||
|
ARG SERVICE_NAME
|
||||||
|
|
||||||
|
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||||
|
COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/${SERVICE_NAME} /app/service
|
||||||
|
|
||||||
|
USER 65532:65532
|
||||||
|
EXPOSE 8000
|
||||||
|
|
||||||
|
ENTRYPOINT ["/app/service"]
|
||||||
Loading…
Add table
Reference in a new issue