Skip to content

Commit

Permalink
initial attempt
Browse files Browse the repository at this point in the history
1. remove additional items, will be added later as an when needed (load, IT)
2. remove nest and use plain express
3. add redux.
  • Loading branch information
mishraomp committed Feb 7, 2024
1 parent 7f4685f commit 61e3712
Show file tree
Hide file tree
Showing 78 changed files with 2,338 additions and 6,610 deletions.
74 changes: 0 additions & 74 deletions .github/workflows/.tests.yml

This file was deleted.

42 changes: 0 additions & 42 deletions .github/workflows/load-test.yml

This file was deleted.

7 changes: 1 addition & 6 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,7 @@ jobs:
tag: ${{ needs.vars.outputs.pr }}
release: test

integration-e2e:
name: Integration and E2E Tests
needs: [deploy-test, vars]
uses: ./.github/workflows/.tests.yml
with:
target: test


deploy-prod:
name: Deploy (prod)
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,3 @@ test-report.xml
**/out
**/target

# VSCode
.vscode/
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode"]
}
38 changes: 38 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Backend",
"request": "launch",
"runtimeArgs": ["run-script", "dev"],
"runtimeExecutable": "npm",
"skipFiles": ["backend/<node_internals>/**"],
"type": "node",
"cwd": "${workspaceFolder}/backend",
"preLaunchTask": "database"
}
{
"name": "Frontend",
"request": "launch",
"runtimeArgs": ["run-script", "serve"],
"runtimeExecutable": "npm",
"skipFiles": ["frontend/<node_internals>/**"],
"type": "node",
"cwd": "${workspaceFolder}/frontend"
},
{
"name": "Launch Edge",
"type": "msedge",
"request": "launch",
"url": "http://localhost:3001",
"webRoot": "${workspaceFolder}/frontend"
}
],
"compounds": [
{
"name": "Launch All",
"configurations": ["Backend", "Frontend", "Launch Edge"],
"stopAll": true
}
]
}
25 changes: 25 additions & 0 deletions .vscode/nr-omrr-transparency.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"folders": [
{
"path": ".."
},
{
"name": "frontend",
"path": "../frontend"
},
{
"name": "backend",
"path": "../backend"
}
],
"settings": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
"files.exclude": {
"backend": true,
"frontend": true,
"coverage": true
}
}
}
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
"eslint.enable": false
}
11 changes: 11 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "database",
"type": "shell",
"command": "docker-compose up -d migrations",
"problemMatcher": []
}
]
}
3 changes: 3 additions & 0 deletions backend/.env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/postgres?schema=omrr&connection_limit=5"
LOG_LEVEL=silly
IS_RATE_LIMIT_ENABLED=true
48 changes: 22 additions & 26 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,44 +1,40 @@
# Build static files
# Node Bullseye has npm
FROM node:20.11.0-bullseye-slim AS buildWithDevDeps
FROM node:20.11.0-bullseye-slim AS build

# Install packages, build and keep only prod packages
WORKDIR /app
COPY *.json ./
COPY ./src ./src
COPY ./prisma ./prisma
RUN npm ci --ignore-scripts --no-update-notifier
RUN npm run prisma-generate
FROM node:20.11.0-bullseye-slim AS build
RUN npm ci --ignore-scripts && \
npm run build

RUN mkdir -p /app/sessions

FROM node:20.11.0-bullseye-slim AS dependencies

# Install packages, build and keep only prod packages
WORKDIR /app
COPY *.json ./
COPY ./src ./src
COPY ./prisma ./prisma
RUN npm ci --ignore-scripts --no-update-notifier --omit=dev

# COPY over few dependencies from buildWithDevDeps
COPY --from=buildWithDevDeps /app/node_modules/@prisma ./node_modules/@prisma
COPY --from=buildWithDevDeps /app/node_modules/.prisma ./node_modules/.prisma
COPY --from=buildWithDevDeps /app/node_modules/prisma ./node_modules/prisma
RUN npm ci --omit=dev --ignore-scripts

RUN npm run build

# Deploy container
# Distroless has node, but not npm
# Deployment container
FROM gcr.io/distroless/nodejs20-debian11:nonroot
ENV NODE_ENV production

# Copy over app
# Copy over app.ts
WORKDIR /app
COPY --from=build /app/node_modules ./node_modules
COPY --from=dependencies /app/node_modules ./node_modules
COPY --from=build /app/node_modules/@prisma ./node_modules/@prisma
COPY --from=build /app/node_modules/.prisma ./node_modules/.prisma
COPY --from=build /app/node_modules/prisma ./node_modules/prisma
COPY --from=build /app/dist ./dist
COPY --from=build /app/sessions ./sessions

# Ports, health check and non-root user
# Port and health check
EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=3s CMD curl -f http://localhost/:3000/api || exit 1
USER nonroot
HEALTHCHECK --interval=30s --timeout=3s CMD curl -f http://localhost/:3000

# Non-privileged user
USER app

# Start up command with 50MB of heap size, each application needs to determine what is the best value. DONT use default as it is 4GB.
CMD ["--max-old-space-size=50", "/app/dist/main"]
# Start up command with 250MB of heap size, each application needs to determine what is the best value. DONT use default as it is 4GB.
CMD ["--max-old-space-size=250", "/app/dist/server"]
4 changes: 0 additions & 4 deletions backend/nest-cli.json

This file was deleted.

Loading

0 comments on commit 61e3712

Please sign in to comment.