Skip to content

Commit

Permalink
feat: add docker
Browse files Browse the repository at this point in the history
  • Loading branch information
harsh-98 committed Dec 24, 2024
1 parent 3257749 commit b257aa9
Show file tree
Hide file tree
Showing 6 changed files with 154 additions and 20 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Release

on:
push:
branches:
- "main"
workflow_dispatch:

env:
HUSKY: 0
CI: true

jobs:
release:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}

- name: Semantic Release
uses: cycjimmy/semantic-release-action@v4
with:
extra_plugins: |
@codedependant/semantic-release-docker
env:
GITHUB_TOKEN: ${{ github.token }}
35 changes: 35 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"branches": [
{
"name": "main"
}
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
[
"@semantic-release/github",
{
"successComment": false,
"failTitle": false
}
],
[
"@codedependant/semantic-release-docker",
{
"dockerTags": [
"{{#if prerelease.[0]}}{{prerelease.[0]}}{{else}}latest{{/if}}",
"{{version}}"
],
"dockerArgs": {
"PACKAGE_VERSION": "{{version}}"
},
"dockerImage": "apy-server",
"dockerRegistry": "ghcr.io",
"dockerProject": "gearbox-protocol",
"dockerBuildQuiet": false,
"dockerLogin": false
}
]
]
}
34 changes: 34 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM node:20.14 as dev

ENV YARN_CACHE_FOLDER=/root/.yarn

WORKDIR /app

COPY . .

RUN --mount=type=cache,id=yarn,target=/root/.yarn \
yarn install --frozen-lockfile --ignore-engines \
&& yarn build

# Production npm modules

FROM node:20.14 as prod

ENV YARN_CACHE_FOLDER=/root/.yarn

WORKDIR /app

COPY --from=dev /app/package.json /app
COPY --from=dev /app/build/ /app/build

RUN --mount=type=cache,id=yarn,target=/root/.yarn \
yarn install --production --frozen-lockfile --ignore-engines


# Final image

FROM gcr.io/distroless/nodejs20-debian12

WORKDIR /app
COPY --from=dev /app /app
CMD ["--enable-source-maps", "/app/build/main.mjs"]
26 changes: 26 additions & 0 deletions esbuild.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { build } from "esbuild";

build({
entryPoints: ["main.ts"],
outdir: "build",
bundle: true,
platform: "node",
format: "esm",
outExtension: { ".js": ".mjs" },
target: ["node20"],
sourcemap: "external",
banner: {
js: `
import { createRequire } from 'module';
import { fileURLToPath } from 'url';
const require = createRequire(import.meta.url);
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
`,
},
external: ["node-pty"],
}).catch(e => {
console.error(e);
process.exit(1);
});
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"description": "Gearbox SDK",
"main": "index.js",
"license": "MIT",
"scripts": {
"build": "node esbuild.config.mjs"
},
"dependencies": {
"axios": "^1.7.9",
"cors": "^2.8.5",
Expand All @@ -18,4 +21,4 @@
"@types/cors": "^2.8.17",
"@types/express": "^5.0.0"
}
}
}
41 changes: 22 additions & 19 deletions src/apy/curveAPY.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,13 @@ export async function getCurveAPY(network: NetworkType, store: TokenStore): Prom
reward: pool.lpTokenAddress,
symbol: curveSymbol,
value: curveAPYToBn(baseAPY),
}, {
reward: crv.address,
symbol: crv.symbol,
value: curveAPYToBn(maxCrv),
}, ...extraRewards];
},
// {
// reward: crv.address,
// symbol: crv.symbol,
// value: curveAPYToBn(maxCrv),
// }, ...extraRewards,
];
acc[pool.lpTokenAddress] = getTokenAPY(curveSymbol, curveAPYs);
return acc;
},
Expand Down Expand Up @@ -199,20 +201,21 @@ export async function getCurveAPY(network: NetworkType, store: TokenStore): Prom
symbol: gearPool.symbol,
value: curveAPYToBn(gearVolume?.latestDailyApyPcent || 0),
},
{
reward: crv.address,
symbol: crv.symbol,
value: curveAPYToBn(Math.max(...(gearPool?.gaugeCrvApy || []), 0)),
},
...(gearPool?.gaugeRewards || []).map(
({ apy = 0, symbol, tokenAddress }): ApyDetails => {
return {
reward: tokenAddress,
symbol: symbol,
value: curveAPYToBn(apy),
}
}
)];
// {
// reward: crv.address,
// symbol: crv.symbol,
// value: curveAPYToBn(Math.max(...(gearPool?.gaugeCrvApy || []), 0)),
// },
// ...(gearPool?.gaugeRewards || []).map(
// ({ apy = 0, symbol, tokenAddress }): ApyDetails => {
// return {
// reward: tokenAddress,
// symbol: symbol,
// value: curveAPYToBn(apy),
// }
// }
// ),
];

curveAPY[GEAR_POOL as Address] = getTokenAPY(gearPool.symbol, gearAPY);

Expand Down

0 comments on commit b257aa9

Please sign in to comment.