diff --git a/.github/workflows/client.yaml b/.github/workflows/client.yaml new file mode 100644 index 00000000..3788d73c --- /dev/null +++ b/.github/workflows/client.yaml @@ -0,0 +1,101 @@ +name: client +on: + workflow_dispatch: + push: + paths: + - 'client/**' + branches: + - main + tags: + - "v*.*.*" + pull_request: + paths: + - 'client/**' + branches: + - main + +jobs: + lint-test: + runs-on: ubuntu-latest + name: Check for Linting Errors and Unit Test Errors + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.ref }} + + - name: Setup NodeJS + uses: actions/setup-node@v3 + with: + node-version: 18 + + - name: NPM Install + run: npm install --force + shell: bash + + - name: Build GraphQL Code + run: npm run introspection + + - name: Check for Linting Issues + run: npm run lint --workspace=client + + - name: Check for Prettier Issues + run: npm run prettier --workspace=client + + - name: Run unit tests for the client + run: npm run test --workspace=client + + docker-build: + runs-on: ubuntu-latest + name: Docker Build (and Deploy) + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v2 + if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build & Push Docker Test Build + uses: docker/build-push-action@v4 + with: + context: . + file: client/Dockerfile + push: ${{ github.event_name != 'pull_request' }} + tags: hicsail/signlab-client:unstable + build-args: | + PRODUCTION="false" + GRAPHQL_ENDPOINT=${{ secrets.GRAPHQL_ENDPOINT }} + ASL_LEX_ID=${{ secrets.ASL_LEX_ID }} + + - name: Build & Push Docker Production Build + uses: docker/build-push-action@v4 + if: startsWith(github.ref, 'refs/tags/v') + with: + context: . + file: client/Dockerfile + push: ${{ github.event_name != 'pull_request' }} + tags: hicsail/signlab-client:latest,hicsail/signlab-client:${{github.ref_name}} + build-args: | + PRODUCTION="true" + GRAPHQL_ENDPOINT=${{ secrets.GRAPHQL_ENDPOINT_PRODUCTION }} + ASL_LEX_ID=${{ secrets.ASL_LEX_ID_PRODUCTION }} + + - name: Push to Staging + uses: fjogeleit/http-request-action@v1 + if: github.ref == 'refs/heads/main' + with: + method: "POST" + url: ${{ secrets.PORTAINER_WEBHOOK }} + preventFailureOnNoResponse: true + + - name: Push to Production + uses: fjogeleit/http-request-action@v1 + if: startsWith(github.ref, 'refs/tags/v') + with: + method: "POST" + url: ${{ secrets.PORTAINER_WEBHOOK_PRODUCTION }} + preventFailureOnNoResponse: true diff --git a/.github/workflows/gateway.yaml b/.github/workflows/gateway.yaml new file mode 100644 index 00000000..592dd838 --- /dev/null +++ b/.github/workflows/gateway.yaml @@ -0,0 +1,113 @@ +name: gateway +on: + workflow_dispatch: + push: + paths: + - 'gateway/**' + branches: + - main + tags: + - "v*.*.*" + pull_request: + paths: + - 'gateway/**' + branches: + - main + +jobs: + lint: + runs-on: ubuntu-latest + name: Check for Linting Errors + defaults: + run: + working-directory: gateway + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.ref }} + + - name: Setup NodeJS + uses: actions/setup-node@v3 + with: + node-version: 18 + + - name: NPM Install + run: npm install --only-dev + shell: bash + + - name: Check for Linting Issues + run: npm run lint + + - name: Check for Prettier Issues + run: npm run prettier + + build: + runs-on: ubuntu-latest + name: Build + defaults: + run: + working-directory: gateway + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Setup NodeJS + uses: actions/setup-node@v3 + with: + node-version: 18 + + - name: NPM Install + run: npm install + shell: bash + + - name: Build + run: npm run build + + docker-build: + runs-on: ubuntu-latest + name: Docker Build (and Deploy) + defaults: + run: + working-directory: gateway + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v2 + if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build & Push Docker Test Build + uses: docker/build-push-action@v4 + with: + context: ./gateway/ + push: ${{ github.event_name != 'pull_request' }} + tags: hicsail/signlab-gateway:unstable + + - name: Build & Push Docker Production Build + uses: docker/build-push-action@v4 + if: startsWith(github.ref, 'refs/tags/v') + with: + context: ./gateway/ + push: ${{ github.event_name != 'pull_request' }} + tags: hicsail/signlab-gateway:latest,hicsail/signlab-gateway:${{github.ref_name}} + + - name: Push to Staging + uses: fjogeleit/http-request-action@v1 + if: github.ref == 'refs/heads/main' + with: + method: "POST" + url: ${{ secrets.PORTAINER_WEBHOOK }} + preventFailureOnNoResponse: true + + - name: Push to Production + uses: fjogeleit/http-request-action@v1 + if: startsWith(github.ref, 'refs/tags/v') + with: + method: "POST" + url: ${{ secrets.PORTAINER_WEBHOOK_PRODUCTION }} + preventFailureOnNoResponse: true diff --git a/.github/workflows/on-pr.yaml b/.github/workflows/on-pr.yaml deleted file mode 100644 index 1940020f..00000000 --- a/.github/workflows/on-pr.yaml +++ /dev/null @@ -1,158 +0,0 @@ -name: Run Linting and Testing - -on: - pull_request: - branches: [ main ] - -jobs: - lint: - runs-on: ubuntu-latest - name: Check for Linting Errors - steps: - - name: Checkout Repository - uses: actions/checkout@v3 - with: - ref: ${{ github.event.pull_request.head.ref }} - - - name: Setup NodeJS - uses: actions/setup-node@v3 - with: - node-version: 16 - - - name: NPM Install - run: npm install --only-dev - shell: bash - - - name: Build GraphQL Code - run: npm run introspection - - - name: Check for Linting Issues - run: npm run lint - - - name: Check for Prettier Issues - run: npm run prettier - - client-unit-tests: - runs-on: ubuntu-latest - name: Run Client Side Unit Tests - steps: - - name: Checkout Repository - uses: actions/checkout@v3 - with: - ref: ${{ github.event.pull_request.head.ref }} - - - name: Setup NodeJS - uses: actions/setup-node@v3 - with: - node-version: 16 - - - name: NPM Install - run: npm install --only-dev - shell: bash - - - name: Build GraphQL Code - run: npm run introspection - - - name: Run unit tests for the client - run: npm run test --workspace=client - - server-unit-tests: - runs-on: ubuntu-latest - name: Run Server Side Unit Tests - steps: - - name: Checkout Repository - uses: actions/checkout@v3 - with: - ref: ${{ github.event.pull_request.head.ref }} - - - name: Setup NodeJS - uses: actions/setup-node@v3 - with: - node-version: 16 - - - name: NPM Install - run: npm install --only-dev - shell: bash - - - name: Build GraphQL Code - run: npm run introspection - - - - name: Run unit tests for the server - run: npm run test --workspace=server - - e2e-tests: - runs-on: ubuntu-latest - name: Run E2E Tests - steps: - - name: Checkout Repository - uses: actions/checkout@v3 - with: - ref: ${{ github.event.pull_request.head.ref }} - - - name: Setup NodeJS - uses: actions/setup-node@v3 - with: - node-version: 16 - - - name: NPM Install - run: npm install --only-dev - shell: bash - - - name: Build GraphQL Code - run: npm run introspection - - - name: Build Code - run: | - npm run build:prod - mkdir -p server/bucket-test/Entries - - - name: Start MongoDB Instance - uses: supercharge/mongodb-github-action@1.8.0 - - - name: Run e2e testing - uses: cypress-io/github-action@v4.2.0 - with: - start: npm run start:ci - browser: chrome - env: - MONGO_URI: mongodb://localhost:27017/signlab-test - - - uses: actions/upload-artifact@v2 - if: failure() - with: - name: cypress-screenshots - path: cypress/screenshots - - - uses: actions/upload-artifact@v2 - if: always() - with: - name: cypress-videos - path: cypress/videos - - docker-build: - runs-on: ubuntu-latest - steps: - - name: Checkout Repository - uses: actions/checkout@v3 - with: - ref: ${{ github.event.pull_request.head.ref }} - - - name: Checkout Repository - uses: actions/checkout@v3 - with: - ref: ${{ github.event.pull_request.head.ref }} - - name: Verify Build Works - uses: docker/build-push-action@v3 - with: - push: false - build-args: | - PRODUCTION="false" - GRAPHQL_ENDPOINT=${{ secrets.GRAPHQL_ENDPOINT }} - ASL_LEX_ID=${{ secrets.ASL_LEX_ID }} - - - name: Verify Build Works (Gateway) - uses: docker/build-push-action@v3 - with: - context: ./gateway - push: false diff --git a/.github/workflows/on-push-main.yaml b/.github/workflows/on-push-main.yaml deleted file mode 100644 index 9b828afd..00000000 --- a/.github/workflows/on-push-main.yaml +++ /dev/null @@ -1,51 +0,0 @@ -name: Handle Push to Main - -on: - push: - branches: [ main ] - -jobs: - docker: - runs-on: ubuntu-latest - name: Build And Push to Docker Hub - steps: - - name: Checkout Repository - uses: actions/checkout@v3 - with: - ref: ${{ github.event.pull_request.head.ref }} - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build and push SignLab - uses: docker/build-push-action@v3 - with: - push: true - tags: hicsail/signlab:unstable - build-args: | - PRODUCTION="false" - GRAPHQL_ENDPOINT=${{ secrets.GRAPHQL_ENDPOINT }} - ASL_LEX_ID=${{ secrets.ASL_LEX_ID }} - - - name: Build and push Gateway - uses: docker/build-push-action@v3 - with: - context: ./gateway - push: true - tags: hicsail/signlab-gateway:unstable - - - name: Push to Staging - uses: fjogeleit/http-request-action@v1 - with: - method: 'POST' - url: ${{ secrets.PORTAINER_WEBHOOK }} - preventFailureOnNoResponse: true diff --git a/.github/workflows/on-release.yaml b/.github/workflows/on-release.yaml deleted file mode 100644 index 7655b0aa..00000000 --- a/.github/workflows/on-release.yaml +++ /dev/null @@ -1,51 +0,0 @@ -name: Release Actions - -on: - release: - types: [published] - -jobs: - docker: - runs-on: ubuntu-latest - name: Build And Push to Docker Hub - steps: - - name: Checkout Repository - uses: actions/checkout@v3 - with: - ref: ${{ github.event.pull_request.head.ref }} - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build and push SignLab - uses: docker/build-push-action@v3 - with: - push: true - tags: hicsail/signlab:${{github.ref_name}},hicsail/signlab:latest - build-args: | - PRODUCTION="true" - GRAPHQL_ENDPOINT=${{ secrets.GRAPHQL_ENDPOINT_PRODUCTION }} - ASL_LEX_ID=${{ secrets.ASL_LEX_ID_PRODUCTION }} - - - name: Build and push Gateway - uses: docker/build-push-action@v3 - with: - context: ./gateway - push: true - tags: hicsail/signlab-gateway:${{github.ref_name}},hicsail/signlab-gateway:latest - - - name: Push to Prod - uses: fjogeleit/http-request-action@v1 - with: - method: 'POST' - url: ${{ secrets.PORTAINER_WEBHOOK_PROD }} - preventFailureOnNoResponse: true diff --git a/.github/workflows/server.yaml b/.github/workflows/server.yaml new file mode 100644 index 00000000..ba66219d --- /dev/null +++ b/.github/workflows/server.yaml @@ -0,0 +1,90 @@ +name: server +on: + workflow_dispatch: + push: + paths: + - 'server/**' + branches: + - main + tags: + - "v*.*.*" + pull_request: + paths: + - 'server/**' + branches: + - main + +jobs: + lint: + runs-on: ubuntu-latest + name: Check for Linting Errors + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.ref }} + + - name: Setup NodeJS + uses: actions/setup-node@v3 + with: + node-version: 18 + + - name: NPM Install + run: npm install + shell: bash + + - name: Check for Linting Issues + run: npm run lint --workspace=server + + - name: Check for Prettier Issues + run: npm run prettier --workspace=server + + - name: Run unit tests + run: npm run test --workspace=server + + docker-build: + runs-on: ubuntu-latest + name: Docker Build (and Deploy) + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v2 + if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build & Push Docker Test Build + uses: docker/build-push-action@v4 + with: + context: . + file: server/Dockerfile + push: ${{ github.event_name != 'pull_request' }} + tags: hicsail/signlab-server:unstable + + - name: Build & Push Docker Production Build + uses: docker/build-push-action@v4 + if: startsWith(github.ref, 'refs/tags/v') + with: + context: . + file: server/Dockerfile + push: ${{ github.event_name != 'pull_request' }} + tags: hicsail/signlab-server:latest,hicsail/signlab-server:${{github.ref_name}} + + - name: Push to Staging + uses: fjogeleit/http-request-action@v1 + if: github.ref == 'refs/heads/main' + with: + method: "POST" + url: ${{ secrets.PORTAINER_WEBHOOK }} + preventFailureOnNoResponse: true + + - name: Push to Production + uses: fjogeleit/http-request-action@v1 + if: startsWith(github.ref, 'refs/tags/v') + with: + method: "POST" + url: ${{ secrets.PORTAINER_WEBHOOK_PRODUCTION }} + preventFailureOnNoResponse: true diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index e093b799..00000000 --- a/Dockerfile +++ /dev/null @@ -1,22 +0,0 @@ -FROM node:18-alpine AS signlab - -ARG PRODUCTION -ARG GRAPHQL_ENDPOINT -ARG ASL_LEX_ID - -ENV PRODUCTION ${PRODUCTION} -ENV GRAPHQL_ENDPOINT ${GRAPHQL_ENDPOINT} -ENV ASL_LEX_ID ${ASL_LEX_ID} - -# Copy over the source -WORKDIR /usr/src/signlab -COPY . . - -# Install required packages and build for prod -RUN apk update && \ - npm install && \ - npm run build:prod - -EXPOSE 3000 - -CMD npm run start:prod diff --git a/client/.dockerignore b/client/.dockerignore new file mode 100644 index 00000000..3c3629e6 --- /dev/null +++ b/client/.dockerignore @@ -0,0 +1 @@ +node_modules diff --git a/client/Dockerfile b/client/Dockerfile new file mode 100644 index 00000000..87e300dc --- /dev/null +++ b/client/Dockerfile @@ -0,0 +1,30 @@ +## Angular Builder +FROM node:18-alpine as builder + +# NOTE: Building has to take place at the top level due to the use of the +# shared package. In the future, when the shared package is no longer +# needed, building can take place directly in the client package +WORKDIR /app/ +COPY . . + +# Take in build arguments +ARG PRODUCTION +ARG GRAPHQL_ENDPOINT +ARG ASL_LEX_ID + +ENV PRODUCTION ${PRODUCTION} +ENV GRAPHQL_ENDPOINT ${GRAPHQL_ENDPOINT} +ENV ASL_LEX_ID ${ASL_LEX_ID} + +# Build code +RUN npm install --force &&\ + npm run build:prod + +## NGINX Server +FROM nginx:1.25-alpine + +COPY client/nginx.conf /etc/nginx/conf.d/default.conf + +COPY --from=builder /app/client/dist /usr/share/nginx/html + +CMD ["/bin/bash", "-c", "nginx -g 'daemon off;'"] diff --git a/client/angular.json b/client/angular.json index 40fb70ac..35f61611 100644 --- a/client/angular.json +++ b/client/angular.json @@ -18,7 +18,7 @@ "builder": "@angular-devkit/build-angular:browser", "options": { "allowedCommonJsDependencies": ["lodash", "joi", "ajv", "ajv-formats"], - "outputPath": "../dist/", + "outputPath": "./dist/", "index": "src/index.html", "main": "src/main.ts", "polyfills": "src/polyfills.ts", diff --git a/client/nginx.conf b/client/nginx.conf new file mode 100644 index 00000000..e161ebb0 --- /dev/null +++ b/client/nginx.conf @@ -0,0 +1,9 @@ +server { + listen 80; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + try_files $uri $uri/ /index.html =404; + } +} diff --git a/client/package.json b/client/package.json index 773b4299..79a43cd6 100644 --- a/client/package.json +++ b/client/package.json @@ -54,8 +54,13 @@ "@graphql-codegen/typescript": "^2.8.7", "@graphql-codegen/typescript-apollo-angular": "^3.5.6", "@graphql-codegen/typescript-operations": "^2.5.12", + "@typescript-eslint/eslint-plugin": "^5.47.0", + "@typescript-eslint/parser": "^5.47.0", "@types/jasmine": "~4.0.3", "@types/node": "^17.0.41", + "eslint": "^8.0.1", + "eslint-config-prettier": "^8.3.0", + "eslint-plugin-prettier": "^4.0.0", "jasmine-core": "~4.1.1", "jasmine-spec-reporter": "~7.0.0", "karma": "~6.3.20", diff --git a/client/src/app/core/services/http.service.ts b/client/src/app/core/services/http.service.ts index 2a93714e..cc14ea11 100644 --- a/client/src/app/core/services/http.service.ts +++ b/client/src/app/core/services/http.service.ts @@ -2,6 +2,7 @@ import { HttpClient, HttpHeaders, HttpContext, HttpParams } from '@angular/commo import { Injectable } from '@angular/core'; import { firstValueFrom } from 'rxjs'; import { TokenService } from './token.service'; +import { environment } from '../../../environments/environment'; /** * Interface which represents the values that can be stored in the options @@ -43,7 +44,7 @@ export class SignLabHttpClient { private baseUrl: string; constructor(private http: HttpClient, private tokenService: TokenService) { - const baseUrl = location.origin; + const baseUrl = environment.backendURL; // Ensure the url does not have a trailing '/' if (baseUrl.endsWith('/')) { this.baseUrl = baseUrl.substring(0, baseUrl.length - 1); diff --git a/client/src/environments/make-env.ts b/client/src/environments/make-env.ts index aaacf650..804e1084 100644 --- a/client/src/environments/make-env.ts +++ b/client/src/environments/make-env.ts @@ -18,7 +18,8 @@ const saveEnvironmentFile = async () => { export const environment = { production: '${process.env.PRODUCTION || false}', graphqlEndpoint: '${process.env.GRAPHQL_ENDPOINT}', - aslLexID: '${process.env.ASL_LEX_ID}' + aslLexID: '${process.env.ASL_LEX_ID}', + backendURL: '${process.env.BACKEND_URL}' }; `; diff --git a/deployment/docker-compose-prod.yml b/deployment/docker-compose-prod.yml index 06eb86ea..ad59a7fb 100644 --- a/deployment/docker-compose-prod.yml +++ b/deployment/docker-compose-prod.yml @@ -5,8 +5,8 @@ services: restart: "always" volumes: - signlab:/data/db - signlab: - image: hicsail/signlab:latest + signlab-server: + image: hicsail/signlab-server:latest restart: always depends_on: - mongo @@ -21,6 +21,12 @@ services: ports: ["6002:3000"] env_file: - ../stack.env + signlab-client: + image: hicsail/signlab-client:latest + restart: always + ports: ["6003:80"] + env_file: + - ../stack.env volumes: signlab: external: true diff --git a/deployment/docker-compose-staging.yml b/deployment/docker-compose-staging.yml index 48fbb9e3..811c0884 100644 --- a/deployment/docker-compose-staging.yml +++ b/deployment/docker-compose-staging.yml @@ -21,6 +21,12 @@ services: ports: ["6001:3002"] env_file: - ../stack.env + signlab-client: + image: hicsail/signlab-client:unstable + restart: always + ports: ["6003:80"] + env_file: + - ../stack.env volumes: signlab-staging: external: true diff --git a/gateway/Dockerfile b/gateway/Dockerfile index e4951775..4198a237 100644 --- a/gateway/Dockerfile +++ b/gateway/Dockerfile @@ -3,8 +3,7 @@ FROM node:18-alpine # Copy over the source WORKDIR /usr/src/gateway COPY . . -RUN apk update && \ - npm install && \ +RUN npm install && \ npm run build # Expose the endpoint diff --git a/package-lock.json b/package-lock.json index d522be35..32e223b7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3491,7 +3491,7 @@ } }, "gateway": { - "name": "@hicsail/nist-gateway", + "name": "@hicsail/signlab-gateway", "version": "0.0.1", "license": "UNLICENSED", "dependencies": { @@ -3501,6 +3501,7 @@ "@nestjs/config": "^2.3.1", "@nestjs/core": "^9.0.0", "@nestjs/platform-express": "^9.0.0", + "@nestjs/serve-static": "^4.0.0", "apollo-server-express": "^3.12.0", "graphql": "^16.6.0", "reflect-metadata": "^0.1.13", @@ -3783,6 +3784,37 @@ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.3.tgz", "integrity": "sha512-mSxlJJwl3BMEQCUNnxXBU9jP4JBktcEGhURcPR6VQVlnP0FdDEsIaz0C35dXNGLyRfrATNofF0F5p2KPxQgB+w==" }, + "gateway/node_modules/@nestjs/serve-static": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@nestjs/serve-static/-/serve-static-4.0.0.tgz", + "integrity": "sha512-8cTrNV2ngdHIjiLNsXePnw0+KY1ThrZGz/WeyAG5gIvmZNDbnZBOrPoYlKL+MOzlXlQStxR5jKLYmn+nJeoncQ==", + "dependencies": { + "path-to-regexp": "0.2.5" + }, + "peerDependencies": { + "@fastify/static": "^6.5.0", + "@nestjs/common": "^9.0.0 || ^10.0.0", + "@nestjs/core": "^9.0.0 || ^10.0.0", + "express": "^4.18.1", + "fastify": "^4.7.0" + }, + "peerDependenciesMeta": { + "@fastify/static": { + "optional": true + }, + "express": { + "optional": true + }, + "fastify": { + "optional": true + } + } + }, + "gateway/node_modules/@nestjs/serve-static/node_modules/path-to-regexp": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.2.5.tgz", + "integrity": "sha512-l6qtdDPIkmAmzEO6egquYDfqQGPMRNGjYtrU13HAXb3YSRrt7HSb1sJY0pKp6o2bAa86tSB6iwaW2JbthPKr7Q==" + }, "gateway/node_modules/@nestjs/testing": { "version": "9.4.3", "resolved": "https://registry.npmjs.org/@nestjs/testing/-/testing-9.4.3.tgz", @@ -10902,7 +10934,7 @@ "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0" } }, - "node_modules/@hicsail/nist-gateway": { + "node_modules/@hicsail/signlab-gateway": { "resolved": "gateway", "link": true }, @@ -33744,7 +33776,7 @@ "integrity": "sha512-NQ17ii0rK1b34VZonlmT2QMJFI70m0TRwbknO/ihlbatXyaktDhN/98vBiUU6kNBPljqGqyIrl2T4nY2RpFANg==", "requires": {} }, - "@hicsail/nist-gateway": { + "@hicsail/signlab-gateway": { "version": "file:gateway", "requires": { "@apollo/gateway": "^2.3.5", @@ -33755,6 +33787,7 @@ "@nestjs/core": "^9.0.0", "@nestjs/platform-express": "^9.0.0", "@nestjs/schematics": "^9.0.0", + "@nestjs/serve-static": "*", "@nestjs/testing": "^9.0.0", "@types/express": "^4.17.13", "@types/jest": "28.1.8", @@ -33909,6 +33942,21 @@ } } }, + "@nestjs/serve-static": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@nestjs/serve-static/-/serve-static-4.0.0.tgz", + "integrity": "sha512-8cTrNV2ngdHIjiLNsXePnw0+KY1ThrZGz/WeyAG5gIvmZNDbnZBOrPoYlKL+MOzlXlQStxR5jKLYmn+nJeoncQ==", + "requires": { + "path-to-regexp": "0.2.5" + }, + "dependencies": { + "path-to-regexp": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.2.5.tgz", + "integrity": "sha512-l6qtdDPIkmAmzEO6egquYDfqQGPMRNGjYtrU13HAXb3YSRrt7HSb1sJY0pKp6o2bAa86tSB6iwaW2JbthPKr7Q==" + } + } + }, "@nestjs/testing": { "version": "9.4.3", "resolved": "https://registry.npmjs.org/@nestjs/testing/-/testing-9.4.3.tgz", @@ -46812,7 +46860,7 @@ "server": { "version": "file:server", "requires": { - "@apollo/subgraph": "*", + "@apollo/subgraph": "^2.4.12", "@aws-sdk/client-s3": "^3.161.0", "@google-cloud/storage": "^6.4.1", "@nestjs/apollo": "^10.1.7", diff --git a/server/Dockerfile b/server/Dockerfile new file mode 100644 index 00000000..dfe9eccc --- /dev/null +++ b/server/Dockerfile @@ -0,0 +1,13 @@ +FROM node:18-alpine AS signlab + +# Copy over the source +WORKDIR /app/ +COPY . . + +# Install required packages and build for prod +RUN npm install && \ + npm run build:prod + +EXPOSE 3000 + +CMD npm run start:prod --workspace=server diff --git a/server/package.json b/server/package.json index 101d5d86..6a01fbc0 100644 --- a/server/package.json +++ b/server/package.json @@ -34,7 +34,6 @@ "@nestjs/mongoose": "^9.1.1", "@nestjs/passport": "^9.0.0", "@nestjs/platform-express": "^8.4.7", - "@nestjs/serve-static": "^2.2.2", "@sniptt/monads": "^0.5.10", "@types/unzipper": "^0.10.5", "apollo-server-express": "^3.11.1", @@ -58,6 +57,8 @@ "@nestjs/schematics": "^8.0.0", "@nestjs/testing": "^8.0.0", "@types/bcrypt": "^5.0.0", + "@typescript-eslint/eslint-plugin": "^5.47.0", + "@typescript-eslint/parser": "^5.47.0", "@types/express": "^4.17.13", "@types/express-session": "^1.17.5", "@types/jest": "27.5.0", @@ -65,6 +66,9 @@ "@types/node": "^16.0.0", "@types/passport-jwt": "^3.0.6", "@types/supertest": "^2.0.11", + "eslint": "^8.0.1", + "eslint-config-prettier": "^8.3.0", + "eslint-plugin-prettier": "^4.0.0", "jest": "28.0.3", "prettier": "^2.3.2", "source-map-support": "^0.5.20", diff --git a/server/src/app.module.ts b/server/src/app.module.ts index 4ea098a3..7f38b20c 100644 --- a/server/src/app.module.ts +++ b/server/src/app.module.ts @@ -2,7 +2,6 @@ import { join } from 'path'; // Modules import { Module } from '@nestjs/common'; -import { ServeStaticModule } from '@nestjs/serve-static'; import { MongooseModule } from '@nestjs/mongoose'; import { ConfigModule } from '@nestjs/config'; @@ -44,10 +43,6 @@ if (process.env.NODE_ENV) { @Module({ imports: [ configModule, - ServeStaticModule.forRoot({ - rootPath: join(__dirname, '../../dist/'), - exclude: ['/api*', '/graphql'] - }), MongooseModule.forRootAsync({ imports: [ConfigModule], useFactory: async (configService: ConfigService) => ({