-
Notifications
You must be signed in to change notification settings - Fork 12
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
[EPIC] E2E DevOps #911
Open
0xlinus
wants to merge
13
commits into
staging
Choose a base branch
from
e2e-devops
base: staging
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[EPIC] E2E DevOps #911
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
ee3ef07
added dockerfiles + some logic changes
0xlinus c6ac87e
improvements
0xlinus 06a8717
added workflow
0xlinus 45eb83f
added ci folder
0xlinus 8449823
added changes for local dev
0xlinus 4c85598
added goerli tokens
0xlinus 21f63fe
added extra envs to add-envs script
0xlinus 12c54e3
no need for vercel deployment
0xlinus 4fc883f
fix envs export + ci warnings
0xlinus 2dbd3db
added missing deps +fix ci try 2
0xlinus a1768e2
fixed linting
0xlinus a4f497c
add mainnet token prov to envs
0xlinus 822e012
added tests + fix synpress envs issue
0xlinus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
FROM alpine:3.14 | ||
|
||
RUN apk update && apk add bash | ||
|
||
WORKDIR /app | ||
|
||
COPY ./ci/add-envs.sh ./ | ||
|
||
|
||
ENTRYPOINT ["/bin/bash", "-c"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,83 @@ | ||
# Aelin Frontend v2 | ||
# Aelin UI - Local Dev Environment | ||
|
||
### Run this application with Node 14 | ||
## How it works | ||
|
||
1. Copy `.env.example` as `.env.local` | ||
To be able to run Aelin and all its components locally we'll need: | ||
|
||
``` | ||
$ cp .env.example .env.local | ||
``` | ||
1. **Blockchain node** with the latest Aelin contracts deployed | ||
2. **Graph node** with the latest Aelin subgraphs deployed | ||
3. **Aelin UI app** running | ||
|
||
2. Install dependencies | ||
### Blockchain | ||
|
||
We'll use **Anvil** for this, which is a ganache-style blockchain node implemented by **Foundry**. There's a script that will run before everything else, which will deploy all contracts and deps needed. | ||
|
||
### Graph node | ||
|
||
A simple graph node as shown [here](https://thegraph.academy/developers/local-development/) | ||
|
||
### Aelin UI | ||
|
||
The one in this repo. | ||
|
||
## Steps | ||
|
||
First run `yarn` and install all deps (check that there are no errors) | ||
|
||
### 1 - Start Anvil + Subgraph + Deploy Contracts | ||
|
||
```sh | ||
. ./start-local.sh | ||
``` | ||
$ yarn | ||
``` | ||
|
||
3. Auto generate generate contracts types, subgraph types & queries SDK | ||
### 3 - Use generated envs | ||
|
||
You'll need new envs containing contracts, private keys (test net dont worry!), etc. | ||
Run this command and then change `.env.generated` to `.env` | ||
|
||
First you'll have to wait until all contracts are deployed and env variables are generated. Check `docker-compose` logs and wait until you start to see a lot of activity. | ||
|
||
After that's done you're safe to export the generated envs: | ||
|
||
```sh | ||
docker cp anvil:/usr/share/envs/.env.generated ./.env.generated | ||
``` | ||
$ yarn postinstall | ||
|
||
### 3 - Start UI | ||
|
||
```sh | ||
yarn dev | ||
``` | ||
|
||
- NOTE: `postinstall` will generates an sdk file in `CODEGEN_OUTPUT_FILE` environment variable (default value: `types/generated/queries.ts` ) with all queries uses in the App. | ||
### 4 - Run E2E test? | ||
|
||
4. Run application as dev mode | ||
> step 3 required! | ||
|
||
```sh | ||
yarn e2e:local | ||
``` | ||
$ yarn dev | ||
``` | ||
|
||
5. Open `http://localhost:3000` | ||
## Metamask config | ||
|
||
**Network** | ||
|
||
You'll need to add the local blockchain we've just started. | ||
|
||
![image](https://user-images.githubusercontent.com/99757679/217300010-2c434eab-b803-47b9-ad99-fed875a45223.png) | ||
|
||
**Account** | ||
|
||
Import a test account using the private key located in the `env.generated` | ||
|
||
**IMPORTANT** | ||
|
||
EVERY TIME your (re)start `docker-compose`, remember to reset Metamask account, otherwise you'll see an error due to block height miss match. | ||
|
||
![image](https://user-images.githubusercontent.com/99757679/217300243-1ef40d2d-72e7-4a1e-b113-716625dbb0cd.png) | ||
|
||
## Requirements | ||
|
||
```sh | ||
docker | ||
docker-compose | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM synthetixio/docker-e2e:18.13-ubuntu as base | ||
|
||
RUN apt install git | ||
|
||
WORKDIR /app | ||
|
||
COPY . . | ||
|
||
RUN echo "NEXT_PUBLIC_GRAPH_ENDPOINT_GOERLI=https://api.thegraph.com/subgraphs/name/alextheboredape/aelin-goerli" > .env | ||
RUN echo "NEXT_PUBLIC_GRAPH_ENDPOINT_OPTIMISM=https://api.thegraph.com/subgraphs/name/alextheboredape/aelin-optimism" > .env | ||
|
||
RUN yarn install --frozen-lockfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
FROM alpine:3.16 AS builder | ||
WORKDIR /opt | ||
RUN apk add clang lld curl build-base linux-headers git \ | ||
&& curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup.sh \ | ||
&& chmod +x ./rustup.sh \ | ||
&& ./rustup.sh -y | ||
RUN git clone https://github.com/foundry-rs/foundry.git | ||
# && cd foundry \ | ||
# && git reset --hard b554ab1fec09087fa3a35c6728968edca6debcf2 | ||
WORKDIR /opt/foundry | ||
RUN source $HOME/.profile && cargo build --release \ | ||
&& strip /opt/foundry/target/release/forge \ | ||
&& strip /opt/foundry/target/release/cast \ | ||
&& strip /opt/foundry/target/release/anvil | ||
|
||
FROM alpine:3.16 AS client | ||
ENV GLIBC_KEY=https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub | ||
ENV GLIBC_KEY_FILE=/etc/apk/keys/sgerrand.rsa.pub | ||
ENV GLIBC_RELEASE=https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.35-r0/glibc-2.35-r0.apk | ||
|
||
RUN apk add linux-headers gcompat git | ||
RUN wget -q -O ${GLIBC_KEY_FILE} ${GLIBC_KEY} \ | ||
&& wget -O glibc.apk ${GLIBC_RELEASE} \ | ||
&& apk add glibc.apk --force | ||
COPY --from=builder /opt/foundry/target/release/forge /usr/local/bin/forge | ||
COPY --from=builder /opt/foundry/target/release/cast /usr/local/bin/cast | ||
COPY --from=builder /opt/foundry/target/release/anvil /usr/local/bin/anvil | ||
RUN adduser -Du 1000 foundry | ||
|
||
EXPOSE 8545 | ||
|
||
ENTRYPOINT ["/bin/sh", "-c"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Install all deps | ||
FROM node:16-alpine AS deps | ||
RUN apk add --no-cache libc6-compat git | ||
WORKDIR /app | ||
COPY package.json yarn-lock.json* ./ | ||
COPY . . | ||
RUN yarn install --frozen-lockfile | ||
|
||
# Build app | ||
FROM node:16-alpine AS builder | ||
WORKDIR /app | ||
COPY --from=deps /app/node_modules ./node_modules | ||
COPY . . | ||
RUN yarn build | ||
|
||
# Run | ||
FROM node:16-alpine AS runner | ||
WORKDIR /app | ||
ENV NODE_ENV production | ||
ENV NEXT_TELEMETRY_DISABLED 1 | ||
|
||
RUN addgroup --system --gid 1001 nodejs | ||
RUN adduser --system --uid 1001 nextjs | ||
|
||
COPY --from=builder /app/next.config.js ./ | ||
COPY --from=builder /app/public ./public | ||
COPY --from=builder /app/package.json ./package.json | ||
COPY --from=builder /app/.env ./ | ||
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ | ||
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static | ||
|
||
USER nextjs | ||
|
||
EXPOSE 3000 | ||
|
||
ENV PORT 3000 | ||
|
||
ENTRYPOINT [ "/bin/sh", "-c" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/bin/bash | ||
|
||
file_path="/usr/share/envs/.env.linuz" | ||
|
||
while [ ! -f $file_path ] | ||
do | ||
echo "Waiting for file $file_path to exist..." | ||
sleep 1 | ||
done | ||
|
||
echo "Exporting ENVs for Aelin UI..." | ||
|
||
|
||
NEXT_PUBLIC_ANVIL="http://0.0.0.0:8545"; | ||
|
||
[[ $1 == ci ]] && NEXT_PUBLIC_ANVIL="http://anvil:8545"; | ||
|
||
NEXT_PUBLIC_AELIN_POOL_FACTORY=$(grep AelinPoolFactory_address /usr/share/envs/.env.linuz | tail -1 | awk -F "=" '{print $2}') | ||
NEXT_PUBLIC_AELIN_DEAL_FACTORY=$(grep AelinUpFrontDealFactory_address /usr/share/envs/.env.linuz | tail -1 | awk -F "=" '{print $2}') | ||
NEXT_PUBLIC_UNI=$(grep UNI_address /usr/share/envs/.env.linuz | tail -1 | awk -F "=" '{print $2}') | ||
NEXT_PUBLIC_USDC=$(grep USDC_address /usr/share/envs/.env.linuz | tail -1 | awk -F "=" '{print $2}') | ||
NEXT_PUBLIC_WETH=$(grep WETH_address /usr/share/envs/.env.linuz | tail -1 | awk -F "=" '{print $2}') | ||
|
||
echo " | ||
CODEGEN_OUTPUT_FILE=types/generated/queries.ts | ||
NEXT_PUBLIC_AELIN_VOUCHER_ENS_ADDRESS=aelincouncil.eth | ||
NEXT_PUBLIC_GRAPH_ENDPOINT_MAINNET=https://api.thegraph.com/subgraphs/name/alextheboredape/aelin-mainnet | ||
NEXT_PUBLIC_GRAPH_ENDPOINT_OPTIMISM=https://api.thegraph.com/subgraphs/name/alextheboredape/aelin-optimism | ||
NEXT_PUBLIC_GRAPH_ENDPOINT_ARBITRUM=https://api.thegraph.com/subgraphs/name/alextheboredape/aelin-arbitrum | ||
NEXT_PUBLIC_GRAPH_ENDPOINT_POLYGON=https://api.thegraph.com/subgraphs/name/alextheboredape/aelin-polygon | ||
NEXT_PUBLIC_IPFS_GATEWAY_BASE_URL=https://w3s.link/ipfs | ||
NEXT_PUBLIC_MAINTENANCE_MESSAGE_SUBTITLE=undefined | ||
NEXT_PUBLIC_MAINTENANCE_MESSAGE_TITLE=undefined | ||
NEXT_PUBLIC_MAINTENANCE_MODE=false | ||
QUIXOTIC_API_TOKEN=ask | ||
SIMPLEHASH_API_KEY=ask | ||
STRATOS_API_TOKEN=ask | ||
NEXT_PUBLIC_ARBITRUM_TOKEN_PROVIDER=ask | ||
NEXT_PUBLIC_GOERLI_TOKEN_PROVIDER=ask | ||
NEXT_PUBLIC_OPTIMISM_TOKEN_PROVIDER=ask | ||
NEXT_PUBLIC_POLYGON_TOKEN_PROVIDER=ask | ||
NEXT_PUBLIC_MAINNET_TOKEN_PROVIDER=EW9N4oDCQJ58k_9wF-wG8pkq7amdPnqD | ||
NEXT_PUBLIC_WEB3_STORAGE_TOKEN_KEY=ask | ||
NEXT_PUBLIC_APP_NAME=Aelin | ||
NEXT_PUBLIC_APP_ENV=development | ||
NEXT_PUBLIC_REACT_APP_DEFAULT_CHAIN_ID=5 | ||
NEXT_PUBLIC_APP_URL=https://app.aelin.xyz | ||
NEXT_PUBLIC_APP_NAME=aelin | ||
[email protected] | ||
NEXT_PUBLIC_GRAPH_ENDPOINT_GOERLI=http://0.0.0.0:8000/subgraphs/name/aelinprotocol/e2e-subgraph | ||
NEXT_PUBLIC_ETH_GAS_STATION_API_URL=https://ethgasstation.info/json/ethgasAPI.json | ||
NEXT_PUBLIC_GAS_NOW_API_URL=https://etherchain.org/api/gasnow | ||
NEXT_PUBLIC_AELIN_POOL_FACTORY=${NEXT_PUBLIC_AELIN_POOL_FACTORY} | ||
NEXT_PUBLIC_AELIN_DEAL_FACTORY=${NEXT_PUBLIC_AELIN_DEAL_FACTORY} | ||
NEXT_PUBLIC_UNI=${NEXT_PUBLIC_UNI} | ||
NEXT_PUBLIC_USDC=${NEXT_PUBLIC_USDC} | ||
NEXT_PUBLIC_WETH=${NEXT_PUBLIC_WETH} | ||
NEXT_PUBLIC_ANVIL=${NEXT_PUBLIC_ANVIL} | ||
PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 | ||
NETWORK_NAME=goerli | ||
" >> .env |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you create a
TESTING.md
file to add this? I don't think it's necessary to run the entire protocol locally for development reasons. I don't think it's worth adding so much complexity to just run the app.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree. But if there's gonna be a pool/deal creation or interaction, then we should use this. Otherwise will be continue to pollute Goerli. Also we tend to always use small token values bc of balance limitations which ended up creating bugs in the past. So:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It adds too much complexity to run the dapp IMO. I would move this to
TESTING.md
, which is what it was created for. I don't want new contributors to struggle w/this when the steps are now pretty simple.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still think that we should go this way:
We can discuss this later in standies
PS: running 2 commands is adding too much complexity?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it not only adds two commands, but requires installing and managing docker and docker compose. Having been developed with the docker stack, it has disadvantages compared to the previous approach. For instance: slower nextjs fast refresh, need to prune your images/container because it uses huge disk space, slower startup time...