Browse Source

Updates with Dockerfile and tweaks for db persistence

unsubscribe-mute
Matthew Raymer 1 year ago
parent
commit
bcb636c150
  1. 1
      .gitignore
  2. 5
      Dockerfile
  3. 3
      build.sh
  4. 112
      package.json
  5. 2
      src/db.ts

1
.gitignore

@ -2,3 +2,4 @@
node_modules node_modules
build build
web_push web_push
data

5
Dockerfile

@ -1,6 +1,6 @@
FROM node:18.17.1-alpine3.17 FROM node:18.17.1-alpine3.17
RUN mkdir -p /usr/src/app RUN mkdir -p /usr/src/app/data
WORKDIR /usr/src/app WORKDIR /usr/src/app
COPY package*.json ./ COPY package*.json ./
@ -9,8 +9,9 @@ COPY .eslintrc.json ./
COPY src ./src COPY src ./src
RUN npm install RUN npm install
RUN npm run build RUN npm run build
EXPOSE 3000 EXPOSE 3000
CMD [ "npm", "start" ] CMD [ "npm", "start" ]

3
build.sh

@ -0,0 +1,3 @@
#!/bin/bash
docker build . -t endorser-push-server:1.0 --no-cache

112
package.json

@ -1,58 +1,58 @@
{ {
"name": "node-typescript-boilerplate", "name": "node-typescript-boilerplate",
"version": "0.0.0", "version": "0.0.0",
"description": "Minimalistic boilerplate to quick-start Node.js development in TypeScript.", "description": "Minimalistic boilerplate to quick-start Node.js development in TypeScript.",
"type": "module", "type": "module",
"engines": { "engines": {
"node": ">= 18.12 <19" "node": ">= 18.12 <19"
}, },
"devDependencies": { "devDependencies": {
"@types/body-parser": "^1.19.2", "@types/body-parser": "^1.19.2",
"@types/express": "^4.17.17", "@types/express": "^4.17.17",
"@types/jest": "~29.5", "@types/jest": "~29.5",
"@types/jsonwebtoken": "^9.0.2", "@types/jsonwebtoken": "^9.0.2",
"@types/node": "~20", "@types/node": "~20",
"@types/sqlite3": "^3.1.8", "@types/sqlite3": "^3.1.8",
"@typescript-eslint/eslint-plugin": "^6.4.0", "@typescript-eslint/eslint-plugin": "^6.4.0",
"@typescript-eslint/parser": "^6.4.0", "@typescript-eslint/parser": "^6.4.0",
"eslint": "~8.47", "eslint": "~8.47",
"eslint-config-prettier": "~9.0", "eslint-config-prettier": "~9.0",
"eslint-plugin-jest": "~27.2", "eslint-plugin-jest": "~27.2",
"jest": "~29.6", "jest": "~29.6",
"prettier": "~3.0", "prettier": "~3.0",
"rimraf": "~5.0", "rimraf": "~5.0",
"ts-api-utils": "~1.0", "ts-api-utils": "~1.0",
"ts-jest": "~29.1", "ts-jest": "~29.1",
"typescript": "~5.1" "typescript": "~5.1"
}, },
"scripts": { "scripts": {
"start": "node build/src/main.js", "start": "node build/src/main.js",
"clean": "rimraf coverage build tmp", "clean": "rimraf coverage build tmp",
"prebuild": "npm run lint", "prebuild": "npm run lint",
"build": "tsc -p tsconfig.json", "build": "tsc -p tsconfig.json",
"build:watch": "tsc -w -p tsconfig.json", "build:watch": "tsc -w -p tsconfig.json",
"build:release": "npm run clean && tsc -p tsconfig.release.json", "build:release": "npm run clean && tsc -p tsconfig.release.json",
"lint": "eslint . --ext .ts --ext .mts", "lint": "eslint . --ext .ts --ext .mts",
"test": "jest --coverage", "test": "jest --coverage",
"prettier": "prettier --config .prettierrc --write .", "prettier": "prettier --config .prettierrc --write .",
"test:watch": "jest --watch" "test:watch": "jest --watch"
}, },
"author": "Jakub Synowiec <jsynowiec@users.noreply.github.com>", "author": "Jakub Synowiec <jsynowiec@users.noreply.github.com>",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"body-parser": "^1.20.2", "body-parser": "^1.20.2",
"elliptic": "^6.5.4", "elliptic": "^6.5.4",
"express": "^4.18.2", "express": "^4.18.2",
"http_ece": "^1.1.0", "http_ece": "^1.1.0",
"jsonwebtoken": "^9.0.1", "jsonwebtoken": "^9.0.1",
"node-fetch": "^3.3.2", "node-fetch": "^3.3.2",
"npm-check-updates": "16.11.1", "npm-check-updates": "16.11.1",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"sqlite3": "^5.1.6", "sqlite3": "^5.1.6",
"tslib": "~2.6", "tslib": "~2.6",
"typeorm": "^0.3.17" "typeorm": "^0.3.17"
}, },
"volta": { "volta": {
"node": "18.12.1" "node": "18.12.1"
} }
} }

2
src/db.ts

@ -15,7 +15,7 @@ class DBService {
private constructor() { private constructor() {
this.dataSource = new DataSource({ this.dataSource = new DataSource({
type: "sqlite", type: "sqlite",
database: "push_server", database: "data/push_server",
entities: [VapidKeys, Subscription], entities: [VapidKeys, Subscription],
synchronize: true synchronize: true
}); });

Loading…
Cancel
Save