Skip to content

Commit

Permalink
feat: add a second Dockerfile.bundled which bundles third-party binar…
Browse files Browse the repository at this point in the history
…ies (#77)

* feat: add a second Dockerfile.bundled which bundles third-party binaries
to run with rindexer

* fix: rename Dockerfile.bundled to bundled.Dockerfile

* fix: copy ssl certs from builder

* feat: don't strip binaries

* fix: install foundry into image
  • Loading branch information
crebsy authored Aug 15, 2024
1 parent 2d1af3c commit 5c63909
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 22 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ on:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
Expand All @@ -18,6 +17,13 @@ jobs:
permissions:
contents: read
packages: write
strategy:
matrix:
include:
- dockerfile: Dockerfile
image: ghcr.io/joshstevens19/rindexer
- dockerfile: bundled.Dockerfile
image: ghcr.io/joshstevens19/rindexer-bundled

steps:
- name: Checkout repository
Expand All @@ -38,7 +44,7 @@ jobs:
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
images: ${{ matrix.image }}
tags: |
type=sha
type=sha,format=long
Expand All @@ -51,6 +57,7 @@ jobs:
uses: docker/build-push-action@v6
with:
context: .
file: ${{ matrix.dockerfile }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
27 changes: 7 additions & 20 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,13 @@
FROM --platform=linux/amd64 rust:1.79-slim-bookworm as builder
FROM --platform=linux/amd64 clux/muslrust:stable as builder
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
RUN apt update && apt install -y libssl-dev binutils libc-dev libstdc++6 pkg-config

RUN mkdir /app
WORKDIR /app
COPY . .
RUN cargo build --release
RUN strip /app/target/release/rindexer_cli

FROM --platform=linux/amd64 node:lts-bookworm as node-builder
RUN apt update && apt install -y ca-certificates
WORKDIR /app
COPY . .
RUN cd /app/graphql && npm i && npm run build-linux

FROM --platform=linux/amd64 debian:bookworm-slim
RUN apt update \
&& apt install -y libssl-dev libc-dev libstdc++6 ca-certificates lsof \
&& apt-get autoremove --yes \
&& apt-get clean --yes \
&& rm -rf /var/lib/apt/lists/*
RUN rustup target add x86_64-unknown-linux-musl
RUN RUSTFLAGS='-C target-cpu=native' cargo build --release --target x86_64-unknown-linux-musl --features jemalloc

COPY --from=node-builder /app/core/resources/rindexer-graphql-linux /app/resources/rindexer-graphql-linux
COPY --from=builder /app/target/release/rindexer_cli /app/rindexer
FROM --platform=linux/amd64 scratch
COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/rindexer_cli /app/rindexer
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/

ENTRYPOINT ["/app/rindexer"]
28 changes: 28 additions & 0 deletions bundled.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM --platform=linux/amd64 rust:1.79-slim-bookworm as builder
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
RUN apt update && apt install -y libssl-dev pkg-config build-essential

WORKDIR /app
COPY . .
RUN RUSTFLAGS='-C target-cpu=native' cargo build --release --features jemalloc

FROM --platform=linux/amd64 node:lts-bookworm as node-builder
RUN apt update && apt install -y ca-certificates
WORKDIR /app
COPY . .
RUN cd /app/graphql && npm i && npm run build-linux

FROM --platform=linux/amd64 debian:bookworm-slim
RUN apt update \
&& apt install -y libssl-dev libc-dev libstdc++6 ca-certificates lsof curl git \
&& apt-get autoremove --yes \
&& apt-get clean --yes \
&& rm -rf /var/lib/apt/lists/*

RUN curl -L https://foundry.paradigm.xyz | bash
RUN /root/.foundry/bin/foundryup

COPY --from=node-builder /app/core/resources/rindexer-graphql-linux /app/resources/rindexer-graphql-linux
COPY --from=builder /app/target/release/rindexer_cli /app/rindexer

ENTRYPOINT ["/app/rindexer"]

0 comments on commit 5c63909

Please sign in to comment.