Skip to content

Commit

Permalink
added dockerfiles + some logic changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Federico Sebaste committed Jan 19, 2023
1 parent 0b93b23 commit 74dd025
Show file tree
Hide file tree
Showing 9 changed files with 906 additions and 279 deletions.
11 changes: 11 additions & 0 deletions ci/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM node:16-alpine

RUN apk add --no-cache libc6-compat git

WORKDIR /app

COPY . .

RUN yarn install --frozen-lockfile

CMD [ "yarn", "dev" ]
32 changes: 32 additions & 0 deletions ci/Dockerfile-anvil
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"]
38 changes: 38 additions & 0 deletions ci/Dockerfile-vercel
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" ]
87 changes: 87 additions & 0 deletions ci/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
version: '3'
services:
anvil:
image: linuzeth/aelin-anvil
command: ["anvil --gas-limit 18446744073709551615 --host 0.0.0.0 --allow-origin '*' --chain-id 5"]
environment:
- ANVIL_IP_ADDR=0.0.0.0
ports:
- '8545:8545'

graph-node:
image: graphprotocol/graph-node
ports:
- '8000:8000'
- '8001:8001'
- '8020:8020'
- '8030:8030'
- '8040:8040'
depends_on:
- ipfs
- postgres
- anvil
environment:
postgres_host: postgres
postgres_user: graph-node
postgres_pass: let-me-in
postgres_db: graph-node
ipfs: 'ipfs:5001'
ethereum: 'mainnet:http://anvil:8545'
GRAPH_LOG: info

ipfs:
image: ipfs/go-ipfs:v0.10.0
ports:
- '5001:5001'

postgres:
image: postgres
ports:
- '5432:5432'
command: ['postgres', '-cshared_preload_libraries=pg_stat_statements']
environment:
POSTGRES_USER: graph-node
POSTGRES_PASSWORD: let-me-in
POSTGRES_DB: graph-node
PGDATA: '/var/lib/postgresql/data'
POSTGRES_INITDB_ARGS: '-E UTF8 --locale=C'

contracts-deployer:
image: linuzeth/aelin-contracts-deployer
command: [". ./deploy-ci.sh"]
depends_on:
- anvil

subgraph-deployer:
image: linuzeth/aelin-subgraph-deployer
command: ["npm run create-local && npm run deploy-local"]
depends_on:
contracts-deployer:
condition: service_completed_successfully

aelin-ui:
build:
context: ..
dockerfile: ./ci/Dockerfile
environment:
- NEXT_PUBLIC_APP_NAME=Aelin
- NEXT_PUBLIC_APP_ENV=development
- NEXT_PUBLIC_REACT_APP_DEFAULT_CHAIN_ID=5
- NEXT_PUBLIC_APP_URL=app.aelin.xyz
- NEXT_PUBLIC_APP_NAME=aelin
- [email protected]
- NEXT_PUBLIC_GRAPH_ENDPOINT_GOERLI=http://0.0.0.0:8000/subgraphs/name/0xlinus/boot-node-goerli
- 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=0x8A791620dd6260079BF849Dc5567aDC3F2FdC318
- NEXT_PUBLIC_AELIN_DEAL_FACTORY=0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6
- NEXT_PUBLIC_UNI=0x610178dA211FEF7D417bC0e6FeD39F05609AD788
- NEXT_PUBLIC_USDC=0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e
- NEXT_PUBLIC_ANVIL=http://0.0.0.0:8545
- CODEGEN_OUTPUT_FILE=types/generated/queries.ts
ports:
- '3000:3000'
depends_on:
subgraph-deployer:
condition: service_completed_successfully

