From bcb636c1500572b052f13a7b570025c0501d202c Mon Sep 17 00:00:00 2001 From: Matthew Raymer Date: Sun, 10 Sep 2023 08:50:26 -0400 Subject: [PATCH] Updates with Dockerfile and tweaks for db persistence --- .gitignore | 1 + Dockerfile | 5 ++- build.sh | 3 ++ package.json | 112 +++++++++++++++++++++++++-------------------------- src/db.ts | 2 +- 5 files changed, 64 insertions(+), 59 deletions(-) create mode 100755 build.sh diff --git a/.gitignore b/.gitignore index e175d24..00cb1cb 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ node_modules build web_push +data \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 72bd375..4412a9d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM node:18.17.1-alpine3.17 -RUN mkdir -p /usr/src/app +RUN mkdir -p /usr/src/app/data WORKDIR /usr/src/app COPY package*.json ./ @@ -9,8 +9,9 @@ COPY .eslintrc.json ./ COPY src ./src RUN npm install + RUN npm run build EXPOSE 3000 -CMD [ "npm", "start" ] +CMD [ "npm", "start" ] \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..5a76bba --- /dev/null +++ b/build.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +docker build . -t endorser-push-server:1.0 --no-cache diff --git a/package.json b/package.json index c37a533..eb04580 100644 --- a/package.json +++ b/package.json @@ -1,58 +1,58 @@ { - "name": "node-typescript-boilerplate", - "version": "0.0.0", - "description": "Minimalistic boilerplate to quick-start Node.js development in TypeScript.", - "type": "module", - "engines": { - "node": ">= 18.12 <19" - }, - "devDependencies": { - "@types/body-parser": "^1.19.2", - "@types/express": "^4.17.17", - "@types/jest": "~29.5", - "@types/jsonwebtoken": "^9.0.2", - "@types/node": "~20", - "@types/sqlite3": "^3.1.8", - "@typescript-eslint/eslint-plugin": "^6.4.0", - "@typescript-eslint/parser": "^6.4.0", - "eslint": "~8.47", - "eslint-config-prettier": "~9.0", - "eslint-plugin-jest": "~27.2", - "jest": "~29.6", - "prettier": "~3.0", - "rimraf": "~5.0", - "ts-api-utils": "~1.0", - "ts-jest": "~29.1", - "typescript": "~5.1" - }, - "scripts": { - "start": "node build/src/main.js", - "clean": "rimraf coverage build tmp", - "prebuild": "npm run lint", - "build": "tsc -p tsconfig.json", - "build:watch": "tsc -w -p tsconfig.json", - "build:release": "npm run clean && tsc -p tsconfig.release.json", - "lint": "eslint . --ext .ts --ext .mts", - "test": "jest --coverage", - "prettier": "prettier --config .prettierrc --write .", - "test:watch": "jest --watch" - }, - "author": "Jakub Synowiec ", - "license": "Apache-2.0", - "dependencies": { - "body-parser": "^1.20.2", - "elliptic": "^6.5.4", - "express": "^4.18.2", - "http_ece": "^1.1.0", - "jsonwebtoken": "^9.0.1", - "node-fetch": "^3.3.2", - "npm-check-updates": "16.11.1", - "reflect-metadata": "^0.1.13", - "sqlite3": "^5.1.6", - "tslib": "~2.6", - "typeorm": "^0.3.17" - }, - "volta": { - "node": "18.12.1" - } + "name": "node-typescript-boilerplate", + "version": "0.0.0", + "description": "Minimalistic boilerplate to quick-start Node.js development in TypeScript.", + "type": "module", + "engines": { + "node": ">= 18.12 <19" + }, + "devDependencies": { + "@types/body-parser": "^1.19.2", + "@types/express": "^4.17.17", + "@types/jest": "~29.5", + "@types/jsonwebtoken": "^9.0.2", + "@types/node": "~20", + "@types/sqlite3": "^3.1.8", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "~8.47", + "eslint-config-prettier": "~9.0", + "eslint-plugin-jest": "~27.2", + "jest": "~29.6", + "prettier": "~3.0", + "rimraf": "~5.0", + "ts-api-utils": "~1.0", + "ts-jest": "~29.1", + "typescript": "~5.1" + }, + "scripts": { + "start": "node build/src/main.js", + "clean": "rimraf coverage build tmp", + "prebuild": "npm run lint", + "build": "tsc -p tsconfig.json", + "build:watch": "tsc -w -p tsconfig.json", + "build:release": "npm run clean && tsc -p tsconfig.release.json", + "lint": "eslint . --ext .ts --ext .mts", + "test": "jest --coverage", + "prettier": "prettier --config .prettierrc --write .", + "test:watch": "jest --watch" + }, + "author": "Jakub Synowiec ", + "license": "Apache-2.0", + "dependencies": { + "body-parser": "^1.20.2", + "elliptic": "^6.5.4", + "express": "^4.18.2", + "http_ece": "^1.1.0", + "jsonwebtoken": "^9.0.1", + "node-fetch": "^3.3.2", + "npm-check-updates": "16.11.1", + "reflect-metadata": "^0.1.13", + "sqlite3": "^5.1.6", + "tslib": "~2.6", + "typeorm": "^0.3.17" + }, + "volta": { + "node": "18.12.1" + } } diff --git a/src/db.ts b/src/db.ts index cc28188..63df692 100644 --- a/src/db.ts +++ b/src/db.ts @@ -15,7 +15,7 @@ class DBService { private constructor() { this.dataSource = new DataSource({ type: "sqlite", - database: "push_server", + database: "data/push_server", entities: [VapidKeys, Subscription], synchronize: true });