Skip to content

Commit

Permalink
Merge pull request #1 from dmytro-komlyk/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
dmytro-komlyk authored May 28, 2024
2 parents 16c1532 + 9018136 commit 833aa1e
Show file tree
Hide file tree
Showing 128 changed files with 13,729 additions and 5,989 deletions.
45 changes: 29 additions & 16 deletions .github/workflows/ssh-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,62 +3,75 @@ name: CI/CD Build Pipeline # The name of the workflow
on:
pull_request:
branches:
- "*"
- '*'
workflow_dispatch:

env:
REGISTRY: ghcr.io
PROD_NAME: prod-nextjs-nestjs-boilerplate
PROD_NAME: ${{ vars.PROD_NAME }}
APP_DOMAIN: ${{ vars.APP_DOMAIN }}
ADMIN_DOMAIN: ${{ vars.ADMIN_DOMAIN }}
SERVER_DOMAIN: ${{ vars.SERVER_DOMAIN }}

jobs:
build:
name: "Build Application"
name: 'Build Application'
runs-on: ubuntu-latest
steps:
- name: "Checkout repository"
- name: 'Checkout repository'
uses: actions/checkout@v4

- name: "Set up QEMU"
- name: 'Set up QEMU'
uses: docker/setup-qemu-action@v3

- name: "Set up Docker Buildx"
- name: 'Set up Docker Buildx'
uses: docker/setup-buildx-action@v3

- name: "Login to GitHub Container Registry"
- name: 'Login to GitHub Container Registry'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.REGISTRY_TOKEN }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: "Build Server"
- name: 'Build Server'
if: contains(github.event.pull_request.labels.*.name, 'backend')
uses: docker/build-push-action@v4
with:
target: production
target: runner
file: ./apps/server/Dockerfile
secrets: |
push: true
tags: |
${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.PROD_NAME }}-server:latest
build-args: |
BUILD_MODE=prod
SERVER_DOMAIN=${{ env.SERVER_DOMAIN }}
ADMIN_DOMAIN=${{ env.ADMIN_DOMAIN }}
- name: "Build Client"
- name: 'Build Client'
if: contains(github.event.pull_request.labels.*.name, 'frontend-client')
uses: docker/build-push-action@v4
with:
target: production
target: runner
file: ./apps/client/Dockerfile
push: true
tags: |
${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.PROD_NAME }}-client:latest
build-args: |
BUILD_MODE=prod
SERVER_DOMAIN=${{ env.SERVER_DOMAIN }}
APP_DOMAIN=${{ env.APP_DOMAIN }}
- name: "Build Admin"
- name: 'Build Admin'
if: contains(github.event.pull_request.labels.*.name, 'frontend-admin')
uses: docker/build-push-action@v4
with:
target: production
target: runner
file: ./apps/admin/Dockerfile
push: true
tags: |
${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.PROD_NAME }}-admin:latest
build-args: |
BUILD_MODE=prod
SERVER_DOMAIN=${{ env.SERVER_DOMAIN }}
ADMIN_DOMAIN=${{ env.ADMIN_DOMAIN }}
20 changes: 10 additions & 10 deletions .github/workflows/ssh-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,30 @@ on:
workflow_dispatch:

env:
BRANCH: development
PROJECT_SSH_FOLDER: boilerplate
BRANCH: ${{ vars.BRANCH_DEPLOYMENT }}
PROJECT_SSH_FOLDER: ${{ vars.SSH_FOLDER }}
REGISTRY: ghcr.io
PROD_NAME: prod-nextjs-nestjs-boilerplate
PROD_NAME: ${{ vars.PROD_NAME }}
LABEL_SERVER: backend
LABEL_CLIENT: frontend-client
LABEL_ADMIN: frontend-admin

jobs:
deploy:
name: "Publish Application"
name: 'Publish Application'
runs-on: ubuntu-latest
steps:
- name: "Run deploy on SSH"
- name: 'Run deploy on SSH'
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == ${{ env.BRANCH_NAME }}
uses: appleboy/ssh-action@v1.0.0
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.SERVER_PASSWORD }}
port: ${{ secrets.SERVER_PORT }}
host: ${{ vars.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
password: ${{ secrets.SSH_PASSWORD }}
port: ${{ vars.SSH_PORT }}
script: |
cd ${{ env.PROJECT_SSH_FOLDER_NAME }}
echo ${{ secrets.REGISTRY_TOKEN }} | docker login ghcr.io -u ${{ github.repository_owner }} --password-stdin
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.repository_owner }} --password-stdin
if [[ "${{ contains(github.event.pull_request.labels.*.name, env.LABEL_SERVER) }}" == "true" ]]; then
docker rm $(docker stop $(docker ps -a -q --filter ancestor=${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.PROD_NAME }}-server:latest ))
Expand Down
64 changes: 39 additions & 25 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,39 +1,53 @@
# dependencies
# Dependencies
node_modules
.pnp
.pnp.js
.yarn/install-state.gz

# database
data
# Build Outputs
.turbo
.next
dist

# testing
coverage
# Uploads
apps/server/public

# next.js
.next/
out/
# env
.env
.env.local
.env.docker.local

# production
build
dist
# Database
apps/database/data
apps/database/seed

# Nginx

# misc
.DS_Store
*.pem

