Skip to content

Commit 979a986

Browse files
authored
Actual Merge Portal Prod (anomalyco#149)
1 parent ca6818d commit 979a986

File tree

358 files changed

+6940
-28902
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

358 files changed

+6940
-28902
lines changed

.devcontainer/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
FROM mcr.microsoft.com/devcontainers/typescript-node:1-22-bookworm
22

3+
RUN git clone https://github.com/git/git.git /tmp/git && \
4+
cd /tmp/git/contrib/subtree && \
5+
make && \
6+
make install prefix=/usr/local && \
7+
rm -rf /tmp/git
8+
9+
RUN curl -fsSL https://bun.sh/install | bash
10+
311
# Install Hasura CLI
412
RUN curl -L https://github.com/hasura/graphql-engine/raw/stable/cli/get.sh | bash

.devcontainer/devcontainer.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@
1717
"bpruitt-goddard.mermaid-markdown-syntax-highlighting",
1818
"GitHub.copilot",
1919
"github.vscode-github-actions",
20-
"styled-components.vscode-styled-components"
20+
"styled-components.vscode-styled-components",
21+
"mtxr.sqltools",
22+
"mtxr.sqltools-driver-pg",
23+
"oven.bun-vscode",
24+
"WallabyJs.console-ninja",
25+
"ms-azuretools.vscode-docker"
2126
]
2227
}
2328
}

.env.dev

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
POSTGRES_PASSWORD=password
2+
JWKS_ENDPOINT=http://auth:3001/.well-known/jwks.json
3+
STRIPE_SECRET_KEY=rk_test_51QJ1i6GzPK2DOcG5XJxzf6GmkKbCESzOfThaVkGxMzVMS7p6UQOycxMuNQG7lPbEJkAvxGwEEvfcsLObiGpNyIX200fxhtNlJG
4+
NEXT_PUBLIC_STRIPE_PRICING_TABLE_ID=prctbl_1QJhTcGzPK2DOcG53lZoMKCm
5+
HASURA_GRAPHQL_ADMIN_SECRET=password
6+
GITHUB_CLIENT_ID=Ov23liYz3ENoXL1dBaf1
7+
GITHUB_CLIENT_SECRET=114f46ccc688e05d0e9b12e9ec7f0c52de4afac0
8+
SEGMENT_WRITE_KEY=t7ho50oiP4r0PF4QQkq2NaHKDiGrZu6x

.env.sample

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
POSTGRES_PASSWORD=password
2+
JWKS_ENDPOINT=http://host.docker.internal:3001/.well-known/jwks.json
3+
STRIPE_SECRET_KEY=rk_test_51QJ1i6GzPK2DOcG5XJxzf6GmkKbCESzOfThaVkGxMzVMS7p6UQOycxMuNQG7lPbEJkAvxGwEEvfcsLObiGpNyIX200fxhtNlJG
4+
HASURA_GRAPHQL_ADMIN_SECRET=password
5+
GITHUB_CLIENT_ID=sample-id
6+
GITHUB_CLIENT_SECRET=sample-secret
7+
SEGMENT_WRITE_KEY=sample-key
8+
# Frontend - Sample of stuff that needs to be set with `defang config set`
9+
NEXT_PUBLIC_AUTH_URL=http://localhost:3001
10+
NEXT_PUBLIC_GRAPHQL_URL=http://localhost:3002/v1/graphql
11+
NEXT_PUBLIC_FN_URL=http://localhost:3003
12+
NEXT_PUBLIC_FABRIC=https://fabric-prod1.defang.dev:443