3 changes: 2 additions & 1 deletion next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ module.exports = {
"storage.googleapis.com",
"ipfs.io"
]
}
},
output: "standalone"
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"is-ipfs": "^7.0.3",
"lodash": "^4.17.21",
"ms": "^2.1.3",
"next": "12.1.0",
"next": "12.3.1",
"nullthrows": "^1.1.1",
"papaparse": "^5.3.2",
"polished": "^4.1.4",
Expand All @@ -74,6 +74,7 @@
"react-papaparse": "^4.0.2",
"react-tooltip": "^4.2.21",
"sanitize.css": "^13.0.0",
"sharp": "^0.31.3",
"styled-components": "^5.3.3",
"swr": "^1.3.0",
"web3.storage": "^4.4.0"
Expand All @@ -100,12 +101,11 @@
"cheerio": "^1.0.0-rc.12",
"dotenv": "^16.0.1",
"eslint": "^8.10.0",
"eslint-config-next": "^12.1.0",
"eslint-config-next": "^13.1.1",
"eslint-config-prettier": "^8.5.0",
"eslint-loader": "^4.0.2",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react-hooks": "^4.3.0",
"eslint-plugin-sort-destructure-keys": "^1.4.0",
"graphql-codegen-plugin-typescript-swr": "^0.8.1",
"husky": "^7.0.4",
Expand Down
8 changes: 6 additions & 2 deletions src/constants/chains.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,12 @@ export const chainsConfig: Record<ChainsValues, ChainConfig> = {
id: Chains.goerli,
isProd: false,
name: 'Görli Testnet',
rpcUrl: `https://eth-goerli.g.alchemy.com/v2/${process.env.NEXT_PUBLIC_GOERLI_TOKEN_PROVIDER}`,
defaultRpcUrl: `https://eth-goerli.g.alchemy.com/v2/${process.env.NEXT_PUBLIC_GOERLI_TOKEN_PROVIDER}`,
rpcUrl:
(process.env.NEXT_PUBLIC_ANVIL as string) ??
`https://eth-goerli.g.alchemy.com/v2/${process.env.NEXT_PUBLIC_GOERLI_TOKEN_PROVIDER}`,
defaultRpcUrl:
(process.env.NEXT_PUBLIC_ANVIL as string) ??
`https://eth-goerli.g.alchemy.com/v2/${process.env.NEXT_PUBLIC_GOERLI_TOKEN_PROVIDER}`,
shortName: 'Goerli',
tokenListUrl: [
'https://tokens.1inch.eth.limo',
Expand Down
8 changes: 6 additions & 2 deletions src/constants/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ export const contracts = constantContracts({
REGULAR_POOL_FACTORY: {
address: {
[Chains.mainnet]: '0x722969A3fdc778a5cC7CbC8DC8Ae3e96a288f853',
[Chains.goerli]: '0xb52736cE26345942134b11083e88A0DD9Ef1be5A',
[Chains.goerli]:
(process.env.NEXT_PUBLIC_AELIN_POOL_FACTORY as string) ??
'0xb52736cE26345942134b11083e88A0DD9Ef1be5A',
[Chains.optimism]: '0x8B35551d6459a3d49B9A5A0D7333c6D7E0cCbBd9',
[Chains.arbitrum]: '0xbf7c0Fd0D31bC377f861d11d4aAc15296c0405b6',
},
Expand All @@ -47,7 +49,9 @@ export const contracts = constantContracts({
DIRECT_DEALS_FACTORY: {
address: {
[Chains.mainnet]: '0x97efdb29c0d6dacdc0bb334cc227ae03a1a7c01e',
[Chains.goerli]: '0x50c4eea08ae5544b622c96683823cecdc8b0e8ba',
[Chains.goerli]:
(process.env.NEXT_PUBLIC_AELIN_DEAL_FACTORY as string) ??
'0x50c4eea08ae5544b622c96683823cecdc8b0e8ba',
[Chains.optimism]: '0xe6355E5B217390A2F888c35f73248844847b0ef4',
[Chains.arbitrum]: '0x91fCeA33D02d11621b7f90ebd5E44eD393eD7b5e',
},
Expand Down
Loading

0 comments on commit 74dd025

Please sign in to comment.