Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
ceddybi committed Mar 21, 2024
0 parents commit 16d90c3
Show file tree
Hide file tree
Showing 65 changed files with 12,580 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
APP_NAME=sslatty
DEBUG=sslatty*
ACCESS_TOKEN_SECRET=random ass string
REFRESH_TOKEN_SECRET=random ass string

COUCHBASE_URL=
COUCHBASE_BUCKET=dev
COUCHBASE_USERNAME=admin
COUCHBASE_PASSWORD=

REDIS_URL="rediss://:xxxxxxxx@gusc1-hot-bass-30296.upstash.io:30296"


#BTCPAYSERVER ENV
BTCPAYSERVER_TOKEN=xxxxx
BTCPAYSERVER_STORE=xxxxx
BTCPAYSERVER_URL=https://xxxxxxx.com/api/v1
BTCPAYSERVER_BTC=S-xxxxxx-BTC
BTCPAYSERVER_XMR=S-xxxx-XMR
BTCPAYSERVER_CRON_ENABLED=BTC,XMR
# BTCPAYSERVER_CRON=*/1 * * * *

# MONERO
MONEROX_URL=http://localhost:3081
MONEROX_WALLET=xxxx-xxx-xx-xxx-xxxxxx
MONEROX_CRON=*/1 * * * *

# WALLET RPC
WALLET_RPC_URL=http://xxxxxxxxx:38084
WALLET_RPC_USER=rpc_user
WALLET_RPC_PASSWORD=abc123

# MAIN wallet
WALLET_PATH=abc123
WALLET_PASSWORD=abc123
WALLETS_DIR=/Users/ceddy/xmr/xwallet
62 changes: 62 additions & 0 deletions .github/workflows/fasdfs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: production

on:
push:
branches:
- "master"

env:
REGISTRY: us-docker.pkg.dev/xxcloud/app/app-backup
IMAGE: prod

NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
GKE_PROJECT: ${{ secrets.GKE_PROJECT }}
GKE_ZONE: ${{ secrets.GKE_ZONE }}
GKE_SA_KEY: ${{ secrets.GKE_SA_KEY }}

jobs:
fastdfs-backup:
name: deploy
runs-on: ubuntu-latest
container: catthehacker/ubuntu:act-latest

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

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildxbe-cache
key: ${{ runner.os }}-buildxbe-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildxbe-
- name: Login to GCR
uses: docker/login-action@v1
with:
registry: us-docker.pkg.dev
username: _json_key
password: ${{ secrets.GKE_SA_KEY }}

- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
file: ./fasdfs-backup.Dockerfile
push: true
tags: ${{ env.REGISTRY }}:${{ env.IMAGE }},${{ env.REGISTRY }}:latest
platforms: linux/amd64
cache-from: type=local,src=/tmp/.buildxbe-cache
cache-to: type=local,dest=/tmp/.buildxbe-cache-new,mode=max
build-args: |
GITHUB_SHA=${{ github.sha }}
GITHUB_REF=${{ github.ref }}
- name: Move cache
run: |
rm -rf /tmp/.buildxbe-cache
mv /tmp/.buildxbe-cache-new /tmp/.buildxbe-cache
104 changes: 104 additions & 0 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: production

on:
push:
branches:
- "master"

env:
REGISTRY: us-docker.pkg.dev/xxcloud/app/app-be
IMAGE: prod
DEPLOYMENT: api

AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
CLUSTER_NAME: ${{ secrets.CLUSTER_NAME }}

NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
GKE_PROJECT: ${{ secrets.GKE_PROJECT }}
GKE_ZONE: ${{ secrets.GKE_ZONE }}
GKE_SA_KEY: ${{ secrets.GKE_SA_KEY }}

jobs:
api:
name: deploy
runs-on: ubuntu-latest
container: catthehacker/ubuntu:act-latest

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

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildxbe-cache
key: ${{ runner.os }}-buildxbe-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildxbe-
- name: Get short SHA
id: slug
run: echo "::set-output name=sha7::$(git rev-parse --short HEAD)"

- name: Login to GCR
uses: docker/login-action@v1
with:
registry: us-docker.pkg.dev
username: _json_key
password: ${{ secrets.GKE_SA_KEY }}

- name: install aws cli
run: curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && unzip -qq awscliv2.zip && sudo ./aws/install

- name: kube configure
run: aws eks --region $AWS_DEFAULT_REGION update-kubeconfig --name $CLUSTER_NAME
env:
AWS_ACCESS_KEY_ID: ${{ env.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ env.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ env.AWS_DEFAULT_REGION }}
CLUSTER_NAME: ${{ env.CLUSTER_NAME }}

- name: Set up k8s
run: curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"

- name: Set chmod +x kubectl
run: chmod +x kubectl

- name: Kubernetes Cluster info
run: ./kubectl cluster-info
env:
AWS_ACCESS_KEY_ID: ${{ env.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ env.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ env.AWS_DEFAULT_REGION }}

- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ env.REGISTRY }}:${{ env.IMAGE }}-${{ steps.slug.outputs.sha7 }},${{ env.REGISTRY }}:latest
platforms: linux/amd64
cache-from: type=local,src=/tmp/.buildxbe-cache
cache-to: type=local,dest=/tmp/.buildxbe-cache-new,mode=max
build-args: |
GITHUB_SHA=${{ github.sha }}
GITHUB_REF=${{ github.ref }}
NPM_AUTH_TOKEN=${{ env.NPM_AUTH_TOKEN }}
- name: Move cache
run: |
rm -rf /tmp/.buildxbe-cache
mv /tmp/.buildxbe-cache-new /tmp/.buildxbe-cache
# Deploy the Docker image to the GKE cluster
- name: Deploy/Update new Image to Kubernetes
run: ./kubectl set image deploy/$DEPLOYMENT $DEPLOYMENT=$REGISTRY:$IMAGE-${{ steps.slug.outputs.sha7 }}
env:
AWS_ACCESS_KEY_ID: ${{ env.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ env.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ env.AWS_DEFAULT_REGION }}
77 changes: 77 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# OSX
#
.DS_Store

# Xcode
#
build/


# node.js
#
node_modules/
npm-debug.log
yarn-error.log

# Expo
.expo/*
web-build/

# @generated: @expo/next-adapter@2.1.52
/.expo/*
# Expo Web
/web-build/*
# Expo Native
*.jks
*.p8
*.p12
*.key
*.mobileprovision
*.orig.*
# Next.js
/.next/*
/out/
# Next.js production
/build/
# Next.js dependencies
/.pnp
.pnp.js
# @end @expo/next-adapter

# Firebase
serviceAccountKey.json*
firebase.config.js*
firebase.config.ts*
firebase.config.json*
*secret.js*
*secret.ts*
service.account.json*

.env


# Backend
.idea/
.vscode/
node_modules/
node_modules/**/*
build/
tmp/
temp/
keys/
*.env

# Web
*.next
*.expo
npm-debug.*
yarn-error.*
*.jks
*.p12
*.key
*.mobileprovision
*.orig.*
web-build/
web-report/

src/_config/*
24 changes: 24 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// This config file contains Mocha's defaults.
// As you can see, comments are allowed.
// This same configuration could be provided in the `mocha` property of your
// project's `package.json`.
// "test": "mocha src/**/*test.ts --exit --timeout 30000 --require ts-node/register --full-trace",
{
"diff": true,
"extension": [
"ts"
],
"opts": false,
"package": "./package.json",
"reporter": "spec",
"require": "ts-node/register",
"slow": 75,
"timeout": 0,
"ui": "bdd",
"watch-files": [
"src/**/*test.ts"
],
"watch-ignore": [
"node_modules"
]
}
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v18.17.1
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM amd64/node:18.17 AS builder

WORKDIR /srv

RUN npm -v
RUN yarn -v
COPY . .
RUN yarn

RUN yarn build

# use lighter image
FROM amd64/node:18.17-slim
COPY --from=builder /srv .
ENV NODE_ENV=production
EXPOSE 3000
CMD ["node", "build/index.js"]
1 change: 1 addition & 0 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
## SSLATT backend using RoadmanJS
15 changes: 15 additions & 0 deletions aws.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM public.ecr.aws/docker/library/node:18.17 AS builder

WORKDIR /srv

COPY . .
RUN yarn --ignore-engines

RUN yarn build

# use lighter image
FROM public.ecr.aws/docker/library/node:18.17-slim
COPY --from=builder /srv .
ENV NODE_ENV=production
EXPOSE 3000
CMD ["node", "build/index.js"]
34 changes: 34 additions & 0 deletions buildspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: 0.2

phases:
pre_build:
commands:
- echo Logging in to Amazon ECR...
- echo -e "$AWS_ACCESS_KEY_ID\n$AWS_SECRET_ACCESS_KEY\n$AWS_DEFAULT_REGION\n$AWS_DEFAULT_OUTPUT_FORMAT" | aws configure
- aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com
- TAG="$(date +%Y-%m-%d.%H.%M.%S).$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | head -c 8)"
- echo $TAG
- echo "Update Kube Config"
- aws eks update-kubeconfig --name $EKS_CLUSTER_NAME
build:
commands:
- echo Build started on `date`
- echo Building the Docker image...
- docker build -f aws.Dockerfile -t $IMAGE_REPO_NAME:$IMAGE_TAG -t $IMAGE_REPO_NAME:$TAG .
- docker tag $IMAGE_REPO_NAME:$IMAGE_TAG $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:$IMAGE_TAG
- docker tag $IMAGE_REPO_NAME:$TAG $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:$TAG

post_build:
commands:
- echo Build completed on `date`
- echo Pushing the Docker image...
- docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME --all-tags

- echo "Apply changes to k8s"
- kubectl set image deployment/$EKS_DEPLOYMENT_NAME $EKS_CONTAINER_NAME=$AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:$TAG
- echo "Completed applying changes to Kubernetes Objects"

- printf '[{"name":"'"$IMAGE_REPO_NAME"'","imageUri":"'"$AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:$IMAGE"'"}]' > imagedefinitions.json
artifacts:
files:
- "imagedefinitions.json"
Loading

0 comments on commit 16d90c3

Please sign in to comment.