.github/actions/deploy/action.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: Deploy to AWS
2+
description: Deploy application to AWS environment
3+
4+
inputs:
5+
aws_account_id:
6+
description: 'AWS Account ID'
7+
required: true
8+
aws_region:
9+
description: 'AWS Region'
10+
required: false
11+
default: 'us-west-2'
12+
project_name:
13+
description: 'Project name'
14+
required: true
15+
domain_name:
16+
description: 'Domain Name'
17+
required: true
18+
github_client_id:
19+
description: 'GitHub Client ID'
20+
required: true
21+
github_client_secret:
22+
description: 'GitHub Client Secret'
23+
required: true
24+
hasura_graphql_admin_secret:
25+
description: 'Hasura GraphQL Admin Secret'
26+
required: true
27+
next_public_segment_write_key:
28+
description: 'Next Public Segment Write Key'
29+
required: true
30+
next_public_stripe_pricing_table_id:
31+
description: 'Next Public Stripe Pricing Table ID'
32+
required: true
33+
next_public_stripe_publishable_key:
34+
description: 'Next Public Stripe Publishable Key'
35+
required: true
36+
next_public_version:
37+
description: 'Next Public Version'
38+
required: true
39+
postgres_password:
40+
description: 'Postgres Password'
41+
required: true
42+
segment_write_key:
43+
description: 'Segment Write Key'
44+
required: true
45+
stripe_secret_key:
46+
description: 'Stripe Secret Key'
47+
required: true
48+
next_public_fabric:
49+
description: 'Next Public Fabric'
50+
required: false
51+
default: ''
52+
compose_file:
53+
description: 'Compose file'
54+
required: true
55+
mode:
56+
description: 'Deployment mode (development | staging | production)'
57+
default: development
58+
required: true
59+
60+
runs:
61+
using: "composite"
62+
steps:
63+
- name: Configure AWS Credentials for CI
64+
uses: aws-actions/configure-aws-credentials@v4
65+
with:
66+
aws-region: us-west-2
67+
role-to-assume: arn:aws:iam::488659951590:role/ci-role-d4fe904 # ciRoleArn from defang-io/infrastructure stack
68+
- name: Configure AWS Credentials for Corp Website Account
69+
uses: aws-actions/configure-aws-credentials@v4
70+
with:
71+
aws-region: ${{ inputs.aws_region }}
72+
role-chaining: true
73+
role-duration-seconds: 1200
74+
role-to-assume: arn:aws:iam::${{ inputs.aws_account_id }}:role/admin
75+
- name: Create dotenv file
76+
shell: bash
77+
run: |
78+
echo "DOMAIN_NAME=${{ inputs.domain_name }}" >> .env
79+
echo "NEXT_PUBLIC_FABRIC=${{ inputs.next_public_fabric }}" >> .env
80+
echo "NEXT_PUBLIC_SEGMENT_WRITE_KEY=${{ inputs.next_public_segment_write_key }}" >> .env
81+
echo "NEXT_PUBLIC_VERSION=${{ inputs.next_public_version }}" >> .env
82+
echo "NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=${{ inputs.next_public_stripe_publishable_key }}" >> .env
83+
echo "NEXT_PUBLIC_STRIPE_PRICING_TABLE_ID=${{ inputs.next_public_stripe_pricing_table_id }}" >> .env
84+
- name: Deploy
85+
uses: DefangLabs/defang-github-action@v1.2.0
86+
with:
87+
mode: ${{ inputs.mode }}
88+
compose-files: ${{ inputs.compose_file }}
89+
config-env-vars: DOMAIN_NAME GITHUB_CLIENT_ID GITHUB_CLIENT_SECRET HASURA_GRAPHQL_ADMIN_SECRET NEXT_PUBLIC_SEGMENT_WRITE_KEY NEXT_PUBLIC_STRIPE_PRICING_TABLE_ID NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY NEXT_PUBLIC_VERSION POSTGRES_PASSWORD SEGMENT_WRITE_KEY STRIPE_SECRET_KEY
90+
env:
91+
DEFANG_PROVIDER: aws
92+
DOMAIN_NAME: ${{ inputs.domain_name }}
93+
GITHUB_CLIENT_ID: ${{ inputs.github_client_id }}
94+
GITHUB_CLIENT_SECRET: ${{ inputs.github_client_secret }}
95+
HASURA_GRAPHQL_ADMIN_SECRET: ${{ inputs.hasura_graphql_admin_secret }}
96+
NEXT_PUBLIC_SEGMENT_WRITE_KEY: ${{ inputs.next_public_segment_write_key }}
97+
NEXT_PUBLIC_STRIPE_PRICING_TABLE_ID: ${{ inputs.next_public_stripe_pricing_table_id }}
98+
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY: ${{ inputs.next_public_stripe_publishable_key }}
99+
NEXT_PUBLIC_VERSION: ${{ inputs.next_public_version }}
100+
POSTGRES_PASSWORD: ${{ inputs.postgres_password }}
101+
SEGMENT_WRITE_KEY: ${{ inputs.segment_write_key }}
102+
STRIPE_SECRET_KEY: ${{ inputs.stripe_secret_key }}
103+
NEXT_PUBLIC_FABRIC: ${{ inputs.next_public_fabric }}

