Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

improve local docker build times (#1583)

Will Hutchinsonbdc463e78e4a
diff --git a/justfile b/justfile
index 6383baaff4..d2ab94c892 100644
--- a/justfile
+++ b/justfile
@@ -69,3 +69,16 @@ setup_fusionauth:
# Stop FusionAuth containers
stop_fusionauth:
docker compose -f infra/stacks/fusionauth-instance/docker-compose.yml down
+
+# Clear all BuildKit build cache (full cold rebuild next time)
+docker_cache_clear:
+ docker builder prune --all -f
+
+# Clear only the Rust target caches (keeps downloaded crates, forces recompilation)
+docker_cache_clear_targets:
+ docker builder prune --filter type=exec.cachemount --filter id=rust-target-dev-debug -f
+ docker builder prune --filter type=exec.cachemount --filter id=rust-target-dev-release -f
+
+# Show BuildKit cache disk usage
+docker_cache_usage:
+ docker builder du --verbose
diff --git a/rust/cloud-storage/Dockerfile.convert_service.dev b/rust/cloud-storage/Dockerfile.convert_service.dev
index 9fe4274b0a..92849b2d39 100644
--- a/rust/cloud-storage/Dockerfile.convert_service.dev
+++ b/rust/cloud-storage/Dockerfile.convert_service.dev
@@ -1,3 +1,4 @@
+# syntax=docker/dockerfile:1
# Download LibreOffice/Collabora Online assets
FROM debian:trixie-slim AS lok
RUN apt-get update && apt-get install -y --no-install-recommends \
@@ -18,9 +19,12 @@ WORKDIR /app
FROM chef AS builder
COPY . .
-RUN cargo build --release --bin convert_service \
+RUN --mount=type=cache,target=/usr/local/cargo/registry,sharing=shared \
+ --mount=type=cache,target=/usr/local/cargo/git/db,sharing=shared \
+ --mount=type=cache,target=/app/target,id=rust-target-dev-release,sharing=locked \
+ cargo build --release --bin convert_service \
&& cargo strip \
- && mv /app/target/release/convert_service /app/svc
+ && cp /app/target/release/convert_service /app/svc
# Runtime image with LibreOffice
FROM ubuntu:noble AS convert_service
diff --git a/rust/cloud-storage/Dockerfile.dev b/rust/cloud-storage/Dockerfile.dev
index 215f5ff2f9..8b3f0ffcfc 100644
--- a/rust/cloud-storage/Dockerfile.dev
+++ b/rust/cloud-storage/Dockerfile.dev
@@ -1,3 +1,4 @@
+# syntax=docker/dockerfile:1
FROM rust:latest AS chef
ENV SQLX_OFFLINE=true
WORKDIR /app
@@ -5,17 +6,30 @@ WORKDIR /app
FROM chef AS builder
COPY . .
-# Build ALL standard service binaries at once
-RUN cargo build \
- --bin authentication_service \
- --bin connection_gateway_service \
- --bin contacts_service \
- --bin document_cognition_service \
- --bin document_storage_service \
- --bin email_service \
- --bin notification_service \
- --bin static_file_service \
- --bin unfurl_service
+# Build ALL standard service binaries at once (with BuildKit cache mounts for incremental builds)
+RUN --mount=type=cache,target=/usr/local/cargo/registry,sharing=shared \
+ --mount=type=cache,target=/usr/local/cargo/git/db,sharing=shared \
+ --mount=type=cache,target=/app/target,id=rust-target-dev-debug,sharing=locked \
+ cargo build \
+ --bin authentication_service \
+ --bin connection_gateway_service \
+ --bin contacts_service \
+ --bin document_cognition_service \
+ --bin document_storage_service \
+ --bin email_service \
+ --bin notification_service \
+ --bin static_file_service \
+ --bin unfurl_service \
+ && mkdir -p /app/out \
+ && cp /app/target/debug/authentication_service /app/out/ \
+ && cp /app/target/debug/connection_gateway_service /app/out/ \
+ && cp /app/target/debug/contacts_service /app/out/ \
+ && cp /app/target/debug/document_cognition_service /app/out/ \
+ && cp /app/target/debug/document_storage_service /app/out/ \
+ && cp /app/target/debug/email_service /app/out/ \
+ && cp /app/target/debug/notification_service /app/out/ \
+ && cp /app/target/debug/static_file_service /app/out/ \
+ && cp /app/target/debug/unfurl_service /app/out/
# Base runtime image
FROM debian:trixie-slim AS base
@@ -28,46 +42,46 @@ EXPOSE 8080
# Individual service targets
FROM base AS authentication_service
-COPY --from=builder /app/target/debug/authentication_service /app/svc
+COPY --from=builder /app/out/authentication_service /app/svc
RUN chmod +x /app/svc
ENTRYPOINT ["dumb-init", "./svc"]
FROM base AS connection_gateway_service
-COPY --from=builder /app/target/debug/connection_gateway_service /app/svc
+COPY --from=builder /app/out/connection_gateway_service /app/svc
RUN chmod +x /app/svc
ENTRYPOINT ["dumb-init", "./svc"]
FROM base AS contacts_service
-COPY --from=builder /app/target/debug/contacts_service /app/svc
+COPY --from=builder /app/out/contacts_service /app/svc
RUN chmod +x /app/svc
ENTRYPOINT ["dumb-init", "./svc"]
FROM base AS document_cognition_service
-COPY --from=builder /app/target/debug/document_cognition_service /app/svc
+COPY --from=builder /app/out/document_cognition_service /app/svc
RUN chmod +x /app/svc
ENTRYPOINT ["dumb-init", "./svc"]
FROM base AS document_storage_service
-COPY --from=builder /app/target/debug/document_storage_service /app/svc
+COPY --from=builder /app/out/document_storage_service /app/svc
RUN chmod +x /app/svc
ENTRYPOINT ["dumb-init", "./svc"]
FROM base AS email_service
-COPY --from=builder /app/target/debug/email_service /app/svc
+COPY --from=builder /app/out/email_service /app/svc
RUN chmod +x /app/svc
ENTRYPOINT ["dumb-init", "./svc"]
FROM base AS notification_service
-COPY --from=builder /app/target/debug/notification_service /app/svc
+COPY --from=builder /app/out/notification_service /app/svc
RUN chmod +x /app/svc
ENTRYPOINT ["dumb-init", "./svc"]
FROM base AS static_file_service
-COPY --from=builder /app/target/debug/static_file_service /app/svc
+COPY --from=builder /app/out/static_file_service /app/svc
RUN chmod +x /app/svc
ENTRYPOINT ["dumb-init", "./svc"]
FROM base AS unfurl_service
-COPY --from=builder /app/target/debug/unfurl_service /app/svc
+COPY --from=builder /app/out/unfurl_service /app/svc
RUN chmod +x /app/svc
ENTRYPOINT ["dumb-init", "./svc"]
diff --git a/rust/cloud-storage/Dockerfile.search_processing_service.dev b/rust/cloud-storage/Dockerfile.search_processing_service.dev
index c90ff7032d..dc2f5473aa 100644
--- a/rust/cloud-storage/Dockerfile.search_processing_service.dev
+++ b/rust/cloud-storage/Dockerfile.search_processing_service.dev
@@ -1,3 +1,4 @@
+# syntax=docker/dockerfile:1
FROM rust:latest AS chef
ENV SQLX_OFFLINE=true
RUN cargo install cargo-strip
@@ -6,9 +7,12 @@ WORKDIR /app
FROM chef AS builder
COPY . .
-RUN cargo build --release --bin search_processing_service \
+RUN --mount=type=cache,target=/usr/local/cargo/registry,sharing=shared \
+ --mount=type=cache,target=/usr/local/cargo/git/db,sharing=shared \
+ --mount=type=cache,target=/app/target,id=rust-target-dev-release,sharing=locked \
+ cargo build --release --bin search_processing_service \
&& cargo strip \
- && mv /app/target/release/search_processing_service /app/svc
+ && cp /app/target/release/search_processing_service /app/svc
# Runtime image
FROM debian:trixie-slim AS search_processing_service