Skip to content

Commit c193082

Browse files
committed
Switch demo to use version 2 of the Docker registry.
1 parent 9df95a1 commit c193082

11 files changed

+22
-77
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
target
22
work
3-
demo/snapshot-plugins/
43
.idea
54
*.iml

demo/.dockerignore

-1
This file was deleted.

demo/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
snapshot-plugins/
2+
certs/

demo/Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ RUN /usr/local/maven/bin/mvn -s settings.xml -Dmaven.repo.local=/usr/share/jenki
3737
COPY plugins.txt /tmp/files/
3838
RUN /usr/local/bin/plugins.sh /tmp/files/plugins.txt
3939

40+
# Remove the base workflow-demo "cd" job
41+
RUN rm -rf /usr/share/jenkins/ref/jobs/cd
42+
4043
ADD JENKINS_HOME /usr/share/jenkins/ref
4144

4245
COPY run-demo.sh /usr/local/bin/run-demo.sh

demo/Dockerfile-proxy

-6
This file was deleted.

demo/Dockerfile-registry

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM registry:2.5.1
2+
ADD certs/ca.crt certs/ca.key certs/docker-registry.htpasswd /var/registry/certs/
3+
ENV REGISTRY_HTTP_TLS_CERTIFICATE /var/registry/certs/ca.crt
4+
ENV REGISTRY_HTTP_TLS_KEY /var/registry/certs/ca.key
5+
ENV REGISTRY_AUTH htpasswd
6+
ENV REGISTRY_AUTH_HTPASSWD_REALM Registry Realm
7+
ENV REGISTRY_AUTH_HTPASSWD_PATH /var/registry/certs/docker-registry.htpasswd

demo/JENKINS_HOME/credentials.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<scope>GLOBAL</scope>
1111
<id>docker-registry-login</id>
1212
<description></description>
13-
<username>workflowuser</username>
13+
<username>pipelineuser</username>
1414
<password>123123123</password>
1515
</com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl>
1616
</java.util.concurrent.CopyOnWriteArrayList>

demo/Makefile

+5-4
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@
2525
TAG=$(shell perl -n -e 'if (/docker-workflow:(.+)/) {print $$1}' plugins.txt)
2626
IMAGE=jenkinsci/docker-workflow-demo
2727

28-
build-proxy:
29-
docker build -t nginx:docker-workflow-demo -f Dockerfile-proxy .
28+
build-registry:
29+
./gen-security-data.sh certs
30+
docker build -t registry:docker-workflow-demo -f Dockerfile-registry .
3031

3132
# Builds a demo based on a released version of the plugin.
32-
build: build-proxy
33+
build: build-registry
3334
docker build -t $(IMAGE):$(TAG) .
3435

3536
# Builds a demo based on the current local snapshot build of the plugin.
@@ -55,7 +56,7 @@ run-snapshot: build-snapshot
5556
$(DOCKER_RUN) $(IMAGE):SNAPSHOT
5657

5758
clean:
58-
rm -rf snapshot-plugins
59+
rm -rf certs snapshot-plugins
5960

6061
push:
6162
docker push $(IMAGE):$(TAG)

demo/gen-security-data.sh

+2-19
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,9 @@ mkdir -p $1
3131

3232
pushd $1
3333

34-
htpasswd -bmc docker-registry.htpasswd workflowuser 123123123
34+
docker run --entrypoint htpasswd registry:2.5.1 -Bbn pipelineuser 123123123 > docker-registry.htpasswd
3535

3636
# Create the CA Key and Certificate for signing Certs
3737
openssl genrsa -des3 -passout pass:x -out ca.key 4096
3838
openssl rsa -passin pass:x -in ca.key -out ca.key # remove password!
39-
openssl req -new -x509 -days 365 -key ca.key -out ca.crt -subj "/C=US/ST=California/L=San Jose/O=Jenkins CI/OU=Workflow Dept/CN=localhost"
40-
41-
# Create the Server Key, CSR, and Certificate
42-
openssl genrsa -des3 -passout pass:x -out key.pem 1024
43-
openssl rsa -passin pass:x -in key.pem -out key.pem # remove password!
44-
openssl req -new -key key.pem -out server.csr -subj "/C=US/ST=California/L=San Jose/O=Jenkins CI/OU=Workflow Dept/CN=localhost"
45-
46-
# Self sign the server cert.
47-
openssl x509 -req -days 365 -in server.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out cert.pem
48-
49-
# cat the ca cert onto the server cert
50-
cat ca.crt >> cert.pem
51-
52-
# White-list the CA cert (because it is self-signed), otherwise docker client will not be able to authenticate
53-
cp ca.crt /usr/local/share/ca-certificates
54-
update-ca-certificates
55-
56-
popd
39+
openssl req -new -x509 -days 365 -key ca.key -out ca.crt -subj "/C=US/ST=California/L=San Jose/O=Jenkins CI/OU=Pipeline Dept/CN=localhost"

demo/run-demo.sh

+2-8
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@
3131
echo '*************** Installing a local Docker Registry Service for the demo ***************'
3232
echo '*************** Please sit tight for a minute ***************'
3333

34-
cont1=$(docker run -d --name registry --restart=always registry:0.9.1)
35-
cont2=$(docker run -d -p 443:443 --name wf-registry-proxy --link registry:registry nginx:docker-workflow-demo)
34+
cont1=$(docker run -d -p 443:5000 --name registry --restart=always registry:docker-workflow-demo)
3635
# TODO would be natural to switch to Compose
37-
trap "docker rm -f $cont1 $cont2" EXIT
36+
trap "docker rm -f $cont1" EXIT
3837

3938
# Note that this https://github.com/docker/docker/issues/23177 workaround is useless since the Docker CLI does not do the hostname resolution, the server does:
4039
# echo $(docker inspect -f '{{.NetworkSettings.Gateway}}' $HOSTNAME) docker.example.com >> /etc/hosts
@@ -44,11 +43,6 @@ echo '*************** Docker Registry Service running now **
4443
# In case some tagged images were left over from a previous run using a cache:
4544
(docker images -q examplecorp/spring-petclinic; docker images -q localhost/examplecorp/spring-petclinic) | xargs docker rmi --no-prune=true --force
4645

47-
#
48-
# Remove the base workflow-demo "cd" job
49-
#
50-
rm -rf /usr/share/jenkins/ref/jobs/cd /var/jenkins_home/jobs/cd
51-
5246
#
5347
# Now run Jenkins.
5448
#

demo/workflow-reg-proxy.conf

-37
This file was deleted.

0 commit comments

Comments
 (0)