From 6dde474fc2e75a4aa519192bab64d41c538f1380 Mon Sep 17 00:00:00 2001 From: victor <52110451+cs50victor@users.noreply.github.com> Date: Tue, 20 Feb 2024 20:25:31 -0500 Subject: [PATCH] refactor: setup and deploy to FLY gpu (#24) --- .github/workflows/fly.yml | 26 ++++++++++++++++++++++++++ demo/components/WebSocketExample.tsx | 3 ++- fly.toml | 6 +++--- 3 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/fly.yml diff --git a/.github/workflows/fly.yml b/.github/workflows/fly.yml new file mode 100644 index 0000000..c4a980a --- /dev/null +++ b/.github/workflows/fly.yml @@ -0,0 +1,26 @@ +name: Deploy NEW_MEDIA to Fly + +on: + push: + branches: + - main + workflow_dispatch: + +env: + CARGO_TERM_COLOR: always + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Get source code + uses: actions/checkout@v3 + + - name: Deploy to Fly.io + uses: superfly/flyctl-actions@1.4 + env: + FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} + with: + args: "deploy --remote-only --dockerfile ./Dockerfile.prod --config ./fly.toml" + + diff --git a/demo/components/WebSocketExample.tsx b/demo/components/WebSocketExample.tsx index a9ec203..b232bfe 100644 --- a/demo/components/WebSocketExample.tsx +++ b/demo/components/WebSocketExample.tsx @@ -12,11 +12,12 @@ export interface ServerWSResponse { } export default function WebSocketExample({port = 8080}:{port?:number}){ + const server_ws_url = process.env.NODE_ENV === "production" ? `ws://localhost:${port}` : "ws://new-media.fly.dev" const [imgMetadata, setImageMetadata] = useState(); const [socket, setSocket] = useState() useEffect(() => { - const socket = new WebSocket(`ws://localhost:${port}`) + const socket = new WebSocket(server_ws_url) socket.onopen = () => { setSocket(socket) diff --git a/fly.toml b/fly.toml index c451701..911200f 100644 --- a/fly.toml +++ b/fly.toml @@ -1,5 +1,5 @@ -app = 'new-media-still-surf-1038' -primary_region = 'sjc' +app = 'new-media' +primary_region = 'ord' [build] dockerfile = 'Dockerfile.prod' @@ -16,4 +16,4 @@ primary_region = 'sjc' cpu_kind = 'performance' memory = '64gb' cpus = 16 - size = "a100-40gb" \ No newline at end of file + size = "a100-40gb"