.github/workflows/deploy.yml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: Deploy
2+
on:
3+
push:
4+
branches:
5+
- main
6+
- staging
7+
tags:
8+
- v*
9+
pull_request:
10+
branches: [main, intermediate-auth]
11+
12+
permissions:
13+
contents: read
14+
id-token: write
15+
16+
jobs:
17+
deploy-dev:
18+
if: github.event_name == 'pull_request'
19+
environment: dev
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout the repository
23+
uses: actions/checkout@v4
24+
25+
# create a short sha and make it available to the next steps
26+
- name: Set short sha
27+
id: vars
28+
run: echo "SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_ENV
29+
30+
- uses: ./.github/actions/deploy
31+
with:
32+
mode: development
33+
compose_file: compose.portal.dev.gnafed.click.yaml
34+
aws_account_id: 532501343364
35+
aws_region: us-west-2
36+
domain_name: ${{ vars.DOMAIN_NAME }}
37+
github_client_id: ${{ secrets.AUTH_GITHUB_CLIENT_ID }}
38+
github_client_secret: ${{ secrets.AUTH_GITHUB_CLIENT_SECRET }}
39+
hasura_graphql_admin_secret: ${{ secrets.HASURA_GRAPHQL_ADMIN_SECRET }}
40+
next_public_segment_write_key: ${{ secrets.NEXT_PUBLIC_SEGMENT_WRITE_KEY }}
41+
next_public_stripe_pricing_table_id: ${{ secrets.NEXT_PUBLIC_STRIPE_PRICING_TABLE_ID }}
42+
next_public_stripe_publishable_key: ${{ secrets.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY }}
43+
next_public_version: ${{ env.SHORT_SHA }}
44+
postgres_password: ${{ secrets.POSTGRES_PASSWORD }}
45+
segment_write_key: ${{ secrets.SEGMENT_WRITE_KEY }}
46+
stripe_secret_key: ${{ secrets.STRIPE_SECRET_KEY }}
47+
next_public_fabric: ${{ vars.NEXT_PUBLIC_FABRIC }}
48+
49+
deploy-staging:
50+
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging')
51+
environment: staging
52+
runs-on: ubuntu-latest
53+
steps:
54+
- name: Checkout the repository
55+
uses: actions/checkout@v4
56+
57+
# create a short sha and make it available to the next steps
58+
- name: Set short sha
59+
id: vars
60+
run: echo "SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_ENV
61+
62+
- uses: ./.github/actions/deploy
63+
with:
64+
mode: staging
65+
compose_file: compose.portal.staging.defang.dev.yaml
66+
aws_account_id: 426819183542
67+
aws_region: us-west-2
68+
domain_name: ${{ vars.DOMAIN_NAME }}
69+
github_client_id: ${{ secrets.AUTH_GITHUB_CLIENT_ID }}
70+
github_client_secret: ${{ secrets.AUTH_GITHUB_CLIENT_SECRET }}
71+
hasura_graphql_admin_secret: ${{ secrets.HASURA_GRAPHQL_ADMIN_SECRET }}
72+
next_public_segment_write_key: ${{ secrets.NEXT_PUBLIC_SEGMENT_WRITE_KEY }}
73+
next_public_stripe_pricing_table_id: ${{ secrets.NEXT_PUBLIC_STRIPE_PRICING_TABLE_ID }}
74+
next_public_stripe_publishable_key: ${{ secrets.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY }}
75+
next_public_version: ${{ env.SHORT_SHA }}
76+
postgres_password: ${{ secrets.POSTGRES_PASSWORD }}
77+
segment_write_key: ${{ secrets.SEGMENT_WRITE_KEY }}
78+
stripe_secret_key: ${{ secrets.STRIPE_SECRET_KEY }}
79+
next_public_fabric: ${{ vars.NEXT_PUBLIC_FABRIC }}
80+
81+
82+
deploy-production:
83+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
84+
environment: production
85+
runs-on: ubuntu-latest
86+
steps:
87+
- name: Checkout the repository
88+
uses: actions/checkout@v4
89+
90+
# create a short sha and make it available to the next steps
91+
- name: Set short sha
92+
id: vars
93+
run: echo "SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_ENV
94+
95+
- uses: ./.github/actions/deploy
96+
with:
97+
mode: production
98+
compose_file: compose.portal.defang.io.yaml
99+
# TODO: Update the AWS account ID to the corp account when ready
100+
aws_account_id: 407839483216
101+
aws_region: us-west-2
102+
domain_name: ${{ vars.DOMAIN_NAME }}
103+
github_client_id: ${{ secrets.AUTH_GITHUB_CLIENT_ID }}
104+
github_client_secret: ${{ secrets.AUTH_GITHUB_CLIENT_SECRET }}
105+
hasura_graphql_admin_secret: ${{ secrets.HASURA_GRAPHQL_ADMIN_SECRET }}
106+
next_public_segment_write_key: ${{ secrets.NEXT_PUBLIC_SEGMENT_WRITE_KEY }}
107+
next_public_stripe_pricing_table_id: ${{ secrets.NEXT_PUBLIC_STRIPE_PRICING_TABLE_ID }}
108+
next_public_stripe_publishable_key: ${{ secrets.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY }}
109+
next_public_version: ${{ env.SHORT_SHA }}
110+
postgres_password: ${{ secrets.POSTGRES_PASSWORD }}
111+
segment_write_key: ${{ secrets.SEGMENT_WRITE_KEY }}
112+
stripe_secret_key: ${{ secrets.STRIPE_SECRET_KEY }}
113+
next_public_fabric: ${{ vars.NEXT_PUBLIC_FABRIC }}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: PR Compose Build
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- '**'
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v2
15+
16+
- name: Set up Docker Buildx
17+
uses: docker/setup-buildx-action@v1
18+
19+
- name: Build Docker Compose
20+
run: docker compose --profile=defang build

.github/workflows/pulumi-preview.yml

Lines changed: 0 additions & 40 deletions
This file was deleted.

.github/workflows/pulumi-up.yml

Lines changed: 0 additions & 47 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ node_modules
33
.data
44
.DS_Store
55
.direnv
6+
.env

0 commit comments

Comments
 (0)