Compare commits
43 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 13a8d3d22f | |||
| 78867e3c6c | |||
| 0e272c92e1 | |||
| ce488a2cbd | |||
| 6a1cc21a6e | |||
| 850d5a247e | |||
| a614458159 | |||
| 3a68297242 | |||
| 5f926027a5 | |||
| af1f6b460c | |||
| 7083c277f3 | |||
| a6d18f36fc | |||
| 4c730ede7e | |||
| 005381cc14 | |||
| eee4bcdbf6 | |||
| 26c8c44a72 | |||
| 042408ae64 | |||
| fe501881ed | |||
| af463afcd8 | |||
| c5a275d3e6 | |||
| 7411a0c123 | |||
| d9a13bd2e6 | |||
| 78fed87f0b | |||
| 4f2383143f | |||
| 7c3aa6d946 | |||
| 1fdaf18624 | |||
| 7611c5315f | |||
| 4e49c4d571 | |||
| faf5d8ea40 | |||
| 93bd692a0c | |||
| 9f68c51782 | |||
| db75705007 | |||
| 0d817a0d7b | |||
| ef72848b96 | |||
| a57dc35a62 | |||
| ac637548bf | |||
| 0c3cb14393 | |||
| 03adc13ef8 | |||
| cb564dbfd9 | |||
| e780ba3300 | |||
| cff6c5c21c | |||
| b06afeab86 | |||
| dbc580e6ab |
@@ -23,7 +23,7 @@
|
||||
much shaming throughout the land. If you use an editor besides Eclipse or IntelliJ, adapt the codestyle and submit a PR
|
||||
there :)
|
||||
* Fill out a CLA for us, so we can sort out all the legal parts of contributing. You can get all the information for
|
||||
this [here](https://books.sonatype.com/nexus-book/reference/contrib.html). You may go, this is for your book, is it
|
||||
this [here](https://help.sonatype.com/display/NXRM3/Bundle+Development#BundleDevelopment-ContributingBundles). You may go, this is for your book, is it
|
||||
applicable for this repo? Yes, absolutely. Follow the CLA process and email in your form. We are working on a way to
|
||||
make this simpler, as well.
|
||||
* Make sure to fill out an issue for your PR, so that we have traceability as to what you are trying to fix,
|
||||
|
||||
+29
-47
@@ -12,72 +12,54 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FROM centos:centos7
|
||||
FROM centos:centos7
|
||||
|
||||
MAINTAINER Sonatype <cloud-ops@sonatype.com>
|
||||
|
||||
LABEL vendor=Sonatype \
|
||||
com.sonatype.license="Apache License, Version 2.0" \
|
||||
com.sonatype.name="Nexus Repository Manager base image"
|
||||
com.sonatype.license="Apache License, Version 2.0" \
|
||||
com.sonatype.name="Nexus Repository Manager base image"
|
||||
|
||||
ARG NEXUS_VERSION=3.5.0-02
|
||||
ARG NEXUS_VERSION=3.14.0-04
|
||||
ARG NEXUS_DOWNLOAD_URL=https://download.sonatype.com/nexus/3/nexus-${NEXUS_VERSION}-unix.tar.gz
|
||||
ARG NEXUS_DOWNLOAD_SHA256_HASH=ae8cc7891942d71cf12c11e1a98d70c1310e788ab44aa95c5d1e7671cc0187e2
|
||||
|
||||
RUN yum install -y \
|
||||
curl tar \
|
||||
&& yum clean all
|
||||
ARG JAVA_URL=http://download.oracle.com/otn-pub/java/jdk/8u181-b13/96a7b8442fe848ef90c96a2fad6ed6d1/server-jre-8u181-linux-x64.tar.gz
|
||||
ARG JAVA_DOWNLOAD_SHA256_HASH=0b26c7fcfad20029e6e0989e678efcd4a81f0fe502a478b4972215533867de1b
|
||||
|
||||
# configure java runtime
|
||||
ENV JAVA_HOME=/opt/java \
|
||||
JAVA_VERSION_MAJOR=8 \
|
||||
JAVA_VERSION_MINOR=141 \
|
||||
JAVA_VERSION_BUILD=15 \
|
||||
JAVA_DOWNLOAD_HASH=336fa29ff2bb4ef291e347e091f7f4a7
|
||||
ENV JAVA_HOME=/opt/java
|
||||
|
||||
# configure nexus runtime
|
||||
ENV SONATYPE_DIR=/opt/sonatype
|
||||
ENV NEXUS_HOME=${SONATYPE_DIR}/nexus \
|
||||
NEXUS_DATA=/nexus-data \
|
||||
NEXUS_CONTEXT='' \
|
||||
SONATYPE_WORK=${SONATYPE_DIR}/sonatype-work
|
||||
NEXUS_DATA=/nexus-data \
|
||||
NEXUS_CONTEXT='' \
|
||||
SONATYPE_WORK=${SONATYPE_DIR}/sonatype-work \
|
||||
DOCKER_TYPE='docker'
|
||||
|
||||
# install Oracle JRE
|
||||
RUN mkdir -p /opt \
|
||||
&& curl --fail --silent --location --retry 3 \
|
||||
--header "Cookie: oraclelicense=accept-securebackup-cookie; " \
|
||||
http://download.oracle.com/otn-pub/java/jdk/${JAVA_VERSION_MAJOR}u${JAVA_VERSION_MINOR}-b${JAVA_VERSION_BUILD}/${JAVA_DOWNLOAD_HASH}/server-jre-${JAVA_VERSION_MAJOR}u${JAVA_VERSION_MINOR}-linux-x64.tar.gz \
|
||||
| gunzip \
|
||||
| tar -x -C /opt \
|
||||
&& ln -s /opt/jdk1.${JAVA_VERSION_MAJOR}.0_${JAVA_VERSION_MINOR} ${JAVA_HOME}
|
||||
ARG NEXUS_REPOSITORY_MANAGER_COOKBOOK_VERSION="release-0.5.20180828-161555.3c23098"
|
||||
ARG NEXUS_REPOSITORY_MANAGER_COOKBOOK_URL="https://github.com/sonatype/chef-nexus-repository-manager/releases/download/${NEXUS_REPOSITORY_MANAGER_COOKBOOK_VERSION}/chef-nexus-repository-manager.tar.gz"
|
||||
|
||||
# install nexus
|
||||
RUN mkdir -p ${NEXUS_HOME} \
|
||||
&& curl --fail --silent --location --retry 3 \
|
||||
${NEXUS_DOWNLOAD_URL} \
|
||||
| gunzip \
|
||||
| tar x -C ${NEXUS_HOME} --strip-components=1 nexus-${NEXUS_VERSION} \
|
||||
&& chown -R root:root ${NEXUS_HOME}
|
||||
ADD solo.json.erb /var/chef/solo.json.erb
|
||||
|
||||
# configure nexus
|
||||
RUN sed \
|
||||
-e '/^nexus-context/ s:$:${NEXUS_CONTEXT}:' \
|
||||
-i ${NEXUS_HOME}/etc/nexus-default.properties \
|
||||
&& sed \
|
||||
-e '/^-Xms/d' \
|
||||
-e '/^-Xmx/d' \
|
||||
-i ${NEXUS_HOME}/bin/nexus.vmoptions
|
||||
|
||||
RUN useradd -r -u 200 -m -c "nexus role account" -d ${NEXUS_DATA} -s /bin/false nexus \
|
||||
&& mkdir -p ${NEXUS_DATA}/etc ${NEXUS_DATA}/log ${NEXUS_DATA}/tmp ${SONATYPE_WORK} \
|
||||
&& ln -s ${NEXUS_DATA} ${SONATYPE_WORK}/nexus3 \
|
||||
&& chown -R nexus:nexus ${NEXUS_DATA}
|
||||
# Install using chef-solo
|
||||
RUN curl -L https://www.getchef.com/chef/install.sh | bash \
|
||||
&& /opt/chef/embedded/bin/erb /var/chef/solo.json.erb > /var/chef/solo.json \
|
||||
&& chef-solo \
|
||||
--recipe-url ${NEXUS_REPOSITORY_MANAGER_COOKBOOK_URL} \
|
||||
--json-attributes /var/chef/solo.json \
|
||||
&& rpm -qa *chef* | xargs rpm -e \
|
||||
&& rpm --rebuilddb \
|
||||
&& rm -rf /etc/chef \
|
||||
&& rm -rf /opt/chefdk \
|
||||
&& rm -rf /var/cache/yum \
|
||||
&& rm -rf /var/chef
|
||||
|
||||
VOLUME ${NEXUS_DATA}
|
||||
|
||||
EXPOSE 8081
|
||||
USER nexus
|
||||
WORKDIR ${NEXUS_HOME}
|
||||
|
||||
ENV INSTALL4J_ADD_VM_PARAMS="-Xms1200m -Xmx1200m"
|
||||
ENV INSTALL4J_ADD_VM_PARAMS="-Xms1200m -Xmx1200m -XX:MaxDirectMemorySize=2g -Djava.util.prefs.userRoot=${NEXUS_DATA}/javaprefs"
|
||||
|
||||
CMD ["bin/nexus", "run"]
|
||||
CMD ["sh", "-c", "${SONATYPE_DIR}/start-nexus-repository-manager.sh"]
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
# Copyright (c) 2016-present Sonatype, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FROM centos:centos7
|
||||
|
||||
MAINTAINER Sonatype <cloud-ops@sonatype.com>
|
||||
|
||||
LABEL name="Nexus Repository Manager" \
|
||||
vendor=Sonatype \
|
||||
version="3.14.0-04" \
|
||||
release="3.14.0" \
|
||||
url="https://sonatype.com" \
|
||||
summary="The Nexus Repository Manager server \
|
||||
with universal support for popular component formats." \
|
||||
description="The Nexus Repository Manager server \
|
||||
with universal support for popular component formats." \
|
||||
run="docker run -d --name NAME \
|
||||
-p 8081:8081 \
|
||||
IMAGE" \
|
||||
stop="docker stop NAME" \
|
||||
com.sonatype.license="Apache License, Version 2.0" \
|
||||
com.sonatype.name="Nexus Repository Manager base image" \
|
||||
io.k8s.description="The Nexus Repository Manager server \
|
||||
with universal support for popular component formats." \
|
||||
io.k8s.display-name="Nexus Repository Manager" \
|
||||
io.openshift.expose-services="8081:8081" \
|
||||
io.openshift.tags="Sonatype,Nexus,Repository Manager"
|
||||
|
||||
ARG NEXUS_VERSION=3.14.0-04
|
||||
ARG NEXUS_DOWNLOAD_URL=https://download.sonatype.com/nexus/3/nexus-${NEXUS_VERSION}-unix.tar.gz
|
||||
ARG NEXUS_DOWNLOAD_SHA256_HASH=ae8cc7891942d71cf12c11e1a98d70c1310e788ab44aa95c5d1e7671cc0187e2
|
||||
|
||||
ARG JAVA_URL=http://download.oracle.com/otn-pub/java/jdk/8u181-b13/96a7b8442fe848ef90c96a2fad6ed6d1/server-jre-8u181-linux-x64.tar.gz
|
||||
ARG JAVA_DOWNLOAD_SHA256_HASH=0b26c7fcfad20029e6e0989e678efcd4a81f0fe502a478b4972215533867de1b
|
||||
|
||||
ENV JAVA_HOME=/opt/java
|
||||
|
||||
# configure nexus runtime
|
||||
ENV SONATYPE_DIR=/opt/sonatype
|
||||
ENV NEXUS_HOME=${SONATYPE_DIR}/nexus \
|
||||
NEXUS_DATA=/nexus-data \
|
||||
NEXUS_CONTEXT='' \
|
||||
SONATYPE_WORK=${SONATYPE_DIR}/sonatype-work \
|
||||
DOCKER_TYPE='rh-docker'
|
||||
|
||||
ARG NEXUS_REPOSITORY_MANAGER_COOKBOOK_VERSION="release-0.5.20180828-161555.3c23098"
|
||||
ARG NEXUS_REPOSITORY_MANAGER_COOKBOOK_URL="https://github.com/sonatype/chef-nexus-repository-manager/releases/download/${NEXUS_REPOSITORY_MANAGER_COOKBOOK_VERSION}/chef-nexus-repository-manager.tar.gz"
|
||||
|
||||
ADD solo.json.erb /var/chef/solo.json.erb
|
||||
|
||||
# Install using chef-solo
|
||||
RUN curl -L https://www.getchef.com/chef/install.sh | bash \
|
||||
&& /opt/chef/embedded/bin/erb /var/chef/solo.json.erb > /var/chef/solo.json \
|
||||
&& chef-solo \
|
||||
--node_name nexus_repository_red_hat_docker_build \
|
||||
--recipe-url ${NEXUS_REPOSITORY_MANAGER_COOKBOOK_URL} \
|
||||
--json-attributes /var/chef/solo.json \
|
||||
&& rpm -qa *chef* | xargs rpm -e \
|
||||
&& rpm --rebuilddb \
|
||||
&& rm -rf /etc/chef \
|
||||
&& rm -rf /opt/chefdk \
|
||||
&& rm -rf /var/cache/yum \
|
||||
&& rm -rf /var/chef
|
||||
|
||||
VOLUME ${NEXUS_DATA}
|
||||
|
||||
EXPOSE 8081
|
||||
USER nexus
|
||||
|
||||
ENV INSTALL4J_ADD_VM_PARAMS="-Xms1200m -Xmx1200m -XX:MaxDirectMemorySize=2g -Djava.util.prefs.userRoot=${NEXUS_DATA}/javaprefs"
|
||||
|
||||
ENTRYPOINT ["/uid_entrypoint.sh"]
|
||||
CMD ["sh", "-c", "${SONATYPE_DIR}/start-nexus-repository-manager.sh"]
|
||||
@@ -0,0 +1,84 @@
|
||||
# Copyright (c) 2016-present Sonatype, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FROM registry.access.redhat.com/rhel7/rhel
|
||||
|
||||
MAINTAINER Sonatype <cloud-ops@sonatype.com>
|
||||
|
||||
LABEL name="Nexus Repository Manager" \
|
||||
vendor=Sonatype \
|
||||
version="3.14.0-04" \
|
||||
release="3.14.0" \
|
||||
url="https://sonatype.com" \
|
||||
summary="The Nexus Repository Manager server \
|
||||
with universal support for popular component formats." \
|
||||
description="The Nexus Repository Manager server \
|
||||
with universal support for popular component formats." \
|
||||
run="docker run -d --name NAME \
|
||||
-p 8081:8081 \
|
||||
IMAGE" \
|
||||
stop="docker stop NAME" \
|
||||
com.sonatype.license="Apache License, Version 2.0" \
|
||||
com.sonatype.name="Nexus Repository Manager base image" \
|
||||
io.k8s.description="The Nexus Repository Manager server \
|
||||
with universal support for popular component formats." \
|
||||
io.k8s.display-name="Nexus Repository Manager" \
|
||||
io.openshift.expose-services="8081:8081" \
|
||||
io.openshift.tags="Sonatype,Nexus,Repository Manager"
|
||||
|
||||
ARG NEXUS_VERSION=3.14.0-04
|
||||
ARG NEXUS_DOWNLOAD_URL=https://download.sonatype.com/nexus/3/nexus-${NEXUS_VERSION}-unix.tar.gz
|
||||
ARG NEXUS_DOWNLOAD_SHA256_HASH=ae8cc7891942d71cf12c11e1a98d70c1310e788ab44aa95c5d1e7671cc0187e2
|
||||
|
||||
ARG JAVA_URL=http://download.oracle.com/otn-pub/java/jdk/8u181-b13/96a7b8442fe848ef90c96a2fad6ed6d1/server-jre-8u181-linux-x64.tar.gz
|
||||
ARG JAVA_DOWNLOAD_SHA256_HASH=0b26c7fcfad20029e6e0989e678efcd4a81f0fe502a478b4972215533867de1b
|
||||
|
||||
ENV JAVA_HOME=/opt/java
|
||||
|
||||
# configure nexus runtime
|
||||
ENV SONATYPE_DIR=/opt/sonatype
|
||||
ENV NEXUS_HOME=${SONATYPE_DIR}/nexus \
|
||||
NEXUS_DATA=/nexus-data \
|
||||
NEXUS_CONTEXT='' \
|
||||
SONATYPE_WORK=${SONATYPE_DIR}/sonatype-work \
|
||||
DOCKER_TYPE='rh-docker'
|
||||
|
||||
ARG NEXUS_REPOSITORY_MANAGER_COOKBOOK_VERSION="release-0.5.20180828-161555.3c23098"
|
||||
ARG NEXUS_REPOSITORY_MANAGER_COOKBOOK_URL="https://github.com/sonatype/chef-nexus-repository-manager/releases/download/${NEXUS_REPOSITORY_MANAGER_COOKBOOK_VERSION}/chef-nexus-repository-manager.tar.gz"
|
||||
|
||||
ADD solo.json.erb /var/chef/solo.json.erb
|
||||
|
||||
# Install using chef-solo
|
||||
RUN curl -L https://www.getchef.com/chef/install.sh | bash \
|
||||
&& /opt/chef/embedded/bin/erb /var/chef/solo.json.erb > /var/chef/solo.json \
|
||||
&& chef-solo \
|
||||
--node_name nexus_repository_red_hat_docker_build \
|
||||
--recipe-url ${NEXUS_REPOSITORY_MANAGER_COOKBOOK_URL} \
|
||||
--json-attributes /var/chef/solo.json \
|
||||
&& rpm -qa *chef* | xargs rpm -e \
|
||||
&& rpm --rebuilddb \
|
||||
&& rm -rf /etc/chef \
|
||||
&& rm -rf /opt/chefdk \
|
||||
&& rm -rf /var/cache/yum \
|
||||
&& rm -rf /var/chef
|
||||
|
||||
VOLUME ${NEXUS_DATA}
|
||||
|
||||
EXPOSE 8081
|
||||
USER nexus
|
||||
|
||||
ENV INSTALL4J_ADD_VM_PARAMS="-Xms1200m -Xmx1200m -XX:MaxDirectMemorySize=2g -Djava.util.prefs.userRoot=${NEXUS_DATA}/javaprefs"
|
||||
|
||||
ENTRYPOINT ["/uid_entrypoint.sh"]
|
||||
CMD ["sh", "-c", "${SONATYPE_DIR}/start-nexus-repository-manager.sh"]
|
||||
Vendored
+257
@@ -0,0 +1,257 @@
|
||||
/*
|
||||
* Copyright (c) 2016-present Sonatype, Inc. All rights reserved.
|
||||
* Includes the third-party code listed at http://links.sonatype.com/products/nexus/attributions.
|
||||
* "Sonatype" is a trademark of Sonatype, Inc.
|
||||
*/
|
||||
@Library('ci-pipeline-library') _
|
||||
import com.sonatype.jenkins.pipeline.GitHub
|
||||
import com.sonatype.jenkins.pipeline.OsTools
|
||||
|
||||
properties([
|
||||
parameters([
|
||||
string(defaultValue: '', description: 'New Nexus Repository Manager Version', name: 'nexus_repository_manager_version'),
|
||||
string(defaultValue: '', description: 'New Nexus Repository Manager Version Sha256', name: 'nexus_repository_manager_version_sha'),
|
||||
|
||||
string(defaultValue: '', description: 'New Nexus Repository Manager Cookbook Version', name: 'nexus_repository_manager_cookbook_version'),
|
||||
|
||||
string(defaultValue: '', description: 'New JRE Url', name: 'oracle_jre_url'),
|
||||
string(defaultValue: '', description: 'New JRE Sha256', name: 'oracle_jre_sha')
|
||||
])
|
||||
])
|
||||
|
||||
node('ubuntu-zion') {
|
||||
def commitId, commitDate, version, imageId, branch, dockerFileLocations
|
||||
def organization = 'sonatype',
|
||||
gitHubRepository = 'docker-nexus3',
|
||||
credentialsId = 'integrations-github-api',
|
||||
imageName = 'sonatype/nexus3',
|
||||
archiveName = 'docker-nexus3',
|
||||
dockerHubRepository = 'nexus3'
|
||||
GitHub gitHub
|
||||
|
||||
try {
|
||||
stage('Preparation') {
|
||||
deleteDir()
|
||||
OsTools.runSafe(this, "docker system prune -a -f")
|
||||
|
||||
def checkoutDetails = checkout scm
|
||||
|
||||
dockerFileLocations = [
|
||||
"${pwd()}/Dockerfile",
|
||||
"${pwd()}/Dockerfile.rh.centos",
|
||||
"${pwd()}/Dockerfile.rh.el"
|
||||
]
|
||||
|
||||
branch = checkoutDetails.GIT_BRANCH == 'origin/master' ? 'master' : checkoutDetails.GIT_BRANCH
|
||||
commitId = checkoutDetails.GIT_COMMIT
|
||||
commitDate = OsTools.runSafe(this, "git show -s --format=%cd --date=format:%Y%m%d-%H%M%S ${commitId}")
|
||||
|
||||
OsTools.runSafe(this, 'git config --global user.email sonatype-ci@sonatype.com')
|
||||
OsTools.runSafe(this, 'git config --global user.name Sonatype CI')
|
||||
|
||||
version = readVersion()
|
||||
|
||||
def apiToken
|
||||
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: credentialsId,
|
||||
usernameVariable: 'GITHUB_API_USERNAME', passwordVariable: 'GITHUB_API_PASSWORD']]) {
|
||||
apiToken = env.GITHUB_API_PASSWORD
|
||||
}
|
||||
gitHub = new GitHub(this, "${organization}/${gitHubRepository}", apiToken)
|
||||
|
||||
if (params.nexus_repository_manager_version && params.nexus_repository_manager_version_sha) {
|
||||
stage('Update Repository Manager Version') {
|
||||
OsTools.runSafe(this, "git checkout ${branch}")
|
||||
dockerFileLocations.each { updateRepositoryManagerVersion(it) }
|
||||
version = getShortVersion(params.nexus_repository_manager_version)
|
||||
}
|
||||
}
|
||||
if (params.nexus_repository_manager_cookbook_version) {
|
||||
stage('Update Repository Manager Cookbook Version') {
|
||||
OsTools.runSafe(this, "git checkout ${branch}")
|
||||
dockerFileLocations.each { updateRepositoryCookbookVersion(it) }
|
||||
}
|
||||
}
|
||||
if (params.oracle_jre_url && params.oracle_jre_sha) {
|
||||
stage('Update JRE Url') {
|
||||
OsTools.runSafe(this, "git checkout ${branch}")
|
||||
dockerFileLocations.each { updateJreUrl(it) }
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Build') {
|
||||
gitHub.statusUpdate commitId, 'pending', 'build', 'Build is running'
|
||||
|
||||
def hash = OsTools.runSafe(this, "docker build --quiet --no-cache --tag ${imageName} .")
|
||||
imageId = hash.split(':')[1]
|
||||
|
||||
if (currentBuild.result == 'FAILURE') {
|
||||
gitHub.statusUpdate commitId, 'failure', 'build', 'Build failed'
|
||||
return
|
||||
} else {
|
||||
gitHub.statusUpdate commitId, 'success', 'build', 'Build succeeded'
|
||||
}
|
||||
}
|
||||
stage('Test') {
|
||||
gitHub.statusUpdate commitId, 'pending', 'test', 'Tests are running'
|
||||
|
||||
def gemInstallDirectory = getGemInstallDirectory()
|
||||
withEnv(["PATH+GEMS=${gemInstallDirectory}/bin"]) {
|
||||
OsTools.runSafe(this, "gem install --user-install rspec")
|
||||
OsTools.runSafe(this, "gem install --user-install serverspec")
|
||||
OsTools.runSafe(this, "gem install --user-install docker-api")
|
||||
OsTools.runSafe(this, "IMAGE_ID=${imageId} rspec --backtrace spec/Dockerfile_spec.rb")
|
||||
}
|
||||
|
||||
if (currentBuild.result == 'FAILURE') {
|
||||
gitHub.statusUpdate commitId, 'failure', 'test', 'Tests failed'
|
||||
return
|
||||
} else {
|
||||
gitHub.statusUpdate commitId, 'success', 'test', 'Tests succeeded'
|
||||
}
|
||||
}
|
||||
if (currentBuild.result == 'FAILURE') {
|
||||
return
|
||||
}
|
||||
if (params.nexus_repository_manager_version && params.nexus_repository_manager_version_sha
|
||||
|| params.nexus_repository_manager_cookbook_version
|
||||
|| params.oracle_jre_url && params.oracle_jre_sha) {
|
||||
stage('Commit Automated Code Update') {
|
||||
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'integrations-github-api',
|
||||
usernameVariable: 'GITHUB_API_USERNAME', passwordVariable: 'GITHUB_API_PASSWORD']]) {
|
||||
def commitMessage = [
|
||||
params.nexus_repository_manager_version && params.nexus_repository_manager_version_sha ?
|
||||
"Update Repository Manager to ${params.nexus_repository_manager_version}." : "",
|
||||
params.nexus_repository_manager_cookbook_version ?
|
||||
"Update Repository Manager Cookbook to ${params.nexus_repository_manager_cookbook_version}." : "",
|
||||
params.oracle_jre_url && params.oracle_jre_sha ?
|
||||
"Update Oracle JRE to ${(params.oracle_jre_url =~ /(\du\d{3}\-b\d{2})/)[0][0]}." : ""
|
||||
].findAll({ it }).join(' ')
|
||||
OsTools.runSafe(this, """
|
||||
git add .
|
||||
git commit -m '${commitMessage}'
|
||||
git push https://${env.GITHUB_API_USERNAME}:${env.GITHUB_API_PASSWORD}@github.com/${organization}/${gitHubRepository}.git ${branch}
|
||||
""")
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Archive') {
|
||||
dir('build/target') {
|
||||
OsTools.runSafe(this, "docker save ${imageName} | gzip > ${archiveName}.tar.gz")
|
||||
archiveArtifacts artifacts: "${archiveName}.tar.gz", onlyIfSuccessful: true
|
||||
}
|
||||
}
|
||||
if (branch != 'master') {
|
||||
return
|
||||
}
|
||||
input 'Push image and tags?'
|
||||
stage('Push image') {
|
||||
def dockerhubApiToken
|
||||
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'docker-hub-credentials',
|
||||
usernameVariable: 'DOCKERHUB_API_USERNAME', passwordVariable: 'DOCKERHUB_API_PASSWORD']]) {
|
||||
OsTools.runSafe(this, "docker tag ${imageId} ${organization}/${dockerHubRepository}:${version}")
|
||||
OsTools.runSafe(this, "docker tag ${imageId} ${organization}/${dockerHubRepository}:latest")
|
||||
OsTools.runSafe(this, """
|
||||
docker login --username ${env.DOCKERHUB_API_USERNAME} --password ${env.DOCKERHUB_API_PASSWORD}
|
||||
""")
|
||||
OsTools.runSafe(this, "docker push ${organization}/${dockerHubRepository}")
|
||||
|
||||
response = OsTools.runSafe(this, """
|
||||
curl -X POST https://hub.docker.com/v2/users/login/ \
|
||||
-H 'cache-control: no-cache' -H 'content-type: application/json' \
|
||||
-d '{ "username": "${env.DOCKERHUB_API_USERNAME}", "password": "${env.DOCKERHUB_API_PASSWORD}" }'
|
||||
""")
|
||||
token = readJSON text: response
|
||||
dockerhubApiToken = token.token
|
||||
|
||||
def readme = readFile file: 'README.md', encoding: 'UTF-8'
|
||||
readme = readme.replaceAll("(?s)<!--.*?-->", "")
|
||||
readme = readme.replace("\"", "\\\"")
|
||||
readme = readme.replace("\n", "\\n")
|
||||
response = httpRequest customHeaders: [[name: 'authorization', value: "JWT ${dockerhubApiToken}"]],
|
||||
acceptType: 'APPLICATION_JSON', contentType: 'APPLICATION_JSON', httpMode: 'PATCH',
|
||||
requestBody: "{ \"full_description\": \"${readme}\" }",
|
||||
url: "https://hub.docker.com/v2/repositories/${organization}/${dockerHubRepository}/"
|
||||
}
|
||||
}
|
||||
stage('Push tags') {
|
||||
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: credentialsId,
|
||||
usernameVariable: 'GITHUB_API_USERNAME', passwordVariable: 'GITHUB_API_PASSWORD']]) {
|
||||
OsTools.runSafe(this, "git tag ${version}")
|
||||
OsTools.runSafe(this, """
|
||||
git push \
|
||||
https://${env.GITHUB_API_USERNAME}:${env.GITHUB_API_PASSWORD}@github.com/${organization}/${gitHubRepository}.git \
|
||||
${version}
|
||||
""")
|
||||
}
|
||||
OsTools.runSafe(this, "git tag -d ${version}")
|
||||
}
|
||||
} finally {
|
||||
OsTools.runSafe(this, "docker logout")
|
||||
OsTools.runSafe(this, "docker system prune -a -f")
|
||||
OsTools.runSafe(this, 'git clean -f && git reset --hard origin/master')
|
||||
}
|
||||
}
|
||||
|
||||
def readVersion() {
|
||||
def content = readFile 'Dockerfile'
|
||||
for (line in content.split('\n')) {
|
||||
if (line.startsWith('ARG NEXUS_VERSION=')) {
|
||||
return getShortVersion(line.substring(18))
|
||||
}
|
||||
}
|
||||
error 'Could not determine version.'
|
||||
}
|
||||
|
||||
def getShortVersion(version) {
|
||||
return version.split('-')[0]
|
||||
}
|
||||
|
||||
def getGemInstallDirectory() {
|
||||
def content = OsTools.runSafe(this, "gem env")
|
||||
for (line in content.split('\n')) {
|
||||
if (line.startsWith(' - USER INSTALLATION DIRECTORY: ')) {
|
||||
return line.substring(33)
|
||||
}
|
||||
}
|
||||
error 'Could not determine user gem install directory.'
|
||||
}
|
||||
|
||||
def updateRepositoryManagerVersion(dockerFileLocation) {
|
||||
def dockerFile = readFile(file: dockerFileLocation)
|
||||
|
||||
def metaVersionRegex = /(version=")(\d\.\d{1,3}\.\d\-\d{2})(" \\)/
|
||||
def metaShortVersionRegex = /(release=")(\d\.\d{1,3}\.\d)(" \\)/
|
||||
|
||||
def versionRegex = /(ARG NEXUS_VERSION=)(\d\.\d{1,3}\.\d\-\d{2})/
|
||||
def shaRegex = /(ARG NEXUS_DOWNLOAD_SHA256_HASH=)([A-Fa-f0-9]{64})/
|
||||
|
||||
dockerFile = dockerFile.replaceAll(metaVersionRegex, "\$1${params.nexus_repository_manager_version}\$3")
|
||||
dockerFile = dockerFile.replaceAll(metaShortVersionRegex,
|
||||
"\$1${params.nexus_repository_manager_version.substring(0, params.nexus_repository_manager_version.indexOf('-'))}\$3")
|
||||
dockerFile = dockerFile.replaceAll(versionRegex, "\$1${params.nexus_repository_manager_version}")
|
||||
dockerFile = dockerFile.replaceAll(shaRegex, "\$1${params.nexus_repository_manager_version_sha}")
|
||||
|
||||
writeFile(file: dockerFileLocation, text: dockerFile)
|
||||
}
|
||||
|
||||
def updateRepositoryCookbookVersion(dockerFileLocation) {
|
||||
def dockerFile = readFile(file: dockerFileLocation)
|
||||
|
||||
def cookbookVersionRegex = /(ARG NEXUS_REPOSITORY_MANAGER_COOKBOOK_VERSION=")(release-\d\.\d\.\d{8}\-\d{6}\.[a-z0-9]{7})(")/
|
||||
|
||||
dockerFile = dockerFile.replaceAll(cookbookVersionRegex, "\$1${params.nexus_repository_manager_cookbook_version}\$3")
|
||||
|
||||
writeFile(file: dockerFileLocation, text: dockerFile)
|
||||
}
|
||||
|
||||
def updateJreUrl(dockerFileLocation) {
|
||||
def dockerFile = readFile(file: dockerFileLocation)
|
||||
|
||||
def jreUrlRegex = /(ARG JAVA_URL=)(http.*-linux-x64\.tar\.gz)/
|
||||
def jreShaRegex = /(JAVA_DOWNLOAD_SHA256_HASH=)([A-Fa-f0-9]{64})/
|
||||
|
||||
dockerFile = dockerFile.replaceAll(jreUrlRegex, "\$1${params.oracle_jre_url}")
|
||||
dockerFile = dockerFile.replaceAll(jreShaRegex, "\$1${params.oracle_jre_sha}")
|
||||
|
||||
writeFile(file: dockerFileLocation, text: dockerFile)
|
||||
}
|
||||
@@ -23,18 +23,21 @@
|
||||
A Dockerfile for Sonatype Nexus Repository Manager 3, based on CentOS.
|
||||
|
||||
* [Contribution Guidlines](#contribution-guidelines)
|
||||
* [Running and Building](#running-and-building)
|
||||
* [Running](#running)
|
||||
* [Building the Nexus Repository Manager image](#building-the-nexus-repository-manager-image)
|
||||
* [Chef Solo for Runtime and Application](#chef-solo-for-runtime-and-application)
|
||||
* [Testing the Dockerfile](#testing-the-dockerfile)
|
||||
* [Red Hat Certified Image](#red-hat-certified-image)
|
||||
* [Notes](#notes)
|
||||
* [Persistent Data](#persistent-data)
|
||||
* [Build Args](#build-args)
|
||||
* [Getting Help](#getting-help)
|
||||
|
||||
## Contribution Guidelines
|
||||
|
||||
Go read [our contribution guidelines](/.github/CONTRIBUTING.md) to get a bit more familiar with how
|
||||
Go read [our contribution guidelines](https://github.com/sonatype/docker-nexus3/blob/master/.github/CONTRIBUTING.md) to get a bit more familiar with how
|
||||
we would like things to flow.
|
||||
|
||||
## Running And Building
|
||||
## Running
|
||||
|
||||
To run, binding the exposed port 8081 to the host.
|
||||
|
||||
@@ -48,14 +51,46 @@ To test:
|
||||
$ curl -u admin:admin123 http://localhost:8081/service/metrics/ping
|
||||
```
|
||||
|
||||
To (re)build the image:
|
||||
## Building the Nexus Repository Manager image
|
||||
|
||||
Copy the Dockerfile and do the build-
|
||||
To build a docker image from the Docker file you can use this command:
|
||||
|
||||
```
|
||||
$ docker build --rm=true --tag=sonatype/nexus3 .
|
||||
```
|
||||
|
||||
The following optional variables can be used when building the image:
|
||||
|
||||
- NEXUS_VERSION: Version of the Nexus Repository Manager
|
||||
- NEXUS_DOWNLOAD_URL: Download URL for Nexus Repository, alternative to using `NEXUS_VERSION` to download from Sonatype
|
||||
- NEXUS_DOWNLOAD_SHA256_HASH: Sha256 checksum for the downloaded Nexus Repository Manager archive. Required if `NEXUS_VERSION`
|
||||
or `NEXUS_DOWNLOAD_URL` is provided
|
||||
|
||||
## Chef Solo for Runtime and Application
|
||||
|
||||
Chef Solo is used to build out the runtime and application layers of the Docker image. The Chef cookbook being used is available
|
||||
on GitHub at [sonatype/chef-nexus-repository-manager](https://github.com/sonatype/chef-nexus-repository-manager).
|
||||
|
||||
## Testing the Dockerfile
|
||||
|
||||
We are using `rspec` as the test framework. `serverspec` provides a docker backend (see the method `set` in the test code)
|
||||
to run the tests inside the docker container, and abstracts away the difference between distributions in the tests
|
||||
(e.g. yum, apt,...).
|
||||
|
||||
rspec [--backtrace] spec/Dockerfile_spec.rb
|
||||
|
||||
## Red Hat Certified Image
|
||||
|
||||
A Red Hat certified container image can be created using `Dockerfile.rh.el` which is built to be compliant with Red Hat certification.
|
||||
The image includes additional meta data to comform with Kubernetes and OpenShift standards, a directory with the
|
||||
licenses applicable to the software and a man file for help on how to use the software. It also uses an ENTRYPOINT
|
||||
script the ensure the running user has access to the appropriate permissions for OpenShift 'restricted' SCC. In addition to the
|
||||
Red Hat Enterprise Linux image, `Dockerfile.rh.centos` provides the same additions but with a CentOS base.
|
||||
|
||||
The Red Hat certified container image is available from the
|
||||
[Red Hat Container Catalog](https://access.redhat.com/containers/#/registry.connect.redhat.com/sonatype/nexus-repository-manager)
|
||||
and qualified accounts can pull it from registry.connect.redhat.com.
|
||||
|
||||
## Notes
|
||||
|
||||
* Default credentials are: `admin` / `admin123`
|
||||
@@ -73,16 +108,19 @@ $ docker logs -f nexus
|
||||
logs, and storage. This directory needs to be writable by the Nexus
|
||||
process, which runs as UID 200.
|
||||
|
||||
* There is an environment variable that can used to pass JVM arguments to the startup script
|
||||
* There is an environment variable that is being used to pass JVM arguments to the startup script
|
||||
|
||||
* `INSTALL4J_ADD_VM_PARAMS`, passed to the Install4J startup script. Defaults to `-Xms1200m -Xmx1200m`.
|
||||
* `INSTALL4J_ADD_VM_PARAMS`, passed to the Install4J startup script. Defaults to `-Xms1200m -Xmx1200m -XX:MaxDirectMemorySize=2g -Djava.util.prefs.userRoot=${NEXUS_DATA}/javaprefs`.
|
||||
|
||||
This can be supplied at runtime:
|
||||
This can be adjusted at runtime:
|
||||
|
||||
```
|
||||
$ docker run -d -p 8081:8081 --name nexus -e INSTALL4J_ADD_VM_PARAMS="-Xms2g -Xmx2g" sonatype/nexus3
|
||||
$ docker run -d -p 8081:8081 --name nexus -e INSTALL4J_ADD_VM_PARAMS="-Xms2g -Xmx2g -XX:MaxDirectMemorySize=3g -Djava.util.prefs.userRoot=/some-other-dir" sonatype/nexus3
|
||||
```
|
||||
|
||||
Of particular note, `-Djava.util.prefs.userRoot=/some-other-dir` can be set to a persistent path, which will maintain
|
||||
the installed Nexus Repository License if the container is restarted.
|
||||
|
||||
* Another environment variable can be used to control the Nexus Context Path
|
||||
|
||||
* `NEXUS_CONTEXT`, defaults to /
|
||||
@@ -99,8 +137,7 @@ There are two general approaches to handling persistent storage requirements
|
||||
with Docker. See [Managing Data in Containers](https://docs.docker.com/engine/tutorials/dockervolumes/)
|
||||
for additional information.
|
||||
|
||||
1. *Use a data volume*. Since data volumes are persistent
|
||||
until no containers use them, a volume can be created specifically for
|
||||
1. *Use a docker volume*. Since docker volumes are persistent, a volume can be created specifically for
|
||||
this purpose. This is the recommended approach.
|
||||
|
||||
```
|
||||
@@ -118,16 +155,6 @@ for additional information.
|
||||
$ docker run -d -p 8081:8081 --name nexus -v /some/dir/nexus-data:/nexus-data sonatype/nexus3
|
||||
```
|
||||
|
||||
### Build Args
|
||||
|
||||
The Dockerfile contains two build arguments (`NEXUS_VERSION` & `NEXUS_DOWNLOAD_URL`) that can be used to customize what
|
||||
version of, and from where, Nexus Repository Manager is downloaded. This is useful mostly for testing purposes as the
|
||||
Dockerfile may be dependent on a very specific version of Nexus Repository Manager.
|
||||
|
||||
```
|
||||
docker build --rm --tag nexus-custom --build-arg NEXUS_VERSION=3.x.y --build-arg NEXUS_DOWNLOAD_URL=http://.../nexus-3.x.y-unix.tar.gz .
|
||||
```
|
||||
|
||||
## Getting Help
|
||||
|
||||
Looking to contribute to our Docker image but need some help? There's a few ways to get information or our attention:
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
// Copyright (c) 2016-present Sonatype, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
<%=
|
||||
require 'json'
|
||||
|
||||
raise RuntimeError, 'environment variable DOCKER_TYPE is required' if ENV['DOCKER_TYPE'].nil? || ENV['DOCKER_TYPE'].empty?
|
||||
raise RuntimeError, 'environment variable SONATYPE_DIR is required' if ENV['SONATYPE_DIR'].nil? || ENV['SONATYPE_DIR'].empty?
|
||||
raise RuntimeError, 'environment variable NEXUS_HOME is required' if ENV['NEXUS_HOME'].nil? || ENV['NEXUS_HOME'].empty?
|
||||
raise RuntimeError, 'environment variable NEXUS_DATA is required' if ENV['NEXUS_DATA'].nil? || ENV['NEXUS_DATA'].empty?
|
||||
|
||||
{
|
||||
:run_list => [ "recipe[nexus_repository_manager::#{ENV['DOCKER_TYPE']}]" ],
|
||||
:java => {
|
||||
:jdk_version => ENV['JAVA_VERSION_MAJOR'],
|
||||
:java_home => ENV['JAVA_HOME'],
|
||||
:install_flavor => 'oracle',
|
||||
:oracle => {
|
||||
:accept_oracle_download_terms => true
|
||||
},
|
||||
:jdk => {
|
||||
:'8' => {
|
||||
:x86_64 => {
|
||||
:url => ENV['JAVA_URL'],
|
||||
:checksum => ENV['JAVA_DOWNLOAD_SHA256_HASH']
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
:nexus_repository_manager => {
|
||||
:version => ENV['NEXUS_VERSION'],
|
||||
:nexus_download_url => ENV['NEXUS_DOWNLOAD_URL'],
|
||||
:nexus_download_sha256 => ENV['NEXUS_DOWNLOAD_SHA256_HASH'],
|
||||
:sonatype => {
|
||||
:path => ENV['SONATYPE_DIR'],
|
||||
},
|
||||
:sonatype_work => {
|
||||
:path => ENV['SONATYPE_DIR'] + '/sonatype-work'
|
||||
},
|
||||
:nexus_home => {
|
||||
:path => ENV['SONATYPE_DIR'] + '/nexus'
|
||||
},
|
||||
:nexus_data => {
|
||||
:path => ENV['NEXUS_DATA']
|
||||
},
|
||||
:properties => {
|
||||
# Set the context_path to the NEXUS_CONTEXT environment variable
|
||||
# that may be passed into the docker run command.
|
||||
:context_path => "/${NEXUS_CONTEXT}"
|
||||
}
|
||||
}
|
||||
}.to_json
|
||||
%>
|
||||
@@ -0,0 +1,44 @@
|
||||
# Copyright (c) 2016-present Sonatype, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
require "serverspec"
|
||||
require "docker"
|
||||
|
||||
describe 'Dockerfile' do
|
||||
before(:all) do
|
||||
Docker.options[:read_timeout] = 900
|
||||
@image = Docker::Image.get(ENV['IMAGE_ID'])
|
||||
|
||||
set :os, family: :redhat
|
||||
set :backend, :docker
|
||||
set :docker_image, @image.id
|
||||
end
|
||||
|
||||
it 'should remove solo.json during cleanup' do
|
||||
expect(File).not_to exist('/var/chef/solo.json')
|
||||
end
|
||||
|
||||
it 'should not have a chef package installed' do
|
||||
expect(package('chef')).not_to be_installed
|
||||
end
|
||||
|
||||
it 'should have a user named nexus' do
|
||||
expect(user('nexus')).to exist
|
||||
end
|
||||
|
||||
it 'should have a nexus process running' do
|
||||
expect(process('java')).to be_running
|
||||
expect(process('java')).to have_attributes(:user => 'nexus')
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user