From aac09f9e2f28067e8ed10215269574275326cc74 Mon Sep 17 00:00:00 2001 From: Charles OuGuo Date: Fri, 2 Aug 2024 20:46:54 -0400 Subject: [PATCH] Deploy fitbit-challenges on Fly.io (#334) --- .github/workflows/main.yml | 16 +++++++++++ fitbit_challenges/api/fly.toml | 34 ++++++++++++++++++++++++ fitbit_challenges/frontend/.dockerignore | 26 ++++++++++++++++++ fitbit_challenges/frontend/fly.toml | 29 ++++++++++++++++++++ 4 files changed, 105 insertions(+) create mode 100644 fitbit_challenges/api/fly.toml create mode 100644 fitbit_challenges/frontend/.dockerignore create mode 100644 fitbit_challenges/frontend/fly.toml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d6552bb1..2c62f0b7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -88,6 +88,22 @@ jobs: bazel --bazelrc=.github/workflows/ci.bazelrc --bazelrc=.bazelrc run --build_tag_filters=manual --stamp --embed_label $(git rev-parse HEAD) //fitbit_challenges/api:api_image_image_dockerhub bazel --bazelrc=.github/workflows/ci.bazelrc --bazelrc=.bazelrc run --build_tag_filters=manual --stamp --embed_label $(git rev-parse HEAD) //fitbit_challenges/worker:image_dockerhub bazel --bazelrc=.github/workflows/ci.bazelrc --bazelrc=.bazelrc run --build_tag_filters=manual --stamp --embed_label $(git rev-parse HEAD) //fitbit_challenges/frontend:production_cross_platform_image_dockerhub + deploy_fitbit_challenges: + needs: push_fitbit_challenges + if: ${{ github.ref == 'refs/heads/main' }} + concurrency: + group: fitbit_challenges_production + cancel-in-progress: false + env: + FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: superfly/flyctl-actions/setup-flyctl@master + - run: flyctl deploy + working-directory: fitbit_challenges/api + - run: flyctl deploy + working-directory: fitbit_challenges/frontend push_home_api: needs: build if: ${{ github.ref == 'refs/heads/main' }} diff --git a/fitbit_challenges/api/fly.toml b/fitbit_challenges/api/fly.toml new file mode 100644 index 00000000..8095e16c --- /dev/null +++ b/fitbit_challenges/api/fly.toml @@ -0,0 +1,34 @@ +# fly.toml app configuration file generated for fitbit-challenges-api on 2024-08-02T20:16:37-04:00 +# +# See https://fly.io/docs/reference/configuration/ for information about how to use this file. +# + +app = 'fitbit-challenges-api' +primary_region = 'ewr' + +[build] + image = 'shaldengeki/fitbit-challenges-api:latest' + +[deploy] + release_command = '/fitbit_challenges/api/migrations/binary /fitbit_challenges/api/migrations ./binary.runfiles/_main/fitbit_challenges/api/migrations/alembic.ini upgrade' + +[env] + API_PORT = '5000' + FLASK_APP = 'app.py' + FLASK_DEBUG = 'false' + FRONTEND_HOST = 'fitbit.ouguo.us' + FRONTEND_PORT = '' + FRONTEND_PROTOCOL = 'https' + +[http_service] + internal_port = 5000 + force_https = true + auto_stop_machines = 'stop' + auto_start_machines = true + min_machines_running = 0 + processes = ['app'] + +[[vm]] + memory = '512mb' + cpu_kind = 'shared' + cpus = 1 diff --git a/fitbit_challenges/frontend/.dockerignore b/fitbit_challenges/frontend/.dockerignore new file mode 100644 index 00000000..9a4de503 --- /dev/null +++ b/fitbit_challenges/frontend/.dockerignore @@ -0,0 +1,26 @@ +# flyctl launch added from .gitignore +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +node_modules +.pnp +**/.pnp.js + +# testing +coverage + +# production +build +**/App.css + +# misc +**/.DS_Store +**/.env.local +**/.env.development.local +**/.env.test.local +**/.env.production.local + +**/npm-debug.log* +**/yarn-debug.log* +**/yarn-error.log* +fly.toml diff --git a/fitbit_challenges/frontend/fly.toml b/fitbit_challenges/frontend/fly.toml new file mode 100644 index 00000000..ffb67058 --- /dev/null +++ b/fitbit_challenges/frontend/fly.toml @@ -0,0 +1,29 @@ +# fly.toml app configuration file generated for fitbit-challenges-frontend on 2024-08-02T20:27:45-04:00 +# +# See https://fly.io/docs/reference/configuration/ for information about how to use this file. +# + +app = 'fitbit-challenges-frontend' +primary_region = 'ewr' + +[build] + image = 'shaldengeki/fitbit-challenges-frontend:latest' + +[env] + REACT_APP_API_HOST = 'api.fitbit.ouguo.us' + REACT_APP_API_PORT = '443' + REACT_APP_API_PROTOCOL = 'https' + REACT_APP_PORT = '80' + +[http_service] + internal_port = 80 + force_https = true + auto_stop_machines = 'stop' + auto_start_machines = true + min_machines_running = 0 + processes = ['app'] + +[[vm]] + memory = '256mb' + cpu_kind = 'shared' + cpus = 1