# debug
# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# Logs
logs
*.log
npm-debug.log*
pnpm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# local env files
.env
.env*.local

# vercel
.vercel
# OS
.DS_Store
*.pem

# typescript
*.tsbuildinfo
next-env.d.ts
# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

pnpm lint
pnpm lint-staged
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
auto-install-peers = true
public-hoist-pattern[]=*@nextui-org/*
public-hoist-pattern[]=*prisma*
3 changes: 3 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleQuote": true
}
12 changes: 10 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": true,
"source.organizeImports": true
"source.fixAll": "explicit",
"source.organizeImports": "explicit"
},
"eslint.workingDirectories": [
{
"mode": "auto"
}
],
"[prisma]": {
"editor.defaultFormatter": "Prisma.prisma"
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# Next-Nest-js-CI-on-VPS-Boilerplate
# Next-Nest-js-CI-on-VPS-Boilerplate
3 changes: 2 additions & 1 deletion apps/admin/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
.next
Dockerfile
.env.local
.env.docker.local
22 changes: 22 additions & 0 deletions apps/admin/.env.docker.local.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
APP_PORT=3002

NEXT_PUBLIC_BASE_URL=http://localhost:3001
NEXT_PUBLIC_SERVER_URL=http://localhost:3000
NEXT_PUBLIC_SERVER_API_URL=http://localhost:3000/api
NEXT_PUBLIC_SERVER_TRPC_URL=http://localhost:3000/api/trpc
NEXTAUTH_SECRET=
NEXTAUTH_URL=http://localhost:3001/api/auth
NEXTAUTH_JWT_ACCESS_TOKEN_EXPIRATION='1d'

# This was inserted by `prisma init`:
# Environment variables declared in this file are automatically made available to Prisma.
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema

# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
DATABASE_USERNAME=
DATABASE_PASSWORD=
DATABASE_HOST=mongo
DATABASE_PORT=27017
DATABASE_NAME=
DATABASE_URL="mongodb://${DATABASE_USERNAME}:${DATABASE_PASSWORD}@${DATABASE_HOST}:${DATABASE_PORT}/${DATABASE_NAME}?replicaSet=rs0&retryWrites=true&w=majority&directConnection=true&authSource=admin"
24 changes: 24 additions & 0 deletions apps/admin/.env.docker.prod.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
APP_PORT=3002
APP_DOMAIN=
SERVER_DOMAIN=

NEXT_PUBLIC_BASE_URL="https://${APP_DOMAIN}"
NEXT_PUBLIC_SERVER_URL="https://${SERVER_DOMAIN}"
NEXT_PUBLIC_SERVER_API_URL="https://${SERVER_DOMAIN}/api"
NEXT_PUBLIC_SERVER_TRPC_URL="https://${SERVER_DOMAIN}/api/trpc"
NEXTAUTH_SECRET=
NEXTAUTH_URL="https://${APP_DOMAIN}/api/auth"
NEXTAUTH_JWT_ACCESS_TOKEN_EXPIRATION='1d'

# This was inserted by `prisma init`:
# Environment variables declared in this file are automatically made available to Prisma.
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema

# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
DATABASE_USERNAME=
DATABASE_PASSWORD=
DATABASE_HOST=mongo
DATABASE_PORT=27017
DATABASE_NAME=
DATABASE_URL="mongodb://${DATABASE_USERNAME}:${DATABASE_PASSWORD}@${DATABASE_HOST}:${DATABASE_PORT}/${DATABASE_NAME}?replicaSet=rs0&retryWrites=true&w=majority&directConnection=true&authSource=admin"
13 changes: 0 additions & 13 deletions apps/admin/.env.example

This file was deleted.

26 changes: 26 additions & 0 deletions apps/admin/.env.local.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
APP_PORT=3002

NEXT_PUBLIC_BASE_URL=http://localhost:3002
NEXT_PUBLIC_SERVER_URL=http://localhost:3000
NEXT_PUBLIC_SERVER_API_URL=http://localhost:3000/api
NEXT_PUBLIC_SERVER_TRPC_URL=http://localhost:3000/api/trpc

#Auth
NEXTAUTH_SECRET=
NEXTAUTH_URL=http://localhost:3002/api/auth
NEXTAUTH_JWT_ACCESS_TOKEN_EXPIRATION='1d'
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=

# This was inserted by `prisma init`:
# Environment variables declared in this file are automatically made available to Prisma.
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema

# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
DATABASE_USERNAME=
DATABASE_PASSWORD=
DATABASE_HOST=127.0.0.1
DATABASE_PORT=27017
DATABASE_NAME=
DATABASE_URL="mongodb://${DATABASE_USERNAME}:${DATABASE_PASSWORD}@${DATABASE_HOST}:${DATABASE_PORT}/${DATABASE_NAME}?replicaSet=rs0&retryWrites=true&w=majority&directConnection=true&authSource=admin"
10 changes: 10 additions & 0 deletions apps/admin/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
root: true,
extends: ['next', 'next/core-web-vitals', '@repo/eslint-config/next.js'],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2021,
sourceType: 'module',
project: true,
},
};
3 changes: 0 additions & 3 deletions apps/admin/.eslintrc.json

This file was deleted.

Loading

0 comments on commit 833aa1e

Please sign in to comment.