Skip to content

Commit

Permalink
Copy upstream over conflicted files
Browse files Browse the repository at this point in the history
  • Loading branch information
DerekRoberts committed Sep 21, 2023
1 parent ab18c0b commit cbe4bd7
Show file tree
Hide file tree
Showing 13 changed files with 318 additions and 8,621 deletions.
342 changes: 1 addition & 341 deletions README.md

Large diffs are not rendered by default.

33 changes: 1 addition & 32 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<<<<<<< HEAD
# Build
FROM node:alpine AS build

Expand All @@ -15,34 +14,4 @@ EXPOSE 5000
HEALTHCHECK --interval=30s --timeout=3s CMD curl -f http://localhost/:5000

#CMD
CMD ["npm", "start"]
=======
# Build static files
# Node Bullseye has npm
FROM node:20.7.0-bullseye-slim AS build

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

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

# Copy over app
WORKDIR /app
COPY --from=build /app/node_modules ./node_modules
COPY --from=build /app/dist ./dist

# Ports, health check and non-root user
EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=3s CMD curl -f http://localhost/:3000/api || exit 1
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"]
>>>>>>> 2577926 (Initial commit)
CMD ["npm", "start"]
108 changes: 0 additions & 108 deletions backend/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
<<<<<<< HEAD
"name": "nr-results-exam-back",
"version": "1.0.0",
"description": "backend service for results exam",
Expand All @@ -17,112 +16,5 @@
"express": "^4.18.2",
"express-async-handler": "^1.2.0",
"express-ipfilter": "^1.3.1"
=======
"author": "BC Government Forestry Suite of Applications Starter Template",
"license": "Apache-2.0",
"main": "index.js",
"scripts": {
"prebuild": "rimraf dist",
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"lint:staged": "./node_modules/.bin/lint-staged",
"make-badges": "istanbul-badges-readme --logo=jest --exitCode=1",
"make-badges:ci": "npm run make-badges -- --ci",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage --detectOpenHandles --forceExit",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
"@nestjs/cli": "^10.1.16",
"@nestjs/common": "^10.0.0",
"@nestjs/config": "^3.0.0",
"@nestjs/core": "^10.0.0",
"@nestjs/platform-express": "^10.0.0",
"@nestjs/schematics": "^10.0.0",
"@nestjs/swagger": "^7.0.3",
"@nestjs/testing": "^10.0.0",
"@nestjs/typeorm": "^10.0.0",
"dotenv": "^16.0.1",
"pg": "^8.7.3",
"reflect-metadata": "^0.1.13",
"rimraf": "^5.0.0",
"rxjs": "^7.8.0",
"swagger-ui-express": "^5.0.0",
"typeorm": "^0.3.17",
"winston": "^3.9.0",
"nest-winston": "^1.9.3",
"helmet": "^7.0.0"
},
"devDependencies": {
"@types/express": "^4.17.15",
"@types/jest": "^29.0.0",
"@types/node": "^18.17.12",
"@types/supertest": "^2.0.11",
"@typescript-eslint/eslint-plugin": "^6.5.0",
"@typescript-eslint/parser": "^6.5.0",
"eslint": "^8.32.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier": "^9.0.0",
"eslint-config-standard": "^17.0.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-promise": "^6.1.1",
"istanbul-badges-readme": "^1.8.4",
"jest": "^29.0.0",
"jest-badges": "^0.1.3",
"jest-sonar-reporter": "^2.0.0",
"lint-staged": "^14.0.0",
"prettier": "^3.0.0",
"source-map-support": "^0.5.20",
"supertest": "^6.3.3",
"ts-jest": "^29.0.5",
"ts-loader": "^9.4.2",
"ts-node": "^10.3.0",
"tsconfig-paths": "^4.1.2",
"typescript": "^4.9.4"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".*\\.spec\\.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"collectCoverage": true,
"collectCoverageFrom": [
"**/*.(t|j)s"
],
"coverageDirectory": "../coverage",
"coveragePathIgnorePatterns": [
"/node_modules/",
"/test/"
],
"coverageReporters": [
"text",
"lcov",
"cobertura",
"jest-badges"
],
"testEnvironment": "node",
"testResultsProcessor": "jest-sonar-reporter"
},
"lint-staged": {
"*.{js,ts}": "./node_modules/.bin/eslint --cache --fix"
},
"overrides": {
"minimist@<1.2.6": "1.2.6"
>>>>>>> 2577926 (Initial commit)
}
}
94 changes: 1 addition & 93 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<<<<<<< HEAD
version: '3.9'

x-common: &common
Expand All @@ -25,88 +24,11 @@ services:
volumes: ["./frontend:/app", "/app/node_modules"]
working_dir: "/app"
<<: *common
=======
---
version: "3.9"

x-var:
- &POSTGRES_USER
postgres
- &POSTGRES_PASSWORD
default
- &POSTGRES_DATABASE
postgres

x-postgres-vars: &postgres-vars
POSTGRES_HOST: database
POSTGRES_USER: *POSTGRES_USER
POSTGRES_PASSWORD: *POSTGRES_PASSWORD
POSTGRES_DATABASE: *POSTGRES_DATABASE

