Skip to content

Commit

Permalink
initial open source commit
Browse files Browse the repository at this point in the history
  • Loading branch information
a-game committed May 24, 2024
0 parents commit f4e86c5
Show file tree
Hide file tree
Showing 379 changed files with 30,748 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .commitlintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
extends:
- '@commitlint/config-conventional'
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
terraform
firebase
27 changes: 27 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Description

Please include a summary of the changes and the related issue.

### Type of change

Please delete options that are not relevant.

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update

### How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce.

### Checklist:

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream modules
76 changes: 76 additions & 0 deletions .github/workflows/gcp-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Deploy to GCP

on:
workflow_call:
inputs:
BUILD_ENV:
required: true
type: string

jobs:
deploy:
name: Deploy to GCP
runs-on: 'ubuntu-latest'
environment:
name: ${{ inputs.BUILD_ENV }}

steps:
- uses: actions/checkout@v4

- name: Authenticate with GCP
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_CREDENTIALS }}
project_id: ${{ vars.PROJECT_ID }}
export_environment_variables: true
create_credentials_file: true

- name: Set up cloud SDK
uses: google-github-actions/setup-gcloud@v2
with:
project_id: ${{ vars.PROJECT_ID }}

- name: authorize docker push
run: gcloud auth configure-docker ${{ vars.REGION }}-docker.pkg.dev --quiet

- name: Build and push service container image
run: |-
docker build --tag ${{ vars.REGION }}-docker.pkg.dev/${{ vars.PROJECT_ID }}/${{ vars.DOCKER_REPO }}/${{ vars.APP_IMAGE }} --build-arg BUILD_MODE=${{ vars.BUILD_MODE }} .
docker push ${{ vars.REGION }}-docker.pkg.dev/${{ vars.PROJECT_ID }}/${{ vars.DOCKER_REPO }}/${{ vars.APP_IMAGE }}
- name: Build and push migrations container image
working-directory: ./server
run: |-
docker build -f Dockerfile.dbmate --tag ${{ vars.REGION }}-docker.pkg.dev/${{ vars.PROJECT_ID }}/${{ vars.DOCKER_REPO }}/migrate-db .
docker push ${{ vars.REGION }}-docker.pkg.dev/${{ vars.PROJECT_ID }}/${{ vars.DOCKER_REPO }}/${{ vars.DB_MIGRATE_IMAGE }}
- name: Set up Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_wrapper: false

- name: Terraform deploy
id: deploy
working-directory: ./terraform/cd
env:
TF_VAR_region: ${{ vars.REGION }}
TF_VAR_project: ${{ vars.PROJECT_ID }}
TF_VAR_service_account: ${{ vars.SERVICE_ACCOUNT }}
TF_VAR_docker_repo: ${{ vars.DOCKER_REPO }}
TF_VAR_db_user: ${{ secrets.DB_USER }}
TF_VAR_app_image: ${{ vars.APP_IMAGE }}
TF_VAR_custom_domain: ${{ vars.CUSTOM_DOMAIN }}
TF_VAR_db_migrate_image: ${{ vars.DB_MIGRATE_IMAGE }}
run: |
terraform init -no-color -backend-config="bucket=${{ vars.TF_STATE_BUCKET }}"
terraform apply -auto-approve -no-color
- name: Get migration job name
id: get-migration-job-name
working-directory: ./terraform/cd
run: echo MIGRATE_DB_JOB_NAME=$(terraform output -raw migrate_db_job_name) >> $GITHUB_OUTPUT

- name: Execute migration job
run: |
gcloud run jobs execute ${{ steps.get-migration-job-name.outputs.MIGRATE_DB_JOB_NAME }} \
--region ${{ vars.REGION }}
53 changes: 53 additions & 0 deletions .github/workflows/lint-and-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Test and lint

on: [push, workflow_call]

jobs:
ci:
name: Lint, typecheck, and test
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- uses: pnpm/action-setup@v3
name: Install pnpm
id: pnpm-install
with:
version: 8
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install

- name: Build shared workspace
run: pnpm --filter shared build

- name: Run lint
run: pnpm lint

- name: Run typecheck
run: pnpm typecheck

- name: Run test
run: pnpm test
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules
.vscode
.idea
.secret
coverage/
.DS_Store

firebase.json
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

pnpm run lint:commit --edit ${1}
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no-install lint-staged
4 changes: 4 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
save-exact=true
auto-install-peers=true
deploy-all-files=true
engine-strict=true
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20
73 changes: 73 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
FROM node:20-alpine as base

WORKDIR '/app'

COPY pnpm-lock.yaml ./

ENV CI=true

RUN npm install -g pnpm@8

RUN pnpm fetch

ADD . ./

RUN pnpm install -r --offline --ignore-scripts
RUN pnpm --filter shared build



# ___ _ ___ ___ _ _ _____
# / __| | |_ _| __| \| |_ _|
# | (__| |__ | || _|| .` | | |
# \___|____|___|___|_|\_| |_|

FROM base as client-builder
COPY . .

WORKDIR '/app/client'

ARG BUILD_MODE

RUN pnpm build --mode $BUILD_MODE

# ___ ___ _____ _____ ___
# / __| __| _ \ \ / / __| _ \
# \__ \ _|| /\ V /| _|| /
# |___/___|_|_\ \_/ |___|_|_\

FROM base as server-builder

COPY . .

ENV CI=true

ENV HUSKY=0


RUN pnpm --filter server --prod deploy pruned

RUN pnpm --filter server deploy build

WORKDIR '/app/build'

RUN pnpm build

# ___ _ _ _ _
# | _ \ | | | \| |
# | / |_| | .` |
# |_|_\\___/|_|\_|

FROM --platform=linux/amd64 node:20-alpine

ENV NODE_ENV=production

COPY --from=server-builder /app/pruned/node_modules /server/node_modules
COPY --from=server-builder /app/build/dist /server/dist
COPY --from=client-builder /app/client/dist /client/dist

EXPOSE 8080

WORKDIR '/server'

CMD ["node", "dist/index.js"]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Devoteam Creative Tech

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading

0 comments on commit f4e86c5

Please sign in to comment.