From e302b1be726eb2e4522e4d1a0c8165aafb624115 Mon Sep 17 00:00:00 2001 From: Devdutt Shenoi Date: Thu, 16 Jan 2025 17:21:43 +0530 Subject: [PATCH 1/3] feat: cache dep builds --- Dockerfile | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1b6d6f51f..5b7c71af3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,7 +14,7 @@ # along with this program. If not, see . # build stage -FROM rust:1.83.0-bookworm as builder +FROM rust:1.83.0-bookworm AS builder LABEL org.opencontainers.image.title="Parseable" LABEL maintainer="Parseable Team " @@ -22,7 +22,13 @@ LABEL org.opencontainers.image.vendor="Parseable Inc" LABEL org.opencontainers.image.licenses="AGPL-3.0" WORKDIR /parseable -COPY . . + +# Cache dependencies +COPY Cargo.toml Cargo.lock build.rs .git ./ +RUN mkdir src && echo "fn main() {}" > src/main.rs && cargo build --release && rm -rf src + +# Build the actual binary +COPY src ./src RUN cargo build --release # final stage @@ -30,7 +36,7 @@ FROM gcr.io/distroless/cc-debian12:latest WORKDIR /parseable -# Copy the static shell into base image. +# Copy the static binary into the final image COPY --from=builder /parseable/target/release/parseable /usr/bin/parseable CMD ["/usr/bin/parseable"] From 8430e89ed8b0ce648b2fc07d2abb52190ca443a6 Mon Sep 17 00:00:00 2001 From: Devdutt Shenoi Date: Wed, 29 Jan 2025 00:42:56 +0530 Subject: [PATCH 2/3] ci: cache docker builds to gha --- .github/workflows/build-push-edge-debug.yaml | 8 +++++--- .github/workflows/build-push-edge.yaml | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-push-edge-debug.yaml b/.github/workflows/build-push-edge-debug.yaml index 6fe503bfc..5319bb5bd 100644 --- a/.github/workflows/build-push-edge-debug.yaml +++ b/.github/workflows/build-push-edge-debug.yaml @@ -24,22 +24,24 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Login to Docker Hub - uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Extract metadata (tags, labels) for Docker id: meta - uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + uses: docker/metadata-action@v5 with: images: parseable/parseable - name: Build and push - uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + uses: docker/build-push-action@v6 with: context: . file: ./Dockerfile.debug push: true tags: parseable/parseable:edge-debug platforms: linux/amd64,linux/arm64 + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/.github/workflows/build-push-edge.yaml b/.github/workflows/build-push-edge.yaml index a93e6673e..625976d7a 100644 --- a/.github/workflows/build-push-edge.yaml +++ b/.github/workflows/build-push-edge.yaml @@ -24,22 +24,24 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Login to Docker Hub - uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Extract metadata (tags, labels) for Docker id: meta - uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + uses: docker/metadata-action@v5 with: images: parseable/parseable - name: Build and push - uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + uses: docker/build-push-action@v6 with: context: . file: ./Dockerfile push: true tags: parseable/parseable:edge platforms: linux/amd64,linux/arm64 + cache-from: type=gha + cache-to: type=gha,mode=max From fef9738bfc279050438654a36eaaf29221a29831 Mon Sep 17 00:00:00 2001 From: Devdutt Shenoi Date: Wed, 29 Jan 2025 00:45:31 +0530 Subject: [PATCH 3/3] cache in debug --- Dockerfile.debug | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Dockerfile.debug b/Dockerfile.debug index e37c2125c..5c86963fc 100644 --- a/Dockerfile.debug +++ b/Dockerfile.debug @@ -22,7 +22,13 @@ LABEL org.opencontainers.image.vendor="Parseable Inc" LABEL org.opencontainers.image.licenses="AGPL-3.0" WORKDIR /parseable -COPY . . + +# Cache dependencies +COPY Cargo.toml Cargo.lock build.rs .git ./ +RUN mkdir src && echo "fn main() {}" > src/main.rs && cargo build --release && rm -rf src + +# Build the actual binary +COPY src ./src RUN cargo build # final stage @@ -30,6 +36,7 @@ FROM docker.io/debian:bookworm-slim WORKDIR /parseable +# Copy the static binary into the final image COPY --from=builder /parseable/target/debug/parseable /usr/bin/parseable CMD ["/usr/bin/parseable"]