From 22193565ecab609e2874f785c98ec3865a326d02 Mon Sep 17 00:00:00 2001 From: omar Date: Mon, 22 Jul 2024 12:13:19 -0700 Subject: [PATCH] feat: publishable docker image --- .gitignore | 3 ++ dockerfiles/.dockerignore | 8 ++++ dockerfiles/Dockerfile | 67 +++++++++++++++++++++++++++++++ dockerfiles/scripts/entrypoint.sh | 7 ++++ 4 files changed, 85 insertions(+) create mode 100644 dockerfiles/.dockerignore create mode 100644 dockerfiles/Dockerfile create mode 100644 dockerfiles/scripts/entrypoint.sh diff --git a/.gitignore b/.gitignore index aa9cae59..e2040a75 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,6 @@ documentation/docs/dist documentation/vocs.config.ts* graphql/node_modules rindexer_rust_playground/generated_csv/*/*.csv +.direnv +._* +_ diff --git a/dockerfiles/.dockerignore b/dockerfiles/.dockerignore new file mode 100644 index 00000000..0938d9a6 --- /dev/null +++ b/dockerfiles/.dockerignore @@ -0,0 +1,8 @@ +# ignore everything +* + +# except the following +!Dockerfile +!.dockerignore +!scripts +!rindexer diff --git a/dockerfiles/Dockerfile b/dockerfiles/Dockerfile new file mode 100644 index 00000000..7a1c4716 --- /dev/null +++ b/dockerfiles/Dockerfile @@ -0,0 +1,67 @@ +# syntax = docker/dockerfile:1.6 +FROM rust:bookworm AS builder + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +ARG DEBIAN_FRONTEND="noninteractive" +ARG DEBCONF_NOWARNINGS="yes" +ARG DEBCONF_TERSE="yes" +ARG LANG="C.UTF-8" + +WORKDIR /app + +RUN apt-get update --yes \ + && apt-get install --yes --no-install-recommends \ + ca-certificates \ + curl \ + unzip \ + && apt-get autoremove --yes \ + && apt-get clean --yes \ + && rm -rf /var/lib/apt/lists/* + +# Install rundexer +RUN set -x && \ + curl \ + --fail \ + --silent \ + --location \ + --show-error \ + --url https://rindexer.xyz/install.sh | \ + sed 's/curl -sSf -L "$RESOURCES_URL" -o "$RINDEXER_DIR\/resources.zip"/curl -sSf -L "$RESOURCES_URL" -o "$RINDEXER_DIR\/resources.zip" || echo "Failed to download resources.zip"/' | \ + sed 's/unzip -o "$RINDEXER_DIR\/resources.zip"/[ -f "$RINDEXER_DIR\/resources.zip" ] \&\& unzip -o "$RINDEXER_DIR\/resources.zip" || echo "Skipping unzip, resources.zip not found"/' | \ + sed 's/rm "$RINDEXER_DIR\/resources.zip"/rm -f "$RINDEXER_DIR\/resources.zip"/' | \ + bash + +FROM debian:bookworm-slim AS runtime + +ARG DEBIAN_FRONTEND="noninteractive" +ARG DEBCONF_NOWARNINGS="yes" +ARG DEBCONF_TERSE="yes" +ARG LANG="C.UTF-8" + +# where rindexer.yaml and a JSON abi file are located +# make sure the project path is in .dockerignore +ARG PROJECT_PATH="./rindexer" + +ENV PATH="/root/.rindexer/bin:${PATH}" + +WORKDIR /app + +RUN apt-get update --yes \ + && apt-get install --yes --no-install-recommends \ + ca-certificates \ + bash \ + sudo \ + openssl \ + && apt-get autoremove --yes \ + && apt-get clean --yes \ + && rm -rf /var/lib/apt/lists/* + +# Copy rindexer from builder stage +COPY --from=builder /root/.rindexer /root/.rindexer +COPY ${PROJECT_PATH} ${PROJECT_PATH} + +COPY ./scripts/entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +ENTRYPOINT [ "/entrypoint.sh" ] diff --git a/dockerfiles/scripts/entrypoint.sh b/dockerfiles/scripts/entrypoint.sh new file mode 100644 index 00000000..db29029c --- /dev/null +++ b/dockerfiles/scripts/entrypoint.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -e + +echo "Running $(/root/.rindexer/bin/rindexer --version)" + +exec "$@"