Skip to content

Commit 50528a2

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into develop
# Conflicts: # global/certbot-dns-plugins.js
2 parents 14ac00d + e08a4d4 commit 50528a2

File tree

107 files changed

+3583
-3371
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+3583
-3371
lines changed

.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.9.19
1+
2.10.4

Jenkinsfile

Lines changed: 49 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
import groovy.transform.Field
2+
3+
@Field
4+
def shOutput = ""
5+
def buildxPushTags = ""
6+
17
pipeline {
28
agent {
39
label 'docker-multiarch'
@@ -8,14 +14,16 @@ pipeline {
814
ansiColor('xterm')
915
}
1016
environment {
11-
IMAGE = "nginx-proxy-manager"
17+
IMAGE = 'nginx-proxy-manager'
1218
BUILD_VERSION = getVersion()
13-
MAJOR_VERSION = "2"
14-
BRANCH_LOWER = "${BRANCH_NAME.toLowerCase().replaceAll('/', '-')}"
19+
MAJOR_VERSION = '2'
20+
BRANCH_LOWER = "${BRANCH_NAME.toLowerCase().replaceAll('\\\\', '-').replaceAll('/', '-').replaceAll('\\.', '-')}"
1521
COMPOSE_PROJECT_NAME = "npm_${BRANCH_LOWER}_${BUILD_NUMBER}"
1622
COMPOSE_FILE = 'docker/docker-compose.ci.yml'
1723
COMPOSE_INTERACTIVE_NO_CLI = 1
1824
BUILDX_NAME = "${COMPOSE_PROJECT_NAME}"
25+
DOCS_BUCKET = 'jc21-npm-site'
26+
DOCS_CDN = 'EN1G6DEWZUTDT'
1927
}
2028
stages {
2129
stage('Environment') {
@@ -26,7 +34,7 @@ pipeline {
2634
}
2735
steps {
2836
script {
29-
env.BUILDX_PUSH_TAGS = "-t docker.io/jc21/${IMAGE}:${BUILD_VERSION} -t docker.io/jc21/${IMAGE}:${MAJOR_VERSION} -t docker.io/jc21/${IMAGE}:latest"
37+
buildxPushTags = "-t docker.io/jc21/${IMAGE}:${BUILD_VERSION} -t docker.io/jc21/${IMAGE}:${MAJOR_VERSION} -t docker.io/jc21/${IMAGE}:latest"
3038
}
3139
}
3240
}
@@ -39,7 +47,7 @@ pipeline {
3947
steps {
4048
script {
4149
// Defaults to the Branch name, which is applies to all branches AND pr's
42-
env.BUILDX_PUSH_TAGS = "-t docker.io/jc21/${IMAGE}:github-${BRANCH_LOWER}"
50+
buildxPushTags = "-t docker.io/jc21/${IMAGE}:github-${BRANCH_LOWER}"
4351
}
4452
}
4553
}
@@ -54,55 +62,52 @@ pipeline {
5462
}
5563
}
5664
}
57-
stage('Frontend') {
65+
stage('Build and Test') {
5866
steps {
59-
sh './scripts/frontend-build'
67+
script {
68+
// Frontend and Backend
69+
def shStatusCode = sh(label: 'Checking and Building', returnStatus: true, script: '''
70+
set -e
71+
./scripts/ci/frontend-build > ${WORKSPACE}/tmp-sh-build 2>&1
72+
./scripts/ci/test-and-build > ${WORKSPACE}/tmp-sh-build 2>&1
73+
''')
74+
shOutput = readFile "${env.WORKSPACE}/tmp-sh-build"
75+
if (shStatusCode != 0) {
76+
error "${shOutput}"
77+
}
78+
}
6079
}
61-
}
62-
stage('Backend') {
63-
steps {
64-
echo 'Checking Syntax ...'
65-
sh 'docker pull nginxproxymanager/nginx-full:certbot-node'
66-
// See: https://github.com/yarnpkg/yarn/issues/3254
67-
sh '''docker run --rm \\
68-
-v "$(pwd)/backend:/app" \\
69-
-v "$(pwd)/global:/app/global" \\
70-
-w /app \\
71-
nginxproxymanager/nginx-full:certbot-node \\
72-
sh -c "yarn install && yarn eslint . && rm -rf node_modules"
73-
'''
74-
75-
echo 'Docker Build ...'
76-
sh '''docker build --pull --no-cache --squash --compress \\
77-
-t "${IMAGE}:ci-${BUILD_NUMBER}" \\
78-
-f docker/Dockerfile \\
79-
--build-arg TARGETPLATFORM=linux/amd64 \\
80-
--build-arg BUILDPLATFORM=linux/amd64 \\
81-
--build-arg BUILD_VERSION="${BUILD_VERSION}" \\
82-
--build-arg BUILD_COMMIT="${BUILD_COMMIT}" \\
83-
--build-arg BUILD_DATE="$(date '+%Y-%m-%d %T %Z')" \\
84-
.
85-
'''
80+
post {
81+
always {
82+
sh 'rm -f ${WORKSPACE}/tmp-sh-build'
83+
}
84+
failure {
85+
npmGithubPrComment("CI Error:\n\n```\n${shOutput}\n```", true)
86+
}
8687
}
8788
}
8889
stage('Integration Tests Sqlite') {
8990
steps {
9091
// Bring up a stack
9192
sh 'docker-compose up -d fullstack-sqlite'
92-
sh './scripts/wait-healthy $(docker-compose ps -q fullstack-sqlite) 120'
93+
sh './scripts/wait-healthy $(docker-compose ps --all -q fullstack-sqlite) 120'
94+
// Stop and Start it, as this will test it's ability to restart with existing data
95+
sh 'docker-compose stop fullstack-sqlite'
96+
sh 'docker-compose start fullstack-sqlite'
97+
sh './scripts/wait-healthy $(docker-compose ps --all -q fullstack-sqlite) 120'
9398

9499
// Run tests
95100
sh 'rm -rf test/results'
96101
sh 'docker-compose up cypress-sqlite'
97102
// Get results
98-
sh 'docker cp -L "$(docker-compose ps -q cypress-sqlite):/test/results" test/'
103+
sh 'docker cp -L "$(docker-compose ps --all -q cypress-sqlite):/test/results" test/'
99104
}
100105
post {
101106
always {
102107
// Dumps to analyze later
103108
sh 'mkdir -p debug'
104-
sh 'docker-compose logs fullstack-sqlite | gzip > debug/docker_fullstack_sqlite.log.gz'
105-
sh 'docker-compose logs db | gzip > debug/docker_db.log.gz'
109+
sh 'docker-compose logs fullstack-sqlite > debug/docker_fullstack_sqlite.log'
110+
sh 'docker-compose logs db > debug/docker_db.log'
106111
// Cypress videos and screenshot artifacts
107112
dir(path: 'test/results') {
108113
archiveArtifacts allowEmptyArchive: true, artifacts: '**/*', excludes: '**/*.xml'
@@ -115,20 +120,20 @@ pipeline {
115120
steps {
116121
// Bring up a stack
117122
sh 'docker-compose up -d fullstack-mysql'
118-
sh './scripts/wait-healthy $(docker-compose ps -q fullstack-mysql) 120'
123+
sh './scripts/wait-healthy $(docker-compose ps --all -q fullstack-mysql) 120'
119124

120125
// Run tests
121126
sh 'rm -rf test/results'
122127
sh 'docker-compose up cypress-mysql'
123128
// Get results
124-
sh 'docker cp -L "$(docker-compose ps -q cypress-mysql):/test/results" test/'
129+
sh 'docker cp -L "$(docker-compose ps --all -q cypress-mysql):/test/results" test/'
125130
}
126131
post {
127132
always {
128133
// Dumps to analyze later
129134
sh 'mkdir -p debug'
130-
sh 'docker-compose logs fullstack-mysql | gzip > debug/docker_fullstack_mysql.log.gz'
131-
sh 'docker-compose logs db | gzip > debug/docker_db.log.gz'
135+
sh 'docker-compose logs fullstack-mysql > debug/docker_fullstack_mysql.log'
136+
sh 'docker-compose logs db > debug/docker_db.log'
132137
// Cypress videos and screenshot artifacts
133138
dir(path: 'test/results') {
134139
archiveArtifacts allowEmptyArchive: true, artifacts: '**/*', excludes: '**/*.xml'
@@ -164,10 +169,8 @@ pipeline {
164169
}
165170
steps {
166171
withCredentials([usernamePassword(credentialsId: 'jc21-dockerhub', passwordVariable: 'dpass', usernameVariable: 'duser')]) {
167-
// Docker Login
168-
sh "docker login -u '${duser}' -p '${dpass}'"
169-
// Buildx with push from cache
170-
sh "./scripts/buildx --push ${BUILDX_PUSH_TAGS}"
172+
sh 'docker login -u "${duser}" -p "${dpass}"'
173+
sh "./scripts/buildx --push ${buildxPushTags}"
171174
}
172175
}
173176
}
@@ -181,26 +184,7 @@ pipeline {
181184
}
182185
}
183186
steps {
184-
withCredentials([[$class: 'AmazonWebServicesCredentialsBinding', accessKeyVariable: 'AWS_ACCESS_KEY_ID', credentialsId: 'npm-s3-docs', secretKeyVariable: 'AWS_SECRET_ACCESS_KEY']]) {
185-
sh """docker run --rm \\
186-
--name \${COMPOSE_PROJECT_NAME}-docs-upload \\
187-
-e S3_BUCKET=jc21-npm-site \\
188-
-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \\
189-
-e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \\
190-
-v \$(pwd):/app \\
191-
-w /app \\
192-
jc21/ci-tools \\
193-
scripts/docs-upload /app/docs/.vuepress/dist/
194-
"""
195-
196-
sh """docker run --rm \\
197-
--name \${COMPOSE_PROJECT_NAME}-docs-invalidate \\
198-
-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \\
199-
-e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \\
200-
jc21/ci-tools \\
201-
aws cloudfront create-invalidation --distribution-id EN1G6DEWZUTDT --paths '/*'
202-
"""
203-
}
187+
npmDocsRelease("$DOCS_BUCKET", "$DOCS_CDN")
204188
}
205189
}
206190
stage('PR Comment') {
@@ -214,7 +198,7 @@ pipeline {
214198
}
215199
steps {
216200
script {
217-
def comment = pullRequest.comment("This is an automated message from CI:\n\nDocker Image for build ${BUILD_NUMBER} is available on [DockerHub](https://cloud.docker.com/repository/docker/jc21/${IMAGE}) as `jc21/${IMAGE}:github-${BRANCH_LOWER}`\n\n**Note:** ensure you backup your NPM instance before testing this PR image! Especially if this PR contains database changes.")
201+
npmGithubPrComment("Docker Image for build ${BUILD_NUMBER} is available on [DockerHub](https://cloud.docker.com/repository/docker/jc21/${IMAGE}) as `jc21/${IMAGE}:github-${BRANCH_LOWER}`\n\n**Note:** ensure you backup your NPM instance before testing this PR image! Especially if this PR contains database changes.", true)
218202
}
219203
}
220204
}

README.md

Lines changed: 4 additions & 2 deletions
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.9.19-green.svg?style=for-the-badge">
4+
<img src="https://img.shields.io/badge/version-2.10.4-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>
@@ -56,7 +56,7 @@ I won't go in to too much detail here but here are the basics for someone new to
5656
2. Create a docker-compose.yml file similar to this:
5757

5858
```yml
59-
version: '3'
59+
version: '3.8'
6060
services:
6161
app:
6262
image: 'jc21/nginx-proxy-manager:latest'
@@ -70,6 +70,8 @@ services:
7070
- ./letsencrypt:/etc/letsencrypt
7171
```
7272
73+
This is the bare minimum configuration required. See the [documentation](https://nginxproxymanager.com/setup/) for more.
74+
7375
3. Bring up your stack by running
7476
7577
```bash

backend/app.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const express = require('express');
22
const bodyParser = require('body-parser');
33
const fileUpload = require('express-fileupload');
44
const compression = require('compression');
5+
const config = require('./lib/config');
56
const log = require('./logger').express;
67

78
/**
@@ -24,7 +25,7 @@ app.enable('trust proxy', ['loopback', 'linklocal', 'uniquelocal']);
2425
app.enable('strict routing');
2526

2627
// pretty print JSON when not live
27-
if (process.env.NODE_ENV !== 'production') {
28+
if (config.debug()) {
2829
app.set('json spaces', 2);
2930
}
3031

@@ -65,7 +66,7 @@ app.use(function (err, req, res, next) {
6566
}
6667
};
6768

68-
if (process.env.NODE_ENV === 'development' || (req.baseUrl + req.path).includes('nginx/certificates')) {
69+
if (config.debug() || (req.baseUrl + req.path).includes('nginx/certificates')) {
6970
payload.debug = {
7071
stack: typeof err.stack !== 'undefined' && err.stack ? err.stack.split('\n') : null,
7172
previous: err.previous
@@ -74,7 +75,7 @@ app.use(function (err, req, res, next) {
7475

7576
// Not every error is worth logging - but this is good for now until it gets annoying.
7677
if (typeof err.stack !== 'undefined' && err.stack) {
77-
if (process.env.NODE_ENV === 'development' || process.env.DEBUG) {
78+
if (config.debug()) {
7879
log.debug(err.stack);
7980
} else if (typeof err.public == 'undefined' || !err.public) {
8081
log.warn(err.message);

backend/db.js

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,27 @@
1-
const config = require('config');
1+
const config = require('./lib/config');
22

33
if (!config.has('database')) {
4-
throw new Error('Database config does not exist! Please read the instructions: https://github.com/jc21/nginx-proxy-manager/blob/master/doc/INSTALL.md');
4+
throw new Error('Database config does not exist! Please read the instructions: https://nginxproxymanager.com/setup/');
55
}
66

77
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-
};
8+
const cfg = config.get('database');
9+
if (cfg.engine === 'knex-native') {
10+
return cfg.knex;
11+
}
12+
return {
13+
client: cfg.engine,
14+
connection: {
15+
host: cfg.host,
16+
user: cfg.user,
17+
password: cfg.password,
18+
database: cfg.name,
19+
port: cfg.port
20+
},
21+
migrations: {
22+
tableName: 'migrations'
23+
}
24+
};
2425
}
2526

26-
27-
let data = generateDbConfig();
28-
29-
if (typeof config.database.version !== 'undefined') {
30-
data.version = config.database.version;
31-
}
32-
33-
module.exports = require('knex')(data);
27+
module.exports = require('knex')(generateDbConfig());

0 commit comments

Comments
 (0)