forked from ethereum-optimism/optimism
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathDockerfile-contracts
More file actions
58 lines (46 loc) · 2.02 KB
/
Dockerfile-contracts
File metadata and controls
58 lines (46 loc) · 2.02 KB
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
# Contracts build stage
FROM okexchain/go-builder:v1 AS contracts-builder
RUN apt install -y jq
RUN curl --proto '=https' --tlsv1.2 -LsSf https://github.com/alloy-rs/svm-rs/releases/download/v0.5.22/svm-rs-installer.sh | sh
ENV PATH=/root/.local/bin:$PATH
RUN svm install 0.8.30
RUN svm install 0.8.25
RUN svm install 0.8.19
RUN svm install 0.8.15
WORKDIR /app
# Copy the entire project (needed for git submodules)
COPY . .
# Initialize submodules and build contracts
WORKDIR /app/packages/contracts-bedrock
RUN git submodule update --init --recursive || echo "No submodules found"
RUN --mount=type=cache,target=/root/.foundry \
--mount=type=cache,target=/root/.cache \
forge build --skip "/**/test/**"
# Build op-deployer
WORKDIR /app
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/root/.cache \
--mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
go mod download
RUN --mount=type=cache,target=/root/.cache \
--mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
go build -o /app/op-deployer/bin/op-deployer ./op-deployer/cmd/op-deployer
# Create final contracts image with artifacts, foundry tools, and op-deployer
FROM debian:bookworm-slim
WORKDIR /app
RUN apt-get update && apt-get install -y ca-certificates && update-ca-certificates
# Set environment variables for Go
ENV SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
ENV SSL_CERT_DIR=/etc/ssl/certs
# Copy foundry tools for runtime use
COPY --from=contracts-builder /usr/local/bin/forge /usr/local/bin/cast /usr/local/bin/anvil /usr/local/bin/
COPY --from=contracts-builder /root/.local/bin/svm /usr/local/bin
COPY --from=contracts-builder /root/.svm /root/.svm
RUN apt install -y jq
# Copy op-deployer binary
COPY --from=contracts-builder /app/op-deployer/bin/ ./op-deployer/bin/
# Copy contract artifacts and config (copy essential files only)
COPY --from=contracts-builder /app/packages/contracts-bedrock/ ./packages/contracts-bedrock/
CMD ["echo", "Contracts and op-deployer ready"]