From 6a1b81a81e938dd0bb4d751e8e86fc22098ee959 Mon Sep 17 00:00:00 2001 From: kms0219kms Date: Mon, 30 Sep 2024 22:15:14 +0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80=20chore:=20Ready=20for=20beta=20op?= =?UTF-8?q?en?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/be-grpc-deploy.yml | 44 + .github/workflows/fe-preview.yml | 21 + .github/workflows/fe-production.yml | 21 + .gitignore | 6 +- apps/backend/envoy-dev.yaml | 81 + apps/backend/envoy.yaml | 8 +- apps/backend/package.json | 19 +- apps/backend/src/index.ts | 4 +- apps/frontend/app/root.tsx | 30 + apps/frontend/package.json | 1 + ...naver08bc76fd83b96df1f5e0dcffa7bd8ed6.html | 1 + apps/frontend/public/robots.txt | 2 + apps/frontend/public/sitemap.xml | 17 + apps/frontend/public/sitemap.xsl | 99 ++ docker-compose.yml | 18 + grpc.Dockerfile | 13 + package.json | 3 +- pnpm-lock.yaml | 1534 +++++++++++++++-- 18 files changed, 1712 insertions(+), 210 deletions(-) create mode 100644 .github/workflows/be-grpc-deploy.yml create mode 100644 .github/workflows/fe-preview.yml create mode 100644 .github/workflows/fe-production.yml create mode 100644 apps/backend/envoy-dev.yaml create mode 100644 apps/frontend/public/naver08bc76fd83b96df1f5e0dcffa7bd8ed6.html create mode 100644 apps/frontend/public/robots.txt create mode 100644 apps/frontend/public/sitemap.xml create mode 100644 apps/frontend/public/sitemap.xsl create mode 100644 docker-compose.yml create mode 100644 grpc.Dockerfile diff --git a/.github/workflows/be-grpc-deploy.yml b/.github/workflows/be-grpc-deploy.yml new file mode 100644 index 0000000..6dce1e6 --- /dev/null +++ b/.github/workflows/be-grpc-deploy.yml @@ -0,0 +1,44 @@ +name: Deploy gRPC Backend to GitHub Container Registry + +on: + push: + branches: + - main + workflow_dispatch: + workflow_call: + +env: + IMAGE_NAME: am-to-mxm_grpc + +jobs: + push: + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + steps: + - uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - id: dockertag + name: Get Docker tag + uses: ASzc/change-string-case-action@v6 + with: + string: ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:latest + + - name: Log in to registry + run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin + + - name: Build and push + uses: docker/build-push-action@v6 + with: + file: ./grpc.Dockerfile + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.dockertag.outputs.lowercase }} diff --git a/.github/workflows/fe-preview.yml b/.github/workflows/fe-preview.yml new file mode 100644 index 0000000..07c786c --- /dev/null +++ b/.github/workflows/fe-preview.yml @@ -0,0 +1,21 @@ +name: Vercel Preview Deployment +env: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + +on: + push: + branches-ignore: + - main + +jobs: + Deploy-Preview: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install Vercel CLI + run: npm install --global vercel@latest + - name: Pull Vercel Environment Information + run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} + - name: Deploy Project Artifacts to Vercel + run: vercel deploy --token=${{ secrets.VERCEL_TOKEN }} diff --git a/.github/workflows/fe-production.yml b/.github/workflows/fe-production.yml new file mode 100644 index 0000000..0546a47 --- /dev/null +++ b/.github/workflows/fe-production.yml @@ -0,0 +1,21 @@ +name: Vercel Production Deployment +env: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + +on: + push: + branches: + - main + +jobs: + Deploy-Production: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install Vercel CLI + run: npm install --global vercel@latest + - name: Pull Vercel Environment Information + run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }} + - name: Deploy Project Artifacts to Vercel + run: vercel deploy --prod --token=${{ secrets.VERCEL_TOKEN }} diff --git a/.gitignore b/.gitignore index 046cd42..9a23b06 100644 --- a/.gitignore +++ b/.gitignore @@ -76,8 +76,11 @@ web_modules/ # dotenv environment variable files .env +.env.development .env.development.local +.env.test .env.test.local +.env.production .env.production.local .env.local @@ -125,4 +128,5 @@ dist .vscode-test # Cache -cache.sqlite \ No newline at end of file +cache.sqlite +.vercel diff --git a/apps/backend/envoy-dev.yaml b/apps/backend/envoy-dev.yaml new file mode 100644 index 0000000..a420b0e --- /dev/null +++ b/apps/backend/envoy-dev.yaml @@ -0,0 +1,81 @@ +admin: + address: + socket_address: + address: 0.0.0.0 + port_value: 52347 + +static_resources: + listeners: + - name: listener_0 + address: + socket_address: + address: 0.0.0.0 + port_value: 52346 + + filter_chains: + - filters: + - name: envoy.http_connection_manager + typed_config: + '@type': >- + type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager + + codec_type: auto + stat_prefix: ingress_http + route_config: + name: local_route + virtual_hosts: + - name: local_service + domains: + - '*' + routes: + - match: + prefix: / + route: + cluster: grpc + cors: + allow_origin_string_match: + - prefix: "*" + allow_methods: GET, PUT, DELETE, POST, OPTIONS + allow_headers: keep-alive,user-agent,cache-control,content-type,content-transfer-encoding,x-accept-content-transfer-encoding,x-accept-response-streaming,x-user-agent,x-grpc-web,grpc-timeout,authorization + max_age: "1728000" + expose_headers: grpc-status,grpc-message + + http_filters: + - name: envoy.grpc_web + typed_config: + '@type': >- + type.googleapis.com/envoy.extensions.filters.http.grpc_web.v3.GrpcWeb + + - name: envoy.filters.http.cors + typed_config: + '@type': >- + type.googleapis.com/envoy.extensions.filters.http.cors.v3.Cors + + - name: envoy.filters.http.router + typed_config: + '@type': >- + type.googleapis.com/envoy.extensions.filters.http.router.v3.Router + + clusters: + - name: grpc + connect_timeout: 0.25s + type: LOGICAL_DNS + lb_policy: ROUND_ROBIN + + typed_extension_protocol_options: + envoy.extensions.upstreams.http.v3.HttpProtocolOptions: + '@type': >- + type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions + + explicit_http_config: + http2_protocol_options: {} + + load_assignment: + cluster_name: grpc + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: 172.29.64.1 + port_value: 52345 diff --git a/apps/backend/envoy.yaml b/apps/backend/envoy.yaml index a420b0e..2dac081 100644 --- a/apps/backend/envoy.yaml +++ b/apps/backend/envoy.yaml @@ -1,9 +1,3 @@ -admin: - address: - socket_address: - address: 0.0.0.0 - port_value: 52347 - static_resources: listeners: - name: listener_0 @@ -77,5 +71,5 @@ static_resources: - endpoint: address: socket_address: - address: 172.29.64.1 + address: am-to-mxm-grpc-1 port_value: 52345 diff --git a/apps/backend/package.json b/apps/backend/package.json index 5bab5d7..42c6a58 100644 --- a/apps/backend/package.json +++ b/apps/backend/package.json @@ -7,10 +7,9 @@ "dist/src" ], "scripts": { - "start": "node dist/src/index.js", + "start": "tsx src/index.ts", "dev": "tsx watch src/index", - "build": "tsup src/index.ts", - "lint": "eslint --ignore-path ../../.gitignore --cache --cache-location ./node_modules/.cache/eslint src/" + "lint": "eslint --ignore-path ../../.gitignore src/" }, "dependencies": { "@grpc/grpc-js": "^1.11.3", @@ -25,21 +24,7 @@ }, "devDependencies": { "@types/node": "20.12.7", - "tsup": "^8.3.0", "tsx": "^4.19.1", "typescript": "^5.4.3" - }, - "tsup": { - "entry": [ - "src/index.ts" - ], - "format": [ - "esm" - ], - "sourcemap": true, - "treeshake": true, - "clean": true, - "minify": true, - "dts": true } } diff --git a/apps/backend/src/index.ts b/apps/backend/src/index.ts index e003acf..5e4f22d 100644 --- a/apps/backend/src/index.ts +++ b/apps/backend/src/index.ts @@ -21,7 +21,9 @@ import * as grpc from '@grpc/grpc-js'; import { SearchService } from './services/search.service'; -process.loadEnvFile('.env'); +try { + process.loadEnvFile('.env'); +} catch {} // eslint-disable-line no-empty const logger: Logger = new Logger({ name: 'lunaiz.am2mxm.api.v1', diff --git a/apps/frontend/app/root.tsx b/apps/frontend/app/root.tsx index 017af2b..0d7e3c3 100644 --- a/apps/frontend/app/root.tsx +++ b/apps/frontend/app/root.tsx @@ -49,8 +49,38 @@ export function Layout({ children }: { children: React.ReactNode }) { rel="stylesheet" href="https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.min.css" /> + + {/* Google Tag Manager */} +