Skip to content

Commit cb8b6c1

Browse files
authored
feat: cache dep builds (#1105)
1 parent a0a0ec3 commit cb8b6c1

File tree

4 files changed

+27
-10
lines changed

4 files changed

+27
-10
lines changed

.github/workflows/build-push-edge-debug.yaml

+5-3
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,24 @@ jobs:
2424
uses: docker/setup-buildx-action@v3
2525

2626
- name: Login to Docker Hub
27-
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
27+
uses: docker/login-action@v3
2828
with:
2929
username: ${{ secrets.DOCKERHUB_USERNAME }}
3030
password: ${{ secrets.DOCKERHUB_TOKEN }}
3131

3232
- name: Extract metadata (tags, labels) for Docker
3333
id: meta
34-
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
34+
uses: docker/metadata-action@v5
3535
with:
3636
images: parseable/parseable
3737

3838
- name: Build and push
39-
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
39+
uses: docker/build-push-action@v6
4040
with:
4141
context: .
4242
file: ./Dockerfile.debug
4343
push: true
4444
tags: parseable/parseable:edge-debug
4545
platforms: linux/amd64,linux/arm64
46+
cache-from: type=gha
47+
cache-to: type=gha,mode=max

.github/workflows/build-push-edge.yaml

+5-3
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,24 @@ jobs:
2424
uses: docker/setup-buildx-action@v3
2525

2626
- name: Login to Docker Hub
27-
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
27+
uses: docker/login-action@v3
2828
with:
2929
username: ${{ secrets.DOCKERHUB_USERNAME }}
3030
password: ${{ secrets.DOCKERHUB_TOKEN }}
3131

3232
- name: Extract metadata (tags, labels) for Docker
3333
id: meta
34-
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
34+
uses: docker/metadata-action@v5
3535
with:
3636
images: parseable/parseable
3737

3838
- name: Build and push
39-
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
39+
uses: docker/build-push-action@v6
4040
with:
4141
context: .
4242
file: ./Dockerfile
4343
push: true
4444
tags: parseable/parseable:edge
4545
platforms: linux/amd64,linux/arm64
46+
cache-from: type=gha
47+
cache-to: type=gha,mode=max

Dockerfile

+9-3
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,29 @@
1414
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1515

1616
# build stage
17-
FROM rust:1.83.0-bookworm as builder
17+
FROM rust:1.83.0-bookworm AS builder
1818

1919
LABEL org.opencontainers.image.title="Parseable"
2020
LABEL maintainer="Parseable Team <[email protected]>"
2121
LABEL org.opencontainers.image.vendor="Parseable Inc"
2222
LABEL org.opencontainers.image.licenses="AGPL-3.0"
2323

2424
WORKDIR /parseable
25-
COPY . .
25+
26+
# Cache dependencies
27+
COPY Cargo.toml Cargo.lock build.rs .git ./
28+
RUN mkdir src && echo "fn main() {}" > src/main.rs && cargo build --release && rm -rf src
29+
30+
# Build the actual binary
31+
COPY src ./src
2632
RUN cargo build --release
2733

2834
# final stage
2935
FROM gcr.io/distroless/cc-debian12:latest
3036

3137
WORKDIR /parseable
3238

33-
# Copy the static shell into base image.
39+
# Copy the static binary into the final image
3440
COPY --from=builder /parseable/target/release/parseable /usr/bin/parseable
3541

3642
CMD ["/usr/bin/parseable"]

Dockerfile.debug

+8-1
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,21 @@ LABEL org.opencontainers.image.vendor="Parseable Inc"
2222
LABEL org.opencontainers.image.licenses="AGPL-3.0"
2323

2424
WORKDIR /parseable
25-
COPY . .
25+
26+
# Cache dependencies
27+
COPY Cargo.toml Cargo.lock build.rs .git ./
28+
RUN mkdir src && echo "fn main() {}" > src/main.rs && cargo build --release && rm -rf src
29+
30+
# Build the actual binary
31+
COPY src ./src
2632
RUN cargo build
2733

2834
# final stage
2935
FROM docker.io/debian:bookworm-slim
3036

3137
WORKDIR /parseable
3238

39+
# Copy the static binary into the final image
3340
COPY --from=builder /parseable/target/debug/parseable /usr/bin/parseable
3441

3542
CMD ["/usr/bin/parseable"]

0 commit comments

Comments
 (0)