forked from kkrt-labs/kakarot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
103 lines (79 loc) · 3.16 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# trunk-ignore-all(hadolint/DL4006)
# trunk-ignore-all(checkov/CKV_DOCKER_3)
# trunk-ignore-all(hadolint/DL3008)
###########################################
# Base image used by builder and deployer
###########################################
FROM python:3.10.14-slim-bookworm as base
HEALTHCHECK NONE
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
git \
&& rm -rf /var/lib/apt/lists/*
ENV VIRTUAL_ENV=/app/kakarot/.venv \
PATH="/app/kakarot/.venv/bin:/root/.local/bin:$PATH"
RUN --mount=type=cache,target=/root/.cache \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
RUN --mount=type=cache,target=/root/.cache \
curl -LsSf https://astral.sh/uv/install.sh | sh
ENV PATH="/root/.cargo/bin:$PATH"
WORKDIR /app/kakarot
############################################
# Kakarot builder
############################################
FROM base as builder
ENV PATH="$PATH:/root/.local/bin:/root/.foundry/bin"
RUN curl -L https://foundry.paradigm.xyz -o foundry.sh \
&& chmod +x foundry.sh \
&& ./foundry.sh \
&& foundryup
RUN apt-get update && apt-get install -y --no-install-recommends \
apt-transport-https \
ca-certificates \
wget \
tar \
unzip \
jq \
gcc \
libgmp-dev \
python3-dev \
build-essential \
&& rm -rf /var/lib/apt/lists/*
ARG GITHUB_TOKEN
ENV GITHUB_TOKEN=${GITHUB_TOKEN}
COPY . .
COPY .env.example .env
SHELL ["/bin/bash", "-c"]
RUN source "$HOME/.cargo/env"
# Install asdf for multiple scarb versions
RUN git clone --depth 1 https://github.com/asdf-vm/asdf.git "$HOME/.asdf" && \
echo ". $HOME/.asdf/asdf.sh" >> "$HOME/.bashrc" && \
echo ". $HOME/.asdf/asdf.sh" >> "$HOME/.profile"
RUN source "$HOME/.asdf/asdf.sh" && asdf plugin add scarb && asdf install scarb 0.7.0 && asdf install scarb 2.6.5 && asdf install scarb 2.8.3
RUN uv sync --all-extras --dev
RUN --mount=type=cache,target=/root/.cache \
source "$HOME/.asdf/asdf.sh" && source "$HOME/.cargo/env" && make build && make build-sol
############################################
# Kakarot deployer
############################################
FROM base as deployer
COPY --from=builder /app/kakarot/build ./build/
COPY --from=builder /app/kakarot/kakarot_scripts/ ./kakarot_scripts/
COPY --from=builder /app/kakarot/tests ./tests/
COPY --from=builder /app/kakarot/.venv ./.venv
# Cairo Smart contracts are used in deploy_kakarot.py
# To limit the probability of this Dockerfile to break, we copy the entire src and not individual files
COPY --from=builder /app/kakarot/cairo_zero/ ./cairo_zero/
COPY --from=builder /app/kakarot/cairo/ ./cairo/
# Default Solidity contracts are also used in deploy_kakarot.py
COPY --from=builder /app/kakarot/solidity_contracts ./solidity_contracts/
COPY --from=builder /app/kakarot/Makefile .
COPY --from=builder /app/kakarot/uv.lock .
COPY --from=builder /app/kakarot/pyproject.toml .
COPY --from=builder /app/kakarot/foundry.toml .
COPY --from=builder /app/kakarot/README.md .
COPY --from=builder /app/kakarot/.env.example .env
COPY --from=builder /app/kakarot/conftest.py .
ENV PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python
# Deploy kakarot
CMD ["uv", "run", "deploy"]