Skip to content

Commit 6205434

Browse files
committed
Version 3 starter
1 parent 60fc574 commit 6205434

File tree

642 files changed

+25869
-32371
lines changed

Some content is hidden

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

642 files changed

+25869
-32371
lines changed

.gitignore

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
1-
.DS_Store
21
.idea
2+
.env
3+
.DS_Store
34
._*
5+
*.code-workspace
6+
vendor
7+
dist
8+
backend/config.json
9+
backend/internal/api/handler/assets
10+
test/node_modules
11+
*/node_modules
12+
docs/.vuepress/dist
13+
frontend/build
14+
frontend/yarn-error.log
15+
frontend/yarn.lock
16+
frontend/.npmrc
17+
test/cypress/fixtures/example.json
418
.vscode
5-
certbot-help.txt
19+
docker-build
20+
data

.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.9.3
1+
3.0.0a

DEV-README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Nginx Proxy Manager 3
2+
3+
WIP
4+
5+
6+
## Usage
7+
8+
environment variables
9+
10+
11+
## Building
12+
13+
### Backend API Server
14+
15+
```bash
16+
go build -ldflags="-X main.commit=$(git log -n 1 --format=%h)" -o bin/server ./cmd/server/main.go
17+
```
18+
19+
20+
## Development
21+
22+
```bash
23+
git clone nginxproxymanager
24+
cd nginxproxymanager
25+
./scripts/start-dev
26+
curl http://127.0.0.1:3000/api/
27+
```

Jenkinsfile

