Skip to content

Commit b9a84b7

Browse files
authored
Fix ci anchor build (#132)
1 parent e02d1fd commit b9a84b7

File tree

3 files changed

+62
-24
lines changed

3 files changed

+62
-24
lines changed

.github/workflows/push-rust-services.yaml

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,23 @@ jobs:
3737
tags: |
3838
type=sha,event=branch
3939
type=ref,event=tag
40+
- name: Build and push server docker image
41+
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
42+
with:
43+
context: .
44+
push: true
45+
tags: ${{ steps.meta_server.outputs.tags }}
46+
labels: ${{ steps.meta_server.outputs.labels }}
47+
vault-monitor:
48+
runs-on: ubuntu-latest
49+
steps:
50+
- uses: actions/checkout@v2
51+
- name: Log in to the Container registry
52+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
53+
with:
54+
registry: ${{ env.REGISTRY }}
55+
username: ${{ github.actor }}
56+
password: ${{ secrets.GITHUB_TOKEN }}
4057
- name: Extract metadata (tags, labels) for Docker
4158
id: meta_monitor
4259
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
@@ -45,21 +62,6 @@ jobs:
4562
tags: |
4663
type=sha,event=branch
4764
type=ref,event=tag
48-
- name: Extract metadata (tags, labels) for Docker
49-
id: meta_swap_beacon
50-
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
51-
with:
52-
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-swap-beacon
53-
tags: |
54-
type=sha,event=branch
55-
type=ref,event=tag
56-
- name: Build and push server docker image
57-
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
58-
with:
59-
context: .
60-
push: true
61-
tags: ${{ steps.meta_server.outputs.tags }}
62-
labels: ${{ steps.meta_server.outputs.labels }}
6365
- name: Build and push vault monitor docker image
6466
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
6567
with:
@@ -68,6 +70,24 @@ jobs:
6870
push: true
6971
tags: ${{ steps.meta_monitor.outputs.tags }}
7072
labels: ${{ steps.meta_monitor.outputs.labels }}
73+
swap-beacon:
74+
runs-on: ubuntu-latest
75+
steps:
76+
- uses: actions/checkout@v2
77+
- name: Log in to the Container registry
78+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
79+
with:
80+
registry: ${{ env.REGISTRY }}
81+
username: ${{ github.actor }}
82+
password: ${{ secrets.GITHUB_TOKEN }}
83+
- name: Extract metadata (tags, labels) for Docker
84+
id: meta_swap_beacon
85+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
86+
with:
87+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-swap-beacon
88+
tags: |
89+
type=sha,event=branch
90+
type=ref,event=tag
7191
- name: Build and push swap beacon docker image
7292
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
7393
with:

Dockerfile

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,40 @@ ARG RUST_VERSION=1.66.1
33
# Get the solidity dependencies using npm
44
FROM node:21-alpine3.18 AS npm_build
55
WORKDIR /src
6-
COPY contracts contracts
6+
COPY contracts/evm contracts/evm
77
WORKDIR /src/contracts/evm
88
RUN npm install
99

10+
# Build solana anchor
11+
FROM solanalabs/solana:v1.18.18 AS solana_build
12+
RUN apt-get update \
13+
&& apt-get install -y \
14+
apt-utils \
15+
curl \
16+
gcc \
17+
&& rm -rf /var/lib/apt/lists/*
18+
RUN curl https://sh.rustup.rs -sSf > /tmp/rustup-init.sh \
19+
&& chmod +x /tmp/rustup-init.sh \
20+
&& sh /tmp/rustup-init.sh -y \
21+
&& rm -rf /tmp/rustup-init.sh
22+
ENV PATH="/root/.cargo/bin:${PATH}"
23+
RUN ["/bin/bash", "-c", "source $HOME/.cargo/env"]
24+
RUN rustup default nightly-2024-02-04
25+
RUN cargo install --git https://github.com/coral-xyz/anchor --tag v0.30.1 anchor-cli --locked
26+
WORKDIR /src
27+
COPY contracts/svm contracts/svm
28+
WORKDIR /src/contracts/svm
29+
RUN anchor build
1030

1131
FROM rust:${RUST_VERSION} AS build
32+
1233
# Set default toolchain
1334
RUN rustup default nightly-2024-04-10
1435

1536
# Install dependencies
1637
RUN curl -L https://foundry.paradigm.xyz | bash
1738
ENV PATH="${PATH}:/root/.foundry/bin/"
1839
RUN foundryup
19-
RUN cargo install --git https://github.com/coral-xyz/anchor --tag v0.30.1 anchor-cli --locked
2040

2141
# Add contracts
2242
WORKDIR /src
@@ -32,9 +52,7 @@ RUN forge install Uniswap/permit2@0x000000000022D473030F116dDEE9F6B43aC78BA3 --n
3252
RUN forge install nomad-xyz/ExcessivelySafeCall@be417ab0c26233578b8d8f3a37b87bd1fcb4e286 --no-git --no-commit
3353

3454
# Add solana dependencies
35-
WORKDIR /src
36-
WORKDIR /src/contracts/svm
37-
RUN anchor build
55+
COPY --from=solana_build /src/contracts/svm/target/ /src/contracts/svm/target/
3856

3957
# Build auction-server
4058
WORKDIR /src

per_sdk/Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ FROM node:21-alpine3.18 AS npm_build
66

77
WORKDIR /src
88
COPY contracts contracts
9-
WORKDIR /src/contracts
9+
WORKDIR /src/contracts/evm
1010
RUN npm install
1111

1212

@@ -22,8 +22,8 @@ RUN foundryup
2222
# Add solidity dependencies
2323
WORKDIR /src
2424
COPY contracts contracts
25-
COPY --from=npm_build /src/contracts/node_modules/ /src/contracts/node_modules/
26-
WORKDIR /src/contracts
25+
COPY --from=npm_build /src/contracts/evm/node_modules/ /src/contracts/evm/node_modules/
26+
WORKDIR /src/contracts/evm
2727
RUN forge install foundry-rs/forge-std@v1.8.0 --no-git --no-commit
2828
RUN forge install OpenZeppelin/openzeppelin-contracts@v5.0.2 --no-git --no-commit
2929
RUN forge install OpenZeppelin/openzeppelin-contracts-upgradeable@v4.9.6 --no-git --no-commit
@@ -56,7 +56,7 @@ ENV PATH="$POETRY_HOME/bin:$PATH"
5656
# Copy only requirements to cache them in docker layer
5757
WORKDIR /src
5858
COPY per_sdk/poetry.lock per_sdk/pyproject.toml /src/per_sdk/
59-
COPY --from=contract_build /src/contracts/out/ /src/contracts/out/
59+
COPY --from=contract_build /src/contracts/evm/out/ /src/contracts/evm/out/
6060

6161
# Project initialization:
6262
RUN poetry -C per_sdk install --no-interaction --no-ansi

0 commit comments

Comments
 (0)