Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
microchipgnu committed Dec 18, 2024
1 parent 22bed60 commit 3753bcf
Show file tree
Hide file tree
Showing 8 changed files with 153 additions and 32 deletions.
40 changes: 40 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# build
dist/

# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts

.env
18 changes: 18 additions & 0 deletions .github/workflows/fly-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# See https://fly.io/docs/app-guides/continuous-deployment-with-github-actions/

name: Fly Deploy
on:
push:
branches:
- main
jobs:
deploy:
name: Deploy app
runs-on: ubuntu-latest
concurrency: deploy-group # optional: ensure only one action runs at a time
steps:
- uses: actions/checkout@v4
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy --remote-only
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
45 changes: 45 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# syntax = docker/dockerfile:1

# Adjust BUN_VERSION as desired
ARG BUN_VERSION=1.1.29
FROM oven/bun:${BUN_VERSION}-slim as base

LABEL fly_launch_runtime="Bun"

# Bun app lives here
WORKDIR /app

# Set production environment
ENV NODE_ENV="production"

# Throw-away build stage to reduce size of final image
FROM base as build

# Install packages needed to build node modules
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y build-essential pkg-config python-is-python3

# Install node modules
COPY bun.lockb package.json ./
RUN bun install

# Copy application code
COPY . .

# Build application
RUN bun --bun run build

# Remove development dependencies
RUN rm -rf node_modules && \
bun install --ci


# Final stage for app image
FROM base

# Copy built application
COPY --from=build /app /app

# Start the server by default, this can be overwritten at runtime
EXPOSE 10000
CMD [ "bun", "run", "start" ]
Binary file modified bun.lockb
Binary file not shown.
22 changes: 22 additions & 0 deletions fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# fly.toml app configuration file generated for near-uniswap-agent on 2024-12-18T10:52:52Z
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = 'near-uniswap-agent'
primary_region = 'cdg'

[build]

[http_service]
internal_port = 10000
force_https = true
auto_stop_machines = 'stop'
auto_start_machines = true
min_machines_running = 0
processes = ['app']

[[vm]]
memory = '1gb'
cpu_kind = 'shared'
cpus = 1
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
"private": true,
"type": "module",
"scripts": {
"dev": "concurrently \"tsx src/server.ts\" \"make-agent dev -p 3000\"",
"dev-testnet": "concurrently \"tsx src/server.ts\" \"make-agent dev -p 3000 -t\"",
"dev": "concurrently \"bun run src/server.ts\" \"make-agent dev -p 10000\"",
"dev-testnet": "concurrently \"bun run src/server.ts\" \"make-agent dev -p 10000 -t\"",
"build": "tsc",
"start": "tsx src/server.ts",
"serve": "bun dist/server.js",
"start": "bun run src/server.ts",
"serve": "bun run src/server.ts",
"lint": "eslint '{src,tests}/**/*.{js,jsx,ts,tsx}'",
"fmt": "eslint --fix '{src,tests}/**/*.{js,jsx,ts,tsx}' && prettier --write '{src,tests}/**/*.{js,jsx,ts,tsx}'",
"test": "jest --config jest.config.ts"
Expand All @@ -26,6 +26,7 @@
"zerion-sdk": "^0.0.13"
},
"devDependencies": {
"@flydotio/dockerfile": "^0.5.9",
"@types/cors": "^2.8.17",
"@types/express": "^4.17.21",
"@types/jest": "^29.5.14",
Expand Down
24 changes: 23 additions & 1 deletion src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,37 @@ import swaggerUi from "swagger-ui-express";
import { healthRouter } from "./routes/health";
import { uniswapRouter } from "./routes/uniswap";
import { pluginData } from "./plugin";
import path from "path";
import { fileURLToPath } from "url";

config(); // Load .env file

const app = express();
const port = process.env.PORT || 3000;
const port = process.env.PORT || 10000;

app.use(cors());
app.use(express.json());

// Serve static files from public directory
app.use(express.static('public'));

// Root route with API info
app.get("/", (_, res) => {
res.send(`
<h1>Bitte Uniswap Agent API</h1>
<p>Welcome to the Bitte Uniswap Agent API server.</p>
<ul>
<li><a href="/docs">API Documentation</a></li>
<li><a href="/.well-known/ai-plugin.json">OpenAI Plugin Specification</a></li>
</ul>
<h2>Available Routes:</h2>
<ul>
<li><code>/api/health</code> - Health check endpoint</li>
<li><code>/api/tools/uniswap</code> - Uniswap integration endpoints</li>
</ul>
`);
});

// Routes
app.use("/api/health", healthRouter);
app.use("/api/tools/uniswap", uniswapRouter);
Expand Down
27 changes: 0 additions & 27 deletions vercel.json

This file was deleted.

0 comments on commit 3753bcf

Please sign in to comment.