Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add a second Dockerfile.bundled which bundles third-party binaries #77

Merged
merged 5 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"]
Loading