Skip to content

Commit

Permalink
feat: initial scaffolding and development (#1)
Browse files Browse the repository at this point in the history
* feat: initial scaffolding and development

Signed-off-by: Bryce McMath <[email protected]>

* chore: update readme

Signed-off-by: Bryce McMath <[email protected]>

* chore: add missing dep

Signed-off-by: Bryce McMath <[email protected]>

* feat: add gha, update Dockerfile and helm charts

Signed-off-by: Bryce McMath <[email protected]>

* fix: lower ubuntu version for python support

Signed-off-by: Bryce McMath <[email protected]>

* chore: remove devcontainer

Signed-off-by: Bryce McMath <[email protected]>

---------

Signed-off-by: Bryce McMath <[email protected]>
  • Loading branch information
bryce-mcmath authored Jul 5, 2024
1 parent c78b88e commit 042c2a6
Show file tree
Hide file tree
Showing 34 changed files with 11,665 additions and 1 deletion.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
4 changes: 4 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
PORT=3000
THROTTLE_TTL=60000
THROTTLE_LIMIT=2000
LOG_LEVEL=3
25 changes: 25 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
tsconfigRootDir: __dirname,
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
root: true,
env: {
node: true,
jest: true,
},
ignorePatterns: ['.eslintrc.js'],
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
};
57 changes: 57 additions & 0 deletions .github/actions/docker-build/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Docker Build
description: Build Docker Image
inputs:
context:
description: Docker context path
required: true
default: dist
dockerfile:
description: Dockerfile path
required: true
registry:
description: Docker registry
required: true
image_name:
description: Docker image name
required: true
docker_user:
description: Docker user
required: true
docker_password:
description: Docker password
required: true
runs:
using: composite
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

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

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ inputs.registry }}
username: ${{ inputs.docker_user }}
password: ${{ inputs.docker_password }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ inputs.registry }}/${{ inputs.image_name }}
tags: |
type=sha,prefix=
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: ${{ inputs.context }}
file: ${{ inputs.dockerfile }}
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
89 changes: 89 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Quality and Build

on:
pull_request:
branches: [main]
types: [opened, synchronize, reopened, labeled]
push:
branches: [main]

jobs:
lint:
runs-on: ubuntu-20.04
name: Linting
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v4
with:
python-version: '3.7.1'

- name: Setup NodeJS
uses: actions/setup-node@v4
with:
node-version: '18'

- name: Install dependencies
run: |
node -v && yarn -v && yarn install --immutable && \
git status
- name: Prettier
run: |
yarn format:check
- name: Linting
run: |
yarn lint:check
test:
runs-on: ubuntu-20.04
name: Testing
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v4
with:
python-version: '3.7.1'

- uses: actions/setup-node@v4
with:
node-version: '18'

- name: Install dependencies
run: |
node -v && yarn -v && yarn install --immutable && \
git status
- name: NestJS build
run: |
yarn build
- name: Unit testing
run: |
yarn test
- name: End-to-end testing
run: |
yarn test:e2e
build:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: [lint, test]
runs-on: ubuntu-20.04
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4

- name: Build Docker image
uses: ./.github/actions/docker-build
with:
registry: ${{ env.REGISTRY }}
image_name: "${{ github.repository }}/server"
context: ./
dockerfile: "Dockerfile"
docker_user: ${{ github.actor }}
docker_password: ${{ secrets.GITHUB_TOKEN }}

77 changes: 77 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# compiled output
/dist
/node_modules
/build

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

# OS
.DS_Store

# Tests
/coverage
/.nyc_output

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

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# yarn
.yarn/*
.yarn/cache
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
app/.yarn/*
app/.yarn/cache
!app/.yarn/patches
!app/.yarn/plugins
!app/.yarn/releases
!app/.yarn/sdks
!app/.yarn/versions
yarn-debug.log*
yarn-error.log*
.yarn-integrity
.pnp.js
.pnp.cjs
.pnp.loader.mjs
.pnp.data.json

# temp directory
.temp
.tmp

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"singleQuote": true,
"trailingComma": "all",
"semi": false,
"printWidth": 100
}
894 changes: 894 additions & 0 deletions .yarn/releases/yarn-4.3.1.cjs

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
nodeLinker: node-modules
yarnPath: .yarn/releases/yarn-4.3.1.cjs
45 changes: 45 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Setup
FROM node:18-buster AS base

# Setup env variable for yarn
ENV YARN_VERSION=4.3.1

# Update dependencies, add python to the base image
RUN apt-get update && apt-get install python3=3.7.3-1

# Install and use yarn 4.x
RUN corepack enable && corepack prepare yarn@${YARN_VERSION}

# Create app directory
WORKDIR /app

# Create non-root user for Docker
RUN addgroup --system --gid 1001 vdrproxy
RUN adduser --system --uid 1001 vdrproxy

# Copy source code into app folder and give permissions to non-root user
COPY --chown=vdrproxy:vdrproxy . .

# Fix for node-gyp issues (Yarn 4 doesn't do global installs)
RUN npm install -g node-gyp

# Build server
FROM base AS builder

# Install deps and remove created cache
RUN yarn install --immutable && yarn cache clean

# Build the server
RUN yarn build

# Run server
FROM builder AS runner

# Set Docker as a non-root user
USER vdrproxy

# Expose port
EXPOSE 3000

# Run server
CMD ["node", "dist/main.js"]
37 changes: 36 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,37 @@
# indy-vdr-proxy-server
HTTP proxy for the Indy verifiable data registry

## Description

HTTP proxy for the Indy verifiable data registry to be used with BC Wallet et al.

## Installation

```bash
$ yarn install
```

## Running the app

```bash
# development
$ yarn run start

# watch mode
$ yarn run start:dev

# production mode
$ yarn run start:prod
```

## Test

```bash
# unit tests
$ yarn run test

# e2e tests
$ yarn run test:e2e

# test coverage
$ yarn run test:cov
```
24 changes: 24 additions & 0 deletions charts/server/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: vdr-proxy
description: A Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.0.1

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "0.0.1"
3 changes: 3 additions & 0 deletions charts/server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```console
helm install proxy-server ./devops/charts/server -f ./devops/charts/server/values_dev.yaml
```
Loading

0 comments on commit 042c2a6

Please sign in to comment.