From f902220e2897c334e4baec71872e0e0caac885d4 Mon Sep 17 00:00:00 2001 From: Naren Rohan Date: Mon, 21 Oct 2024 00:23:24 +1300 Subject: [PATCH 1/3] feat: added deployment script for production --- .github/workflows/deploy.production.yml | 29 +++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/deploy.production.yml diff --git a/.github/workflows/deploy.production.yml b/.github/workflows/deploy.production.yml new file mode 100644 index 00000000..ba801813 --- /dev/null +++ b/.github/workflows/deploy.production.yml @@ -0,0 +1,29 @@ +name: Fly Deploy Production + +on: + push: + branches: + - master + +jobs: + deploy-web: + name: Deploy Web + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: superfly/flyctl-actions/setup-flyctl@master + - run: flyctl deploy --remote-only --config fly.production.toml --build-arg VITE_FIREBASE_PROJECT_ID=${{ secrets.VITE_FIREBASE_PROJECT_ID }} --build-arg VITE_REACT_APP_API_KEY=${{ secrets.VITE_REACT_APP_API_KEY }} --build-arg VITE_REACT_APP_AUTH_DOMAIN=${{ secrets.VITE_REACT_APP_AUTH_DOMAIN }} --build-arg VITE_REACT_APP_STORAGE_BUCKET=${{ secrets.VITE_REACT_APP_STORAGE_BUCKET }} --build-arg VITE_REACT_APP_MESSAGING_SENDER_ID=${{ secrets.VITE_REACT_APP_MESSAGING_SENDER_ID }} --build-arg VITE_REACT_APP_APP_ID=${{ secrets.VITE_REACT_APP_APP_ID }} --build-arg VITE_REACT_APP_MEASUREMENT_ID=${{ secrets.VITE_REACT_APP_MEASUREMENT_ID }} + working-directory: ./frontend + env: + FLY_API_TOKEN: ${{ secrets.FLY_PRODUCTION_API_TOKEN }} + + deploy-api: + name: Deploy Api + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: superfly/flyctl-actions/setup-flyctl@master + - run: flyctl deploy --remote-only --config fly.production.toml + working-directory: ./backend + env: + FLY_API_TOKEN: ${{ secrets.FLY_API_PRODUCTION_API_TOKEN }} From 95816bbfd07011a75ffd3da78e74a2bf91c06b84 Mon Sep 17 00:00:00 2001 From: Naren Rohan Date: Mon, 21 Oct 2024 00:24:36 +1300 Subject: [PATCH 2/3] feat: added fly.production.toml --- backend/fly.production.toml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 backend/fly.production.toml diff --git a/backend/fly.production.toml b/backend/fly.production.toml new file mode 100644 index 00000000..34c6745d --- /dev/null +++ b/backend/fly.production.toml @@ -0,0 +1,18 @@ +app = 'wdcc-vps-api' +primary_region = 'syd' + +[build] + dockerfile = "Dockerfile" + +[http_service] + internal_port = 5000 + force_https = true + auto_stop_machines = true + auto_start_machines = true + min_machines_running = 0 + processes = ['app'] + +[[vm]] + cpu_kind = 'shared' + cpus = 1 + memory_mb = 1024 \ No newline at end of file From fd285a46e645f02234d917f8f73cbb160052dfa6 Mon Sep 17 00:00:00 2001 From: Naren Rohan Date: Mon, 21 Oct 2024 00:32:18 +1300 Subject: [PATCH 3/3] feat: added production config for FE --- .github/workflows/deploy.production.yml | 7 ++----- .github/workflows/deploy.staging.yml | 2 +- frontend/{Dockerfile.staging => Dockerfile} | 5 ++--- frontend/fly.production.toml | 19 +++++++++++++++++++ frontend/fly.staging.toml | 2 +- 5 files changed, 25 insertions(+), 10 deletions(-) rename frontend/{Dockerfile.staging => Dockerfile} (95%) create mode 100644 frontend/fly.production.toml diff --git a/.github/workflows/deploy.production.yml b/.github/workflows/deploy.production.yml index ba801813..ce04c342 100644 --- a/.github/workflows/deploy.production.yml +++ b/.github/workflows/deploy.production.yml @@ -1,9 +1,6 @@ name: Fly Deploy Production -on: - push: - branches: - - master +on: [workflow_dispatch] jobs: deploy-web: @@ -12,7 +9,7 @@ jobs: steps: - uses: actions/checkout@v3 - uses: superfly/flyctl-actions/setup-flyctl@master - - run: flyctl deploy --remote-only --config fly.production.toml --build-arg VITE_FIREBASE_PROJECT_ID=${{ secrets.VITE_FIREBASE_PROJECT_ID }} --build-arg VITE_REACT_APP_API_KEY=${{ secrets.VITE_REACT_APP_API_KEY }} --build-arg VITE_REACT_APP_AUTH_DOMAIN=${{ secrets.VITE_REACT_APP_AUTH_DOMAIN }} --build-arg VITE_REACT_APP_STORAGE_BUCKET=${{ secrets.VITE_REACT_APP_STORAGE_BUCKET }} --build-arg VITE_REACT_APP_MESSAGING_SENDER_ID=${{ secrets.VITE_REACT_APP_MESSAGING_SENDER_ID }} --build-arg VITE_REACT_APP_APP_ID=${{ secrets.VITE_REACT_APP_APP_ID }} --build-arg VITE_REACT_APP_MEASUREMENT_ID=${{ secrets.VITE_REACT_APP_MEASUREMENT_ID }} + - run: flyctl deploy --remote-only --config fly.production.toml --build-arg VITE_FIREBASE_PROJECT_ID=${{ secrets.VITE_FIREBASE_PROJECT_ID }} --build-arg VITE_REACT_APP_API_KEY=${{ secrets.VITE_REACT_APP_API_KEY }} --build-arg VITE_REACT_APP_AUTH_DOMAIN=${{ secrets.VITE_REACT_APP_AUTH_DOMAIN }} --build-arg VITE_REACT_APP_STORAGE_BUCKET=${{ secrets.VITE_REACT_APP_STORAGE_BUCKET }} --build-arg VITE_REACT_APP_MESSAGING_SENDER_ID=${{ secrets.VITE_REACT_APP_MESSAGING_SENDER_ID }} --build-arg VITE_REACT_APP_APP_ID=${{ secrets.VITE_REACT_APP_APP_ID }} --build-arg VITE_REACT_APP_MEASUREMENT_ID=${{ secrets.VITE_REACT_APP_MEASUREMENT_ID }} --build-arg VITE_REACT_APP_SERVER_URL=${{ secrets.VITE_REACT_APP_SERVER_URL_PRODUCTION }} working-directory: ./frontend env: FLY_API_TOKEN: ${{ secrets.FLY_PRODUCTION_API_TOKEN }} diff --git a/.github/workflows/deploy.staging.yml b/.github/workflows/deploy.staging.yml index c340f30a..6ea3ac57 100644 --- a/.github/workflows/deploy.staging.yml +++ b/.github/workflows/deploy.staging.yml @@ -12,7 +12,7 @@ jobs: steps: - uses: actions/checkout@v3 - uses: superfly/flyctl-actions/setup-flyctl@master - - run: flyctl deploy --remote-only --config fly.staging.toml --build-arg VITE_FIREBASE_PROJECT_ID=${{ secrets.VITE_FIREBASE_PROJECT_ID }} --build-arg VITE_REACT_APP_API_KEY=${{ secrets.VITE_REACT_APP_API_KEY }} --build-arg VITE_REACT_APP_AUTH_DOMAIN=${{ secrets.VITE_REACT_APP_AUTH_DOMAIN }} --build-arg VITE_REACT_APP_STORAGE_BUCKET=${{ secrets.VITE_REACT_APP_STORAGE_BUCKET }} --build-arg VITE_REACT_APP_MESSAGING_SENDER_ID=${{ secrets.VITE_REACT_APP_MESSAGING_SENDER_ID }} --build-arg VITE_REACT_APP_APP_ID=${{ secrets.VITE_REACT_APP_APP_ID }} --build-arg VITE_REACT_APP_MEASUREMENT_ID=${{ secrets.VITE_REACT_APP_MEASUREMENT_ID }} + - run: flyctl deploy --remote-only --config fly.staging.toml --build-arg VITE_FIREBASE_PROJECT_ID=${{ secrets.VITE_FIREBASE_PROJECT_ID }} --build-arg VITE_REACT_APP_API_KEY=${{ secrets.VITE_REACT_APP_API_KEY }} --build-arg VITE_REACT_APP_AUTH_DOMAIN=${{ secrets.VITE_REACT_APP_AUTH_DOMAIN }} --build-arg VITE_REACT_APP_STORAGE_BUCKET=${{ secrets.VITE_REACT_APP_STORAGE_BUCKET }} --build-arg VITE_REACT_APP_MESSAGING_SENDER_ID=${{ secrets.VITE_REACT_APP_MESSAGING_SENDER_ID }} --build-arg VITE_REACT_APP_APP_ID=${{ secrets.VITE_REACT_APP_APP_ID }} --build-arg VITE_REACT_APP_MEASUREMENT_ID=${{ secrets.VITE_REACT_APP_MEASUREMENT_ID }} --build-arg VITE_REACT_APP_SERVER_URL=${{ secrets.VITE_REACT_APP_SERVER_URL_STAGING }} working-directory: ./frontend env: FLY_API_TOKEN: ${{ secrets.FLY_STAGING_API_TOKEN }} diff --git a/frontend/Dockerfile.staging b/frontend/Dockerfile similarity index 95% rename from frontend/Dockerfile.staging rename to frontend/Dockerfile index 898961ab..30724961 100644 --- a/frontend/Dockerfile.staging +++ b/frontend/Dockerfile @@ -34,6 +34,7 @@ ARG VITE_REACT_APP_STORAGE_BUCKET ARG VITE_REACT_APP_MESSAGING_SENDER_ID ARG VITE_REACT_APP_APP_ID ARG VITE_REACT_APP_MEASUREMENT_ID +ARG VITE_REACT_APP_SERVER_URL ENV VITE_FIREBASE_PROJECT_ID=${VITE_FIREBASE_PROJECT_ID} ENV VITE_REACT_APP_API_KEY=${VITE_REACT_APP_API_KEY} @@ -42,9 +43,7 @@ ENV VITE_REACT_APP_STORAGE_BUCKET=${VITE_REACT_APP_STORAGE_BUCKET} ENV VITE_REACT_APP_MESSAGING_SENDER_ID=${VITE_REACT_APP_MESSAGING_SENDER_ID} ENV VITE_REACT_APP_APP_ID=${VITE_REACT_APP_APP_ID} ENV VITE_REACT_APP_MEASUREMENT_ID=${VITE_REACT_APP_MEASUREMENT_ID} - -# Set server URL -ENV VITE_REACT_APP_SERVER_URL="https://wdcc-vps-api-staging.fly.dev" +ENV VITE_REACT_APP_SERVER_URL=${VITE_REACT_APP_SERVER_URL} # Build the app with environment variables RUN yarn run build diff --git a/frontend/fly.production.toml b/frontend/fly.production.toml new file mode 100644 index 00000000..b8ec7a7d --- /dev/null +++ b/frontend/fly.production.toml @@ -0,0 +1,19 @@ +app = 'wdcc-vps' +primary_region = 'syd' + +[build] + # dockerfile contains build time non-sensitive env vars + dockerfile = "Dockerfile" + +[http_service] + internal_port = 80 + force_https = true + auto_stop_machines = true + auto_start_machines = true + min_machines_running = 0 + processes = ['app'] + +[[vm]] + cpu_kind = 'shared' + cpus = 1 + memory_mb = 1024 \ No newline at end of file diff --git a/frontend/fly.staging.toml b/frontend/fly.staging.toml index 4ea2692a..60145f22 100644 --- a/frontend/fly.staging.toml +++ b/frontend/fly.staging.toml @@ -3,7 +3,7 @@ primary_region = 'syd' [build] # dockerfile contains build time non-sensitive env vars - dockerfile = "Dockerfile.staging" + dockerfile = "Dockerfile" [http_service] internal_port = 80