Skip to content

Commit

Permalink
Add prod fly tomls
Browse files Browse the repository at this point in the history
  • Loading branch information
azlyth committed Feb 17, 2025
1 parent 7ce5806 commit 429d66e
Show file tree
Hide file tree
Showing 8 changed files with 190 additions and 10 deletions.
50 changes: 42 additions & 8 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,68 @@ 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

- 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
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
21 changes: 19 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
25 changes: 25 additions & 0 deletions db/fly.prod.toml
Original file line number Diff line number Diff line change
@@ -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"
27 changes: 27 additions & 0 deletions frontend/fly.prod.toml
Original file line number Diff line number Diff line change
@@ -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
27 changes: 27 additions & 0 deletions meilisearch/fly.prod.toml
Original file line number Diff line number Diff line change
@@ -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"
File renamed without changes.
24 changes: 24 additions & 0 deletions python-backend/fly.prod.toml
Original file line number Diff line number Diff line change
@@ -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
26 changes: 26 additions & 0 deletions search/fly.prod.toml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 429d66e

Please sign in to comment.