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

Optimise Docker image #26

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
30 changes: 23 additions & 7 deletions Dockerfile.availability-oracle
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
FROM rust:latest as build
# Use an official Rust image to build the project
FROM --platform=linux/amd64 rust:1.78 as build

# Copy and build the project
# Set the working directory
WORKDIR /availability-oracle/src
COPY . ./

# Copy the source code into the container
COPY . .

# Build the project
RUN cargo install --locked --path availability-oracle

## Clean up the source directory
RUN rm -rf /src
# Use a minimal image for the final stage with a fixed version
FROM --platform=linux/amd64 debian:12-slim

# Install the necessary dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
libssl3 \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*

# Copy the built binary from the build stage
COPY --from=build /usr/local/cargo/bin/availability-oracle /usr/local/bin/availability-oracle

# Set the user
USER 1000
ENTRYPOINT ["/usr/local/cargo/bin/availability-oracle"]
CMD ["--ipfs", "https://ipfs.network.thegraph.com", "--subgraph", "https://gateway.network.thegraph.com/network", "--period", "300"]

# Set the entrypoint and command
ENTRYPOINT ["/usr/local/bin/availability-oracle"]