Lines changed: 97 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,17 @@ pipeline {
88
ansiColor('xterm')
99
}
1010
environment {
11-
IMAGE = "nginx-proxy-manager"
11+
IMAGE = 'nginx-proxy-manager'
1212
BUILD_VERSION = getVersion()
13-
MAJOR_VERSION = "2"
13+
BUILD_COMMIT = getCommit()
14+
MAJOR_VERSION = '3'
1415
BRANCH_LOWER = "${BRANCH_NAME.toLowerCase().replaceAll('/', '-')}"
1516
COMPOSE_PROJECT_NAME = "npm_${BRANCH_LOWER}_${BUILD_NUMBER}"
1617
COMPOSE_FILE = 'docker/docker-compose.ci.yml'
1718
COMPOSE_INTERACTIVE_NO_CLI = 1
1819
BUILDX_NAME = "${COMPOSE_PROJECT_NAME}"
20+
DOCS_BUCKET = 'jc21-npm-site-next' // TODO: change to prod when official
21+
DOCS_CDN = 'E2Z0128EHS0Q23' // TODO: same
1922
}
2023
stages {
2124
stage('Environment') {
@@ -45,89 +48,67 @@ pipeline {
4548
}
4649
stage('Versions') {
4750
steps {
51+
// Is this frontend version stuff still applicable?
4852
sh 'cat frontend/package.json | jq --arg BUILD_VERSION "${BUILD_VERSION}" \'.version = $BUILD_VERSION\' | sponge frontend/package.json'
4953
sh 'echo -e "\\E[1;36mFrontend Version is:\\E[1;33m $(cat frontend/package.json | jq -r .version)\\E[0m"'
50-
sh 'cat backend/package.json | jq --arg BUILD_VERSION "${BUILD_VERSION}" \'.version = $BUILD_VERSION\' | sponge backend/package.json'
51-
sh 'echo -e "\\E[1;36mBackend Version is:\\E[1;33m $(cat backend/package.json | jq -r .version)\\E[0m"'
5254
sh 'sed -i -E "s/(version-)[0-9]+\\.[0-9]+\\.[0-9]+(-green)/\\1${BUILD_VERSION}\\2/" README.md'
5355
}
5456
}
5557
}
5658
}
5759
stage('Frontend') {
5860
steps {
59-
sh './scripts/frontend-build'
61+
sh './scripts/ci/frontend-build'
62+
}
63+
post {
64+
always {
65+
junit 'frontend/eslint.xml'
66+
junit 'frontend/junit.xml'
67+
}
6068
}
6169
}
6270
stage('Backend') {
6371
steps {
64-
echo 'Checking Syntax ...'
65-
// See: https://github.com/yarnpkg/yarn/issues/3254
66-
sh '''docker run --rm \\
67-
-v "$(pwd)/backend:/app" \\
68-
-v "$(pwd)/global:/app/global" \\
69-
-w /app \\
70-
node:latest \\
71-
sh -c "yarn install && yarn eslint . && rm -rf node_modules"
72-
'''
73-
74-
echo 'Docker Build ...'
75-
sh '''docker build --pull --no-cache --squash --compress \\
76-
-t "${IMAGE}:ci-${BUILD_NUMBER}" \\
77-
-f docker/Dockerfile \\
78-
--build-arg TARGETPLATFORM=linux/amd64 \\
79-
--build-arg BUILDPLATFORM=linux/amd64 \\
80-
--build-arg BUILD_VERSION="${BUILD_VERSION}" \\
81-
--build-arg BUILD_COMMIT="${BUILD_COMMIT}" \\
82-
--build-arg BUILD_DATE="$(date '+%Y-%m-%d %T %Z')" \\
83-
.
84-
'''
72+
withCredentials([usernamePassword(credentialsId: 'oss-index-token', passwordVariable: 'NANCY_TOKEN', usernameVariable: 'NANCY_USER')]) {
73+
sh '''docker build --pull --no-cache --squash --compress \\
74+
-t ${IMAGE}:ci-${BUILD_NUMBER} \\
75+
-f docker/Dockerfile \\
76+
--build-arg TARGETPLATFORM=linux/amd64 \\
77+
--build-arg BUILDPLATFORM=linux/amd64 \\
78+
--build-arg BUILD_DATE="$(date '+%Y-%m-%d %T %Z')" \\
79+
--build-arg BUILD_VERSION="${BUILD_VERSION}" \\
80+
--build-arg BUILD_COMMIT="${BUILD_COMMIT}" \\
81+
--build-arg SENTRY_DSN="${SENTRY_DSN:-}" \\
82+
--build-arg GOPROXY="${GOPROXY:-}" \\
83+
--build-arg GOPRIVATE="${GOPRIVATE:-}" \\
84+
--build-arg NANCY_USER="${NANCY_USER}" \\
85+
--build-arg NANCY_TOKEN="${NANCY_TOKEN}" \\
86+
.
87+
'''
88+
}
8589
}
8690
}
87-
stage('Integration Tests Sqlite') {
88-
steps {
89-
// Bring up a stack
90-
sh 'docker-compose up -d fullstack-sqlite'
91-
sh './scripts/wait-healthy $(docker-compose ps -q fullstack-sqlite) 120'
92-
93-
// Run tests
94-
sh 'rm -rf test/results'
95-
sh 'docker-compose up cypress-sqlite'
96-
// Get results
97-
sh 'docker cp -L "$(docker-compose ps -q cypress-sqlite):/test/results" test/'
98-
}
99-
post {
100-
always {
101-
// Dumps to analyze later
102-
sh 'mkdir -p debug'
103-
sh 'docker-compose logs fullstack-sqlite | gzip > debug/docker_fullstack_sqlite.log.gz'
104-
sh 'docker-compose logs db | gzip > debug/docker_db.log.gz'
105-
// Cypress videos and screenshot artifacts
106-
dir(path: 'test/results') {
107-
archiveArtifacts allowEmptyArchive: true, artifacts: '**/*', excludes: '**/*.xml'
108-
}
109-
junit 'test/results/junit/*'
91+
stage('Test') {
92+
when {
93+
not {
94+
equals expected: 'UNSTABLE', actual: currentBuild.result
11095
}
11196
}
112-
}
113-
stage('Integration Tests Mysql') {
11497
steps {
11598
// Bring up a stack
116-
sh 'docker-compose up -d fullstack-mysql'
117-
sh './scripts/wait-healthy $(docker-compose ps -q fullstack-mysql) 120'
118-
99+
sh 'docker-compose up -d fullstack'
100+
sh './scripts/wait-healthy $(docker-compose ps -q fullstack) 120'
119101
// Run tests
120102
sh 'rm -rf test/results'
121-
sh 'docker-compose up cypress-mysql'
103+
sh 'docker-compose up cypress'
122104
// Get results
123-
sh 'docker cp -L "$(docker-compose ps -q cypress-mysql):/test/results" test/'
105+
sh 'docker cp -L "$(docker-compose ps -q cypress):/test/results" test/'
124106
}
125107
post {
126108
always {
127109
// Dumps to analyze later
128110
sh 'mkdir -p debug'
129-
sh 'docker-compose logs fullstack-mysql | gzip > debug/docker_fullstack_mysql.log.gz'
130-
sh 'docker-compose logs db | gzip > debug/docker_db.log.gz'
111+
sh 'docker-compose logs fullstack | gzip > debug/docker_fullstack.log.gz'
131112
// Cypress videos and screenshot artifacts
132113
dir(path: 'test/results') {
133114
archiveArtifacts allowEmptyArchive: true, artifacts: '**/*', excludes: '**/*.xml'
@@ -148,28 +129,41 @@ pipeline {
148129
sh 'yarn build'
149130
}
150131

132+
// API Docs:
133+
sh 'docker-compose exec -T fullstack curl -s --output /temp-docs/api-schema.json "http://fullstack:81/api/schema"'
134+
sh 'mkdir -p "docs/.vuepress/dist/api"'
135+
sh 'mv docs/api-schema.json docs/.vuepress/dist/api/'
136+
151137
dir(path: 'docs/.vuepress/dist') {
152138
sh 'tar -czf ../../docs.tgz *'
153139
}
154140

155141
archiveArtifacts(artifacts: 'docs/docs.tgz', allowEmptyArchive: false)
156142
}
157143
}
144+
/*
158145
stage('MultiArch Build') {
159146
when {
160-
not {
161-
equals expected: 'UNSTABLE', actual: currentBuild.result
147+
allOf {
148+
branch 'master'
149+
not {
150+
equals expected: 'UNSTABLE', actual: currentBuild.result
151+
}
162152
}
163153
}
164154
steps {
165-
withCredentials([usernamePassword(credentialsId: 'jc21-dockerhub', passwordVariable: 'dpass', usernameVariable: 'duser')]) {
166-
// Docker Login
167-
sh "docker login -u '${duser}' -p '${dpass}'"
168-
// Buildx with push from cache
169-
sh "./scripts/buildx --push ${BUILDX_PUSH_TAGS}"
155+
withCredentials([string(credentialsId: 'npm-sentry-dsn', variable: 'SENTRY_DSN')]) {
156+
withCredentials([usernamePassword(credentialsId: 'jc21-dockerhub', passwordVariable: 'dpass', usernameVariable: 'duser')]) {
157+
sh "docker login -u '${duser}' -p '${dpass}'"
158+
// Buildx to local files
159+
// sh './scripts/buildx -o type=local,dest=docker-build'
160+
// Buildx to with push
161+
sh "./scripts/buildx --push ${BUILDX_PUSH_TAGS}"
162+
}
170163
}
171164
}
172165
}
166+
*/
173167
stage('Docs Deploy') {
174168
when {
175169
allOf {
@@ -183,7 +177,7 @@ pipeline {
183177
withCredentials([[$class: 'AmazonWebServicesCredentialsBinding', accessKeyVariable: 'AWS_ACCESS_KEY_ID', credentialsId: 'npm-s3-docs', secretKeyVariable: 'AWS_SECRET_ACCESS_KEY']]) {
184178
sh """docker run --rm \\
185179
--name \${COMPOSE_PROJECT_NAME}-docs-upload \\
186-
-e S3_BUCKET=jc21-npm-site \\
180+
-e S3_BUCKET=$DOCS_BUCKET \\
187181
-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \\
188182
-e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \\
189183
-v \$(pwd):/app \\
@@ -197,7 +191,7 @@ pipeline {
197191
-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \\
198192
-e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \\
199193
jc21/ci-tools \\
200-
aws cloudfront create-invalidation --distribution-id EN1G6DEWZUTDT --paths '/*'
194+
aws cloudfront create-invalidation --distribution-id $DOCS_CDN --paths '/*'
201195
"""
202196
}
203197
}
@@ -213,16 +207,50 @@ pipeline {
213207
}
214208
steps {
215209
script {
216-
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.")
210+
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}:git-3-${BRANCH_LOWER}`\n\n**Note:** ensure you backup your NPM instance before testing this PR image! Especially if this PR contains database changes.")
211+
}
212+
}
213+
}
214+
stage('Artifacts') {
215+
when {
216+
allOf {
217+
branch 'master'
218+
not {
219+
equals expected: 'UNSTABLE', actual: currentBuild.result
220+
}
221+
}
222+
}
223+
steps {
224+
sh 'mkdir -p artifacts'
225+
// Docs
226+
dir(path: 'docs/.vuepress/dist') {
227+
sh 'zip -qr ../../../artifacts/docs.zip *'
228+
}
229+
// Multiarch builds
230+
/*
231+
dir(path: 'docker-build/linux_amd64/app') {
232+
sh 'zip -qr ../../../artifacts/linux_amd64.zip *'
233+
}
234+
dir(path: 'docker-build/linux_arm64/app') {
235+
sh 'zip -qr ../../../artifacts/linux_arm64.zip *'
236+
}
237+
dir(path: 'docker-build/linux_arm_v7/app') {
238+
sh 'zip -qr ../../../artifacts/linux_arm_v7.zip *'
239+
}
240+
**/
241+
// Archive them
242+
dir(path: 'artifacts') {
243+
archiveArtifacts artifacts: '**/*'
217244
}
218245
}
219246
}
220247
}
221248
post {
222249
always {
223250
sh 'docker-compose down --rmi all --remove-orphans --volumes -t 30'
251+
sh './scripts/build-cleanup'
224252
sh 'echo Reverting ownership'
225-
sh 'docker run --rm -v $(pwd):/data jc21/ci-tools chown -R $(id -u):$(id -g) /data'
253+
sh 'docker run --rm -v $(pwd):/data node:latest chown -R "$(id -u):$(id -g)" /data'
226254
}
227255
success {
228256
juxtapose event: 'success'

0 commit comments

Comments
 (0)