From 429d66edcbea979b6755b568e9d2caad482ce2e0 Mon Sep 17 00:00:00 2001 From: Peter Valdez Date: Sun, 16 Feb 2025 19:05:34 -0500 Subject: [PATCH] Add prod fly tomls --- .github/workflows/deploy.yml | 50 ++++++++++++++++---- Makefile | 21 +++++++- db/fly.prod.toml | 25 ++++++++++ frontend/fly.prod.toml | 27 +++++++++++ meilisearch/fly.prod.toml | 27 +++++++++++ {search/meilisearch => meilisearch}/fly.toml | 0 python-backend/fly.prod.toml | 24 ++++++++++ search/fly.prod.toml | 26 ++++++++++ 8 files changed, 190 insertions(+), 10 deletions(-) create mode 100644 db/fly.prod.toml create mode 100644 frontend/fly.prod.toml create mode 100644 meilisearch/fly.prod.toml rename {search/meilisearch => meilisearch}/fly.toml (100%) create mode 100644 python-backend/fly.prod.toml create mode 100644 search/fly.prod.toml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index dead894..e40caa2 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -3,12 +3,13 @@ name: Deploy to Fly.io on: push: branches: - - azlyth/fly - # - main + - main + - stable jobs: - deploy: - name: Deploy apps + deploy_staging: + name: Deploy apps to Staging + if: github.ref == 'refs/heads/main' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -16,21 +17,54 @@ jobs: - name: Setup Flyctl uses: superfly/flyctl-actions/setup-flyctl@master + # Deploy Database (Pocketbase) - name: Deploy Database working-directory: db env: FLY_API_TOKEN: ${{ secrets.FLY_TOKEN }} - run: flyctl deploy --remote-only + run: flyctl deploy --remote-only + # Deploy Backend - name: Deploy Backend working-directory: python-backend env: FLY_API_TOKEN: ${{ secrets.FLY_TOKEN }} - run: | - flyctl deploy --remote-only + run: flyctl deploy --remote-only + # Deploy Frontend - name: Deploy Frontend working-directory: frontend env: FLY_API_TOKEN: ${{ secrets.FLY_TOKEN }} - run: flyctl deploy --remote-only \ No newline at end of file + run: flyctl deploy --remote-only + + deploy_production: + name: Deploy apps to Production + if: github.ref == 'refs/heads/stable' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Setup Flyctl + uses: superfly/flyctl-actions/setup-flyctl@master + + # Deploy Database (Pocketbase) + - name: Deploy Database + working-directory: db + env: + FLY_API_TOKEN: ${{ secrets.FLY_TOKEN }} + run: flyctl deploy --config fly.prod.toml --remote-only + + # Deploy Backend + - name: Deploy Backend + working-directory: python-backend + env: + FLY_API_TOKEN: ${{ secrets.FLY_TOKEN }} + run: flyctl deploy --config fly.prod.toml --remote-only + + # Deploy Frontend + - name: Deploy Frontend + working-directory: frontend + env: + FLY_API_TOKEN: ${{ secrets.FLY_TOKEN }} + run: flyctl deploy --config fly.prod.toml --remote-only \ No newline at end of file diff --git a/Makefile b/Makefile index 1edad41..dbbf0a2 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,24 @@ deploy-pocketbase: cd db && fly deploy deploy-meilisearch: - cd search/meilisearch && fly deploy + cd meilisearch && fly deploy deploy-search: - cd search && fly deploy \ No newline at end of file + cd search && fly deploy + +deploy-frontend-prod: + cd frontend && fly deploy --config fly.prod.toml + +deploy-backend-prod: + cd python-backend && fly deploy --config fly.prod.toml + +deploy-pocketbase-prod: + cd db && fly deploy --config fly.prod.toml + +deploy-meilisearch-prod: + cd meilisearch && fly deploy --config fly.prod.toml + +deploy-search-prod: + cd search && fly deploy --config fly.prod.toml + +deploy-all-prod: deploy-frontend-prod deploy-backend-prod deploy-pocketbase-prod deploy-meilisearch-prod deploy-search-prod \ No newline at end of file diff --git a/db/fly.prod.toml b/db/fly.prod.toml new file mode 100644 index 0000000..4f30a6e --- /dev/null +++ b/db/fly.prod.toml @@ -0,0 +1,25 @@ +app = "localmart-pocketbase-prod" +primary_region = "ewr" # Change this to your preferred region + +[build] + dockerfile = "Dockerfile" + +[env] + PORT = "8090" + +[http_service] + internal_port = 8090 + force_https = true + auto_stop_machines = true + auto_start_machines = true + min_machines_running = 1 + processes = ["app"] + +[[vm]] + cpu_kind = "shared" + cpus = 1 + memory_mb = 1024 + +[mounts] + source = "pb_data" + destination = "/pb_data" \ No newline at end of file diff --git a/frontend/fly.prod.toml b/frontend/fly.prod.toml new file mode 100644 index 0000000..0516762 --- /dev/null +++ b/frontend/fly.prod.toml @@ -0,0 +1,27 @@ +app = "localmart-frontend-prod" +primary_region = "ewr" # Change this to your preferred region + +[build] + dockerfile = "Dockerfile" + +[env] + NODE_ENV = "production" + PORT = "3000" + NEXT_PUBLIC_API_URL = "https://localmart-backend-prod.fly.dev" + NEXT_PUBLIC_POCKETBASE_URL = "https://localmart-pocketbase-prod.fly.dev" + NEXT_PUBLIC_SEARCH_URL = "https://localmart-search-prod.fly.dev" + NEXT_PUBLIC_MEILI_URL = "https://localmart-meilisearch-prod.fly.dev" + +[http_service] + internal_port = 3000 + force_https = true + auto_stop_machines = true + auto_start_machines = true + min_machines_running = 1 + max_machines_count = 1 + processes = ["app"] + +[[vm]] + cpu_kind = "shared" + cpus = 1 + memory_mb = 1024 \ No newline at end of file diff --git a/meilisearch/fly.prod.toml b/meilisearch/fly.prod.toml new file mode 100644 index 0000000..0bdb199 --- /dev/null +++ b/meilisearch/fly.prod.toml @@ -0,0 +1,27 @@ +app = "localmart-meilisearch-prod" +primary_region = "ewr" + +[build] + image = "getmeili/meilisearch:latest" + +[env] + MEILI_ENV = "production" + MEILI_NO_ANALYTICS = "true" + +[http_service] + internal_port = 7700 + force_https = true + auto_stop_machines = true + auto_start_machines = true + min_machines_running = 1 + max_machines_count = 1 + processes = ["app"] + +[[vm]] + cpu_kind = "shared" + cpus = 1 + memory_mb = 1024 + +[mounts] + source = "meili_data" + destination = "/data.ms" \ No newline at end of file diff --git a/search/meilisearch/fly.toml b/meilisearch/fly.toml similarity index 100% rename from search/meilisearch/fly.toml rename to meilisearch/fly.toml diff --git a/python-backend/fly.prod.toml b/python-backend/fly.prod.toml new file mode 100644 index 0000000..88a1376 --- /dev/null +++ b/python-backend/fly.prod.toml @@ -0,0 +1,24 @@ +app = "localmart-backend-prod" +primary_region = "ewr" + +[build] + dockerfile = "Dockerfile" + +[env] + PORT = "8000" + PYTHONPATH = "/app" + POCKETBASE_URL = "https://localmart-pocketbase-prod.fly.dev" + +[http_service] + internal_port = 8000 + force_https = true + auto_stop_machines = true + auto_start_machines = true + min_machines_running = 1 + max_machines_count = 1 + processes = ["app"] + +[[vm]] + cpu_kind = "shared" + cpus = 1 + memory_mb = 1024 \ No newline at end of file diff --git a/search/fly.prod.toml b/search/fly.prod.toml new file mode 100644 index 0000000..1579294 --- /dev/null +++ b/search/fly.prod.toml @@ -0,0 +1,26 @@ +app = "localmart-search-prod" +primary_region = "ewr" + +[build] + dockerfile = "Dockerfile" + +[env] + PORT = "4100" + PHX_HOST = "localmart-search-prod.fly.dev" + MIX_ENV = "prod" + MEILI_HOST = "https://localmart-meilisearch-prod.fly.dev" + MEILI_ENDPOINT = "https://localmart-meilisearch-prod.fly.dev" + +[http_service] + internal_port = 4100 + force_https = true + auto_stop_machines = true + auto_start_machines = true + min_machines_running = 1 + max_machines_count = 1 + processes = ["app"] + +[[vm]] + cpu_kind = "shared" + cpus = 1 + memory_mb = 1024 \ No newline at end of file