This commit is contained in:
parent
b70b80bbea
commit
8d98cf8b66
10
.drone.yml
Normal file
10
.drone.yml
Normal file
@ -0,0 +1,10 @@
|
||||
kind: pipeline
|
||||
name: default
|
||||
|
||||
steps:
|
||||
- name: docker build
|
||||
image: plugins/docker
|
||||
settings:
|
||||
repo: registry:5000/appreports
|
||||
dockerfile: dockerfile
|
||||
insecure: true
|
12
dockerfile
Normal file
12
dockerfile
Normal file
@ -0,0 +1,12 @@
|
||||
FROM node:lts-alpine
|
||||
|
||||
RUN mkdir appreports
|
||||
COPY ./* /appreports
|
||||
WORKDIR /appreports
|
||||
|
||||
RUN yarn; \
|
||||
yarn compile;
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
ENTRYPOINT ["node", "index.js"]
|
13
index.js
13
index.js
@ -19,6 +19,7 @@ const api = require ('./lib/api');
|
||||
const http_proxy = require ('express-http-proxy');
|
||||
const history_fallback = require ('connect-history-api-fallback');
|
||||
const fs = require ('fs');
|
||||
const { argv } = require ('yargs');
|
||||
|
||||
const salt = crypto.create_salt ();
|
||||
const hash = crypto.hash_sha512 ('asd', salt);
|
||||
@ -29,9 +30,12 @@ const user = {
|
||||
password: password_helper.hash (hash)
|
||||
};
|
||||
|
||||
const is_dev = argv.dev;
|
||||
|
||||
(async () => {
|
||||
fs.unlinkSync ('db.sqlite');
|
||||
await db.init (true);
|
||||
if (fs.existsSync ('db.sqlite'))
|
||||
fs.unlinkSync ('db.sqlite');
|
||||
await db.init (is_dev);
|
||||
|
||||
const app = express ();
|
||||
app.use (cookie_parser ());
|
||||
@ -47,7 +51,10 @@ const user = {
|
||||
|
||||
app.use (api);
|
||||
app.use (history_fallback ());
|
||||
app.use (http_proxy ('localhost:8080'));
|
||||
if (is_dev)
|
||||
app.use (http_proxy ('localhost:8080'));
|
||||
else
|
||||
app.use (express.static ('dist'));
|
||||
|
||||
app.listen (3000, () => {
|
||||
console.log ('listening on 3000');
|
||||
|
@ -29,7 +29,7 @@ module.exports = async (req, res) => {
|
||||
}
|
||||
|
||||
const { message, data, timestamp } = log;
|
||||
await db.log.insert (app_id, message, data, timestamp);
|
||||
await db.log.insert (app_id, message, JSON.stringify (data), timestamp);
|
||||
|
||||
res.status (http.status_created)
|
||||
.end ();
|
||||
|
@ -23,6 +23,8 @@ async function init (use_fake_seed) {
|
||||
await db.migrate.latest ();
|
||||
if (use_fake_seed)
|
||||
await db.seed.run ({ specific: 'fake.js' });
|
||||
else
|
||||
await db.seed.run ({ specific: 'prod.js' });
|
||||
}
|
||||
|
||||
function get_db () {
|
||||
|
10
package.json
10
package.json
@ -5,7 +5,7 @@
|
||||
"scripts": {
|
||||
"lint": "eslint . --ext .js,.jsx,.ts,.tsx,.vue,.mjs",
|
||||
"test": "echo \"no test\"",
|
||||
"compile": "tsc --allowJs --declaration --emitDeclarationOnly index.js",
|
||||
"compile": "vue-cli-service build",
|
||||
"serve": "vue-cli-service serve"
|
||||
},
|
||||
"dependencies": {
|
||||
@ -31,7 +31,8 @@
|
||||
"vue": "^2.6.11",
|
||||
"vue-chartjs": "^3.5.0",
|
||||
"vue-router": "^3.2.0",
|
||||
"vuex": "^3.4.0"
|
||||
"vuex": "^3.4.0",
|
||||
"yargs": "^15.4.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sapphirecode/eslint-config": "^2.1.16",
|
||||
@ -48,5 +49,8 @@
|
||||
},
|
||||
"license": "GPL-3.0-or-later",
|
||||
"main": "index.js",
|
||||
"author": "Timo Hocker <timo@scode.ovh>"
|
||||
"author": {
|
||||
"name": "Timo Hocker",
|
||||
"email": "timo@scode.ovh"
|
||||
}
|
||||
}
|
@ -35,11 +35,6 @@ function create_log (index, simplex) {
|
||||
}
|
||||
|
||||
async function seed (knex) {
|
||||
await knex ('log')
|
||||
.del ();
|
||||
await knex ('app')
|
||||
.del ();
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
console.log ('creating seeds');
|
||||
for (let i = 0; i < 5; i++)
|
||||
|
19
seeds/prod.js
Normal file
19
seeds/prod.js
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright (C) Sapphirecode - All Rights Reserved
|
||||
* This file is part of appreports which is released under GPL-3.0-or-later.
|
||||
* See file 'LICENSE' for full license details.
|
||||
* Created by Timo Hocker <timo@scode.ovh>, August 2020
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
async function seed (knex) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log ('creating prod seeds');
|
||||
await knex ('app')
|
||||
.insert (
|
||||
{ name: 'test app' }
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = { seed };
|
@ -9427,7 +9427,7 @@ yargs@^13.3.2:
|
||||
y18n "^4.0.0"
|
||||
yargs-parser "^13.1.2"
|
||||
|
||||
yargs@^15.0.0:
|
||||
yargs@^15.0.0, yargs@^15.4.1:
|
||||
version "15.4.1"
|
||||
resolved "https://registry.yarnpkg.com/yargs/-/yargs-15.4.1.tgz#0d87a16de01aee9d8bec2bfbf74f67851730f4f8"
|
||||
integrity sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==
|
||||
|
Loading…
x
Reference in New Issue
Block a user