Skip to content

Commit 74010ac

Browse files
authored
Merge pull request #543 from jc21/develop
v2.4.0
2 parents f9b8d76 + 7c7d255 commit 74010ac

40 files changed

+4912
-4439
lines changed
File renamed without changes.

.jenkins/config-sqlite.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"database": {
3+
"engine": "knex-native",
4+
"knex": {
5+
"client": "sqlite3",
6+
"connection": {
7+
"filename": "/data/database.sqlite"
8+
}
9+
}
10+
}
11+
}

.version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.3.1
1+
2.4.0

Jenkinsfile

+34-7
Original file line numberDiff line numberDiff line change
@@ -83,23 +83,49 @@ pipeline {
8383
'''
8484
}
8585
}
86-
stage('Test') {
86+
stage('Integration Tests Sqlite') {
8787
steps {
8888
// Bring up a stack
89-
sh 'docker-compose up -d fullstack'
90-
sh './scripts/wait-healthy $(docker-compose ps -q fullstack) 120'
89+
sh 'docker-compose up -d fullstack-sqlite'
90+
sh './scripts/wait-healthy $(docker-compose ps -q fullstack-sqlite) 120'
9191

9292
// Run tests
9393
sh 'rm -rf test/results'
94-
sh 'docker-compose up cypress'
94+
sh 'docker-compose up cypress-sqlite'
9595
// Get results
96-
sh 'docker cp -L "$(docker-compose ps -q cypress):/results" test/'
96+
sh 'docker cp -L "$(docker-compose ps -q cypress-sqlite):/test/results" test/'
9797
}
9898
post {
9999
always {
100100
// Dumps to analyze later
101101
sh 'mkdir -p debug'
102-
sh 'docker-compose logs fullstack | gzip > debug/docker_fullstack.log.gz'
102+
sh 'docker-compose logs fullstack-sqlite | gzip > debug/docker_fullstack_sqlite.log.gz'
103+
sh 'docker-compose logs db | gzip > debug/docker_db.log.gz'
104+
// Cypress videos and screenshot artifacts
105+
dir(path: 'test/results') {
106+
archiveArtifacts allowEmptyArchive: true, artifacts: '**/*', excludes: '**/*.xml'
107+
}
108+
junit 'test/results/junit/*'
109+
}
110+
}
111+
}
112+
stage('Integration Tests Mysql') {
113+
steps {
114+
// Bring up a stack
115+
sh 'docker-compose up -d fullstack-mysql'
116+
sh './scripts/wait-healthy $(docker-compose ps -q fullstack-mysql) 120'
117+
118+
// Run tests
119+
sh 'rm -rf test/results'
120+
sh 'docker-compose up cypress-mysql'
121+
// Get results
122+
sh 'docker cp -L "$(docker-compose ps -q cypress-mysql):/test/results" test/'
123+
}
124+
post {
125+
always {
126+
// Dumps to analyze later
127+
sh 'mkdir -p debug'
128+
sh 'docker-compose logs fullstack-mysql | gzip > debug/docker_fullstack_mysql.log.gz'
103129
sh 'docker-compose logs db | gzip > debug/docker_db.log.gz'
104130
// Cypress videos and screenshot artifacts
105131
dir(path: 'test/results') {
@@ -136,8 +162,9 @@ pipeline {
136162
}
137163
steps {
138164
withCredentials([usernamePassword(credentialsId: 'jc21-dockerhub', passwordVariable: 'dpass', usernameVariable: 'duser')]) {
165+
// Docker Login
139166
sh "docker login -u '${duser}' -p '${dpass}'"
140-
// Buildx with push
167+
// Buildx with push from cache
141168
sh "./scripts/buildx --push ${BUILDX_PUSH_TAGS}"
142169
}
143170
}

README.md

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<p align="center">
22
<img src="https://nginxproxymanager.com/github.png">
33
<br><br>
4-
<img src="https://img.shields.io/badge/version-2.3.1-green.svg?style=for-the-badge">
4+
<img src="https://img.shields.io/badge/version-2.4.0-green.svg?style=for-the-badge">
55
<a href="https://hub.docker.com/repository/docker/jc21/nginx-proxy-manager">
66
<img src="https://img.shields.io/docker/stars/jc21/nginx-proxy-manager.svg?style=for-the-badge">
77
</a>
@@ -155,14 +155,24 @@ Special thanks to the following contributors:
155155
<br /><sub><b>OhHeyAlan</b></sub>
156156
</a>
157157
</td>
158-
</tr>
159-
<tr>
160158
<td align="center">
161159
<a href="https://github.com/dogmatic69">
162160
<img src="https://avatars2.githubusercontent.com/u/94674?s=460&u=ca7647de53145c6283b6373ade5dc94ba99347db&v=4" width="80px;" alt=""/>
163161
<br /><sub><b>Carl Sutton</b></sub>
164162
</a>
165163
</td>
164+
<td align="center">
165+
<a href="https://github.com/tg44">
166+
<img src="https://avatars0.githubusercontent.com/u/31839?s=460&u=ad32f4cadfef5e5fb09cdfa4b7b7b36a99ba6811&v=4" width="80px;" alt=""/>
167+
<br /><sub><b>Gergő Törcsvári</b></sub>
168+
</a>
169+
</td>
170+
<td align="center">
171+
<a href="https://github.com/vrenjith">
172+
<img src="https://avatars3.githubusercontent.com/u/2093241?s=460&u=96ce93a9bebabdd0a60a2dc96cd093a41d5edaba&v=4" width="80px;" alt=""/>
173+
<br /><sub><b>vrenjith</b></sub>
174+
</a>
175+
</td>
166176
</tr>
167177
</table>
168178
<!-- markdownlint-enable -->

backend/config/sqlite-test-db.json

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"database": {
3+
"engine": "knex-native",
4+
"knex": {
5+
"client": "sqlite3",
6+
"connection": {
7+
"filename": "/app/backend/config/mydb.sqlite"
8+
},
9+
"pool": {
10+
"min": 0,
11+
"max": 1,
12+
"createTimeoutMillis": 3000,
13+
"acquireTimeoutMillis": 30000,
14+
"idleTimeoutMillis": 30000,
15+
"reapIntervalMillis": 1000,
16+
"createRetryIntervalMillis": 100,
17+
"propagateCreateError": false
18+
},
19+
"migrations": {
20+
"tableName": "migrations",
21+
"stub": "src/backend/lib/migrate_template.js",
22+
"directory": "src/backend/migrations"
23+
}
24+
}
25+
}
26+
}

backend/db.js

+21-13
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,27 @@ if (!config.has('database')) {
44
throw new Error('Database config does not exist! Please read the instructions: https://github.com/jc21/nginx-proxy-manager/blob/master/doc/INSTALL.md');
55
}
66

7-
let data = {
8-
client: config.database.engine,
9-
connection: {
10-
host: config.database.host,
11-
user: config.database.user,
12-
password: config.database.password,
13-
database: config.database.name,
14-
port: config.database.port
15-
},
16-
migrations: {
17-
tableName: 'migrations'
18-
}
19-
};
7+
function generateDbConfig() {
8+
if (config.database.engine === 'knex-native') {
9+
return config.database.knex;
10+
} else
11+
return {
12+
client: config.database.engine,
13+
connection: {
14+
host: config.database.host,
15+
user: config.database.user,
16+
password: config.database.password,
17+
database: config.database.name,
18+
port: config.database.port
19+
},
20+
migrations: {
21+
tableName: 'migrations'
22+
}
23+
};
24+
}
25+
26+
27+
let data = generateDbConfig();
2028

2129
if (typeof config.database.version !== 'undefined') {
2230
data.version = config.database.version;

backend/migrations/20190227065017_settings.js

-16
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,6 @@ exports.up = function (knex/*, Promise*/) {
2222
})
2323
.then(() => {
2424
logger.info('[' + migrate_name + '] setting Table created');
25-
26-
// TODO: add settings
27-
let settingModel = require('../models/setting');
28-
29-
return settingModel
30-
.query()
31-
.insert({
32-
id: 'default-site',
33-
name: 'Default Site',
34-
description: 'What to show when Nginx is hit with an unknown Host',
35-
value: 'congratulations',
36-
meta: {}
37-
});
38-
})
39-
.then(() => {
40-
logger.info('[' + migrate_name + '] Default settings added');
4125
});
4226
};
4327

backend/models/access_list.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ const Model = require('objection').Model;
66
const User = require('./user');
77
const AccessListAuth = require('./access_list_auth');
88
const AccessListClient = require('./access_list_client');
9+
const now = require('./now_helper');
910

1011
Model.knex(db);
1112

1213
class AccessList extends Model {
1314
$beforeInsert () {
14-
this.created_on = Model.raw('NOW()');
15-
this.modified_on = Model.raw('NOW()');
15+
this.created_on = now();
16+
this.modified_on = now();
1617

1718
// Default for meta
1819
if (typeof this.meta === 'undefined') {
@@ -21,7 +22,7 @@ class AccessList extends Model {
2122
}
2223

2324
$beforeUpdate () {
24-
this.modified_on = Model.raw('NOW()');
25+
this.modified_on = now();
2526
}
2627

2728
static get name () {

backend/models/access_list_auth.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33

44
const db = require('../db');
55
const Model = require('objection').Model;
6+
const now = require('./now_helper');
67

78
Model.knex(db);
89

910
class AccessListAuth extends Model {
1011
$beforeInsert () {
11-
this.created_on = Model.raw('NOW()');
12-
this.modified_on = Model.raw('NOW()');
12+
this.created_on = now();
13+
this.modified_on = now();
1314

1415
// Default for meta
1516
if (typeof this.meta === 'undefined') {
@@ -18,7 +19,7 @@ class AccessListAuth extends Model {
1819
}
1920

2021
$beforeUpdate () {
21-
this.modified_on = Model.raw('NOW()');
22+
this.modified_on = now();
2223
}
2324

2425
static get name () {

backend/models/access_list_client.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33

44
const db = require('../db');
55
const Model = require('objection').Model;
6+
const now = require('./now_helper');
67

78
Model.knex(db);
89

910
class AccessListClient extends Model {
1011
$beforeInsert () {
11-
this.created_on = Model.raw('NOW()');
12-
this.modified_on = Model.raw('NOW()');
12+
this.created_on = now();
13+
this.modified_on = now();
1314

1415
// Default for meta
1516
if (typeof this.meta === 'undefined') {
@@ -18,7 +19,7 @@ class AccessListClient extends Model {
1819
}
1920

2021
$beforeUpdate () {
21-
this.modified_on = Model.raw('NOW()');
22+
this.modified_on = now();
2223
}
2324

2425
static get name () {

backend/models/audit-log.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
const db = require('../db');
55
const Model = require('objection').Model;
66
const User = require('./user');
7+
const now = require('./now_helper');
78

89
Model.knex(db);
910

1011
class AuditLog extends Model {
1112
$beforeInsert () {
12-
this.created_on = Model.raw('NOW()');
13-
this.modified_on = Model.raw('NOW()');
13+
this.created_on = now();
14+
this.modified_on = now();
1415

1516
// Default for meta
1617
if (typeof this.meta === 'undefined') {
@@ -19,7 +20,7 @@ class AuditLog extends Model {
1920
}
2021

2122
$beforeUpdate () {
22-
this.modified_on = Model.raw('NOW()');
23+
this.modified_on = now();
2324
}
2425

2526
static get name () {

backend/models/auth.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const bcrypt = require('bcrypt');
55
const db = require('../db');
66
const Model = require('objection').Model;
77
const User = require('./user');
8+
const now = require('./now_helper');
89

910
Model.knex(db);
1011

@@ -24,8 +25,8 @@ function encryptPassword () {
2425

2526
class Auth extends Model {
2627
$beforeInsert (queryContext) {
27-
this.created_on = Model.raw('NOW()');
28-
this.modified_on = Model.raw('NOW()');
28+
this.created_on = now();
29+
this.modified_on = now();
2930

3031
// Default for meta
3132
if (typeof this.meta === 'undefined') {
@@ -36,7 +37,7 @@ class Auth extends Model {
3637
}
3738

3839
$beforeUpdate (queryContext) {
39-
this.modified_on = Model.raw('NOW()');
40+
this.modified_on = now();
4041
return encryptPassword.apply(this, queryContext);
4142
}
4243

backend/models/certificate.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@
44
const db = require('../db');
55
const Model = require('objection').Model;
66
const User = require('./user');
7+
const now = require('./now_helper');
78

89
Model.knex(db);
910

1011
class Certificate extends Model {
1112
$beforeInsert () {
12-
this.created_on = Model.raw('NOW()');
13-
this.modified_on = Model.raw('NOW()');
13+
this.created_on = now();
14+
this.modified_on = now();
1415

1516
// Default for expires_on
1617
if (typeof this.expires_on === 'undefined') {
17-
this.expires_on = Model.raw('NOW()');
18+
this.expires_on = now();
1819
}
1920

2021
// Default for domain_names
@@ -31,7 +32,7 @@ class Certificate extends Model {
3132
}
3233

3334
$beforeUpdate () {
34-
this.modified_on = Model.raw('NOW()');
35+
this.modified_on = now();
3536

3637
// Sort domain_names
3738
if (typeof this.domain_names !== 'undefined') {

backend/models/dead_host.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ const db = require('../db');
55
const Model = require('objection').Model;
66
const User = require('./user');
77
const Certificate = require('./certificate');
8+
const now = require('./now_helper');
89

910
Model.knex(db);
1011

1112
class DeadHost extends Model {
1213
$beforeInsert () {
13-
this.created_on = Model.raw('NOW()');
14-
this.modified_on = Model.raw('NOW()');
14+
this.created_on = now();
15+
this.modified_on = now();
1516

1617
// Default for domain_names
1718
if (typeof this.domain_names === 'undefined') {
@@ -27,7 +28,7 @@ class DeadHost extends Model {
2728
}
2829

2930
$beforeUpdate () {
30-
this.modified_on = Model.raw('NOW()');
31+
this.modified_on = now();
3132

3233
// Sort domain_names
3334
if (typeof this.domain_names !== 'undefined') {

0 commit comments

Comments
 (0)