# syntax=docker/dockerfile:1.4 # smartbotic-automation Package Builder # Compiles the C++ binaries + WebUI bundle, then assembles a single .deb. # # Build: # docker buildx build -f packaging/Dockerfile.build \ # --build-arg BASE_IMAGE=smartbotic-automation-build-base:debian13 \ # --build-arg BUILD_VERSION=1.0.0 \ # --target packages \ # --output "type=local,dest=dist/debian13/" . ARG BASE_IMAGE=debian:trixie FROM ${BASE_IMAGE} AS builder ARG BUILD_VERSION=0.0.0 ARG BUILD_DEB_REVISION=1 ARG BUILD_JOBS=8 ARG BUILD_GIT_COMMIT=unknown ENV DEBIAN_FRONTEND=noninteractive ENV BUILD_VERSION=${BUILD_VERSION} ENV BUILD_DEB_REVISION=${BUILD_DEB_REVISION} ENV BUILD_JOBS=${BUILD_JOBS} ENV CCACHE_DIR=/ccache ENV CCACHE_MAXSIZE=5G ENV PATH="/usr/lib/ccache:${PATH}" # Fall back to fresh dep install if the base image isn't our prebuilt one RUN if [ ! -f /etc/smartbotic-automation-build-base ]; then \ apt-get update && apt-get install -y --no-install-recommends \ build-essential cmake ninja-build git pkg-config ccache dpkg-dev \ libssl-dev zlib1g-dev libbrotli-dev uuid-dev \ protobuf-compiler libprotobuf-dev libgrpc++-dev protobuf-compiler-grpc \ nlohmann-json3-dev libspdlog-dev libfmt-dev libcurl4-openssl-dev libwebsockets-dev \ nodejs npm libsmartbotic-db-client-dev \ && rm -rf /var/lib/apt/lists/*; \ else echo "Using pre-built base: $(cat /etc/smartbotic-automation-build-base)"; fi WORKDIR /build # WebUI build (cached separately from C++) COPY webui/package.json webui/package-lock.json ./webui/ RUN --mount=type=cache,target=/npm-cache,id=smartbotic-automation-npm-cache \ cd webui && npm ci --cache /npm-cache COPY VERSION ./ COPY webui/ ./webui/ RUN cd webui && npm run build # C++ build COPY CMakeLists.txt ./ COPY cmake/ ./cmake/ COPY proto/ ./proto/ COPY lib/ ./lib/ COPY src/ ./src/ COPY config/ ./config/ COPY nodes/ ./nodes/ COPY packaging/ ./packaging/ RUN --mount=type=cache,target=/ccache,id=smartbotic-automation-ccache \ cmake -B build -G Ninja \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_C_COMPILER_LAUNCHER=ccache \ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ && cmake --build build --parallel ${BUILD_JOBS} \ && (ccache --show-stats || true) # ----- Package assembly stage ----- FROM builder AS packager RUN mkdir -p /packages RUN chmod +x /build/packaging/scripts/create-deb.sh \ && OUTPUT_DIR=/packages /build/packaging/scripts/create-deb.sh # ----- Final export stage ----- FROM scratch AS packages COPY --from=packager /packages/*.deb /