From 3d3c9024094820c51965d7ee13f2a1ef436fd21d Mon Sep 17 00:00:00 2001 From: victor <52110451+cs50victor@users.noreply.github.com> Date: Sat, 2 Mar 2024 13:48:26 -0500 Subject: [PATCH] feat: deploy docker backend on fly.io (#12) * feat: vercel analytics * feat:fly.io * feat: dockerfile --- .dockerignore | 3 ++- .python-version | 1 + Dockerfile | 7 ++++--- README.md | 3 ++- app/layout.tsx | 2 ++ fly.toml | 23 +++++++++++++++++++++++ package.json | 1 + pnpm-lock.yaml | 23 +++++++++++++++++++++++ requirements.txt | 49 ++++++------------------------------------------ 9 files changed, 64 insertions(+), 48 deletions(-) create mode 100644 .python-version create mode 100644 fly.toml diff --git a/.dockerignore b/.dockerignore index 35f68de..1cbb524 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,3 @@ * -!server/**.py \ No newline at end of file +!server/**.py +!requirements.txt \ No newline at end of file diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..171a6a9 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.12.1 diff --git a/Dockerfile b/Dockerfile index c49b360..91178fe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1 -ARG PYTHON_VERSION=3.11.6 +ARG PYTHON_VERSION=3.12.1 FROM python:${PYTHON_VERSION}-slim as base # Prevents Python from writing pyc files. @@ -27,10 +27,11 @@ RUN adduser \ # Copy the source code into the container. COPY . . -RUN python -m pip install -r requirements.txt +RUN pip install -r requirements.txt +RUN pip install supabase # Switch to the non-privileged user to run the application. USER appuser # Run the application. -CMD python agent.py start \ No newline at end of file +CMD python server/agent.py start \ No newline at end of file diff --git a/README.md b/README.md index 93fabb4..3a634a3 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ # Buildspace AI + `find and be found.` -a more detailed docs coming soon. +a more detailed docs coming soon. ## setup for mac diff --git a/app/layout.tsx b/app/layout.tsx index b7d072c..0b34ae8 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -1,3 +1,4 @@ +import { Analytics } from '@vercel/analytics/react'; import type { Metadata } from 'next'; import { Inter, Roboto } from 'next/font/google'; @@ -34,6 +35,7 @@ export default function RootLayout({ children }: { children: React.ReactNode }) > {children} + diff --git a/fly.toml b/fly.toml new file mode 100644 index 0000000..4a96019 --- /dev/null +++ b/fly.toml @@ -0,0 +1,23 @@ +# fly.toml app configuration file generated for buildspace on 2024-03-01T19:57:23-05:00 +# +# See https://fly.io/docs/reference/configuration/ for information about how to use this file. +# + +app = 'buildspace' +primary_region = 'iad' + +[build] + dockerfile = 'Dockerfile' + +[http_service] + internal_port = 8080 + force_https = true + auto_stop_machines = true + auto_start_machines = true + min_machines_running = 0 + processes = ['app'] + +[[vm]] + memory = '1gb' + cpu_kind = 'shared' + cpus = 1 diff --git a/package.json b/package.json index d370795..964d083 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "@radix-ui/react-menubar": "^1.0.4", "@radix-ui/react-separator": "^1.0.3", "@radix-ui/react-slot": "^1.0.2", + "@vercel/analytics": "^1.2.2", "class-variance-authority": "^0.7.0", "clsx": "^2.1.0", "framer-motion": "^11.0.5", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bf76534..c91e031 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -29,6 +29,9 @@ importers: '@radix-ui/react-slot': specifier: ^1.0.2 version: 1.0.2(@types/react@18.2.47)(react@18.2.0) + '@vercel/analytics': + specifier: ^1.2.2 + version: 1.2.2(next@14.0.4)(react@18.2.0) class-variance-authority: specifier: ^0.7.0 version: 0.7.0 @@ -1296,6 +1299,22 @@ packages: resolution: {integrity: sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==} dev: true + /@vercel/analytics@1.2.2(next@14.0.4)(react@18.2.0): + resolution: {integrity: sha512-X0rctVWkQV1e5Y300ehVNqpOfSOufo7ieA5PIdna8yX/U7Vjz0GFsGf4qvAhxV02uQ2CVt7GYcrFfddXXK2Y4A==} + peerDependencies: + next: '>= 13' + react: ^18 || ^19 + peerDependenciesMeta: + next: + optional: true + react: + optional: true + dependencies: + next: 14.0.4(react-dom@18.2.0)(react@18.2.0) + react: 18.2.0 + server-only: 0.0.1 + dev: false + /acorn-jsx@5.3.2(acorn@8.11.3): resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==} peerDependencies: @@ -3850,6 +3869,10 @@ packages: dependencies: lru-cache: 6.0.0 + /server-only@0.0.1: + resolution: {integrity: sha512-qepMx2JxAa5jjfzxG79yPPq+8BuFToHd1hm7kI+Z4zAq1ftQiP7HcxMhDDItrbtwVeLg/cY2JnKnrcFkmiswNA==} + dev: false + /set-function-length@1.1.1: resolution: {integrity: sha512-VoaqjbBJKiWtg4yRcKBQ7g7wnGnLV3M8oLvVWwOk2PdYY6PEFegR1vezXR0tw6fZGF9csVakIRjrJiy2veSBFQ==} engines: {node: '>= 0.4'} diff --git a/requirements.txt b/requirements.txt index ced32e1..0b2a711 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,45 +1,8 @@ -aiohttp==3.9.3 -aiosignal==1.3.1 -annotated-types==0.6.0 -anyio==4.3.0 -attrs==23.2.0 -certifi==2024.2.2 -click==8.1.7 -deprecation==2.1.0 -distro==1.9.0 -frozenlist==1.4.1 -gotrue==2.4.1 -h11==0.14.0 -httpcore==1.0.4 -httpx==0.25.2 -idna==3.6 livekit==0.9.1 -livekit-agents==0.4.0 -livekit-api==0.4.2 -livekit-plugins-deepgram==0.2.0 -livekit-plugins-elevenlabs==0.2.0 -livekit-protocol==0.3.1 -multidict==6.0.5 -openai==1.12.0 -packaging==23.2 -postgrest==0.16.1 -protobuf==4.25.3 -pydantic==2.6.2 -pydantic_core==2.16.3 -PyJWT==2.8.0 -python-dateutil==2.9.0 +livekit_agents==0.4.0 +livekit_api==0.4.2 +livekit_plugins_deepgram==0.2.0 +livekit_plugins_elevenlabs==0.2.0 +livekit_protocol==0.3.1 +openai==1.13.3 python-dotenv==1.0.1 -realtime==1.0.2 -setuptools==68.2.2 -six==1.16.0 -sniffio==1.3.0 -storage3==0.7.0 -StrEnum==0.4.15 -supabase==2.4.0 -supafunc==0.3.3 -tqdm==4.66.2 -types-protobuf==4.24.0.20240129 -typing_extensions==4.9.0 -websockets==11.0.3 -wheel==0.41.2 -yarl==1.9.4