Skip to content

Commit c210bf0

Browse files
authored
message_buffer: Add Dockerfile with caching (#778)
* message_buffer: Add Dockerfile with caching This dockerfile ensures as little cache invalidation as possible through layer-caching and BuildKit cache mounts. * dockerignowe -> dockerignore * message_buffer/Dockerfile: Fix the final cached target move
1 parent 2bc98b4 commit c210bf0

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

message_buffer/.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
target
2+
node_modules

message_buffer/Dockerfile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
ARG RUST_VERSION=1.69
2+
FROM rust:${RUST_VERSION}
3+
4+
RUN apt-get update && apt-get install -qq nodejs npm curl
5+
6+
RUN npm install --global yarn
7+
8+
RUN rustup default ${RUST_VERSION}
9+
10+
ARG SOLANA_VERSION=v1.14.11
11+
RUN curl -sSfL https://release.solana.com/${SOLANA_VERSION}/install > install_solana.sh
12+
RUN sh install_solana.sh
13+
ENV PATH="/root/.local/share/solana/install/active_release/bin:$PATH"
14+
15+
RUN --mount=type=cache,target=target cargo install --git https://github.com/coral-xyz/anchor avm --locked --force --target-dir target
16+
17+
ARG ANCHOR_VERSION=0.27.0
18+
RUN --mount=type=cache,target=target CARGO_TARGET_DIR=target avm install ${ANCHOR_VERSION} && avm use ${ANCHOR_VERSION}
19+
20+
# Trigger Anchor's BPF tools download for caching
21+
RUN anchor init decoy-crate
22+
RUN cd decoy-crate && anchor build
23+
RUN rm -rf decoy-crate
24+
25+
WORKDIR message_buffer
26+
27+
# layer-cache cargo deps
28+
ADD Cargo.toml Cargo.lock ./
29+
ADD programs/message_buffer/Cargo.toml programs/message_buffer/
30+
RUN mkdir -p programs/message_buffer/src && touch programs/message_buffer/src/lib.rs
31+
RUN cargo fetch --locked
32+
33+
ADD . .
34+
35+
RUN --mount=type=cache,target=target anchor build -p message_buffer && cp -r target target_tmp
36+
RUN rm -rf target && mv target_tmp target

0 commit comments

Comments
 (0)