services:
database:
image: postgres:15
container_name: database
environment:
<<: *postgres-vars
healthcheck:
test: ["CMD", "pg_isready", "-U", *POSTGRES_USER]
ports: ["5432:5432"]

migrations:
image: flyway/flyway:9-alpine
container_name: migrations
command: info migrate info
volumes: ["./backend/db/migrations:/flyway/sql:ro"]
environment:
FLYWAY_URL: jdbc:postgresql://database:5432/postgres
FLYWAY_USER: *POSTGRES_USER
FLYWAY_PASSWORD: *POSTGRES_PASSWORD
FLYWAY_BASELINE_ON_MIGRATE: true
FLYWAY_DEFAULT_SCHEMA: USERS
depends_on:
database:
condition: service_healthy

backend:
container_name: backend
entrypoint: sh -c "npm i && npm run start:dev"
environment:
<<: *postgres-vars
NODE_ENV: development
image: node:20-bullseye
ports: ["3001:3000"]
volumes: ["./backend:/app", "/app/node_modules"]
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/api"]
working_dir: "/app"
depends_on:
migrations:
condition: service_started

frontend:
container_name: frontend
entrypoint: sh -c "npm ci && npm run dev"
environment:
NODE_ENV: development
PORT: 3000
BACKEND_URL: http://backend:3000
image: node:20-bullseye
ports: ["3000:3000"]
volumes: ["./frontend:/app", "/app/node_modules"]
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000"]
working_dir: "/app"
depends_on:
backend:
condition: service_healthy
>>>>>>> 2577926 (Initial commit)

caddy:
container_name: caddy
profiles: ["caddy"]
build: ./frontend
<<<<<<< HEAD
ports: ["3005:3000"]
volumes: ["./frontend/Caddyfile:/etc/caddy/Caddyfile"]
<<: *common
Expand All @@ -128,18 +50,4 @@ services:
test: [ "CMD-SHELL", "curl http://localhost:5000" ]
interval: 15s
timeout: 5s
retries: 5
=======
environment:
NODE_ENV: development
PORT: 3000
BACKEND_URL: http://backend:3000
LOG_LEVEL: info
ports: ["3005:3000"]
volumes: ["./frontend/Caddyfile:/etc/caddy/Caddyfile"]
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000"]
depends_on:
backend:
condition: service_healthy
>>>>>>> 2577926 (Initial commit)
retries: 5
27 changes: 0 additions & 27 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<<<<<<< HEAD
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
Expand All @@ -25,29 +24,3 @@ yarn-error.log*
package-lock.json


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

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
>>>>>>> 2577926 (Initial commit)
37 changes: 1 addition & 36 deletions frontend/Caddyfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@
auto_https off
admin off
}
<<<<<<< HEAD

:3000 {
root * /srv

encode gzip

=======
:3000 {
>>>>>>> 2577926 (Initial commit)
log {
output stdout
format console {
Expand All @@ -20,33 +16,13 @@
}
level {$LOG_LEVEL}
}
<<<<<<< HEAD

=======
root * /srv
encode zstd gzip
file_server
@spa_router {
not path /api/*
file {
try_files {path} /index.html
}
}
rewrite @spa_router {http.matchers.file.relative}
# Proxy requests to API service
reverse_proxy /api/* {$BACKEND_URL} {
header_up Host {http.reverse_proxy.upstream.hostport}
header_up X-Real-IP {remote_host}
header_up X-Forwarded-For {remote_host}
}
>>>>>>> 2577926 (Initial commit)
header {
X-Frame-Options "SAMEORIGIN"
X-XSS-Protection "1;mode=block"
Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate"
X-Content-Type-Options "nosniff"
Strict-Transport-Security "max-age=31536000"
<<<<<<< HEAD
Content-Security-Policy "base-uri 'self'; connect-src 'self' https://*.gov.bc.ca https://*.amazoncognito.com https://cognito-idp.ca-central-1.amazonaws.com; default-src 'self'; font-src 'self'; frame-src 'self' https://*.gov.bc.ca; img-src 'self'; manifest-src 'self'; media-src 'self'; object-src 'none'; script-src 'unsafe-inline' 'report-sample' 'self' https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js; style-src 'report-sample' 'self' https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css; worker-src 'none';"
Referrer-Policy "same-origin"
}
Expand All @@ -63,19 +39,8 @@
file_server
}

=======
Content-Security-Policy "default-src 'self' https://spt.apps.gov.bc.ca data:; script-src 'self' 'unsafe-eval' https://www2.gov.bc.ca ;style-src 'self' 'unsafe-inline' https://fonts.googleapis.com https://use.fontawesome.com; font-src 'self' https://fonts.gstatic.com; img-src 'self' data: https://fonts.googleapis.com http://www.w3.org https://*.gov.bc.ca"
Referrer-Policy "same-origin"
Feature-Policy "fullscreen 'self'; camera 'none'; microphone 'none'"
}
}
>>>>>>> 2577926 (Initial commit)
:3001 {
handle /health {
respond "OK"
}
<<<<<<< HEAD
}
=======
}
>>>>>>> 2577926 (Initial commit)
}
Loading

0 comments on commit cbe4bd7

Please sign in to comment.