added 3rd test image and made build more generic

This commit is contained in:
Manuel Vogel 2018-04-09 20:31:09 +02:00
parent 37e3301e98
commit 9e643ac13d
No known key found for this signature in database
GPG key ID: 533006C7B61DB1CE
5 changed files with 28 additions and 12 deletions

View file

@ -2,5 +2,5 @@ FROM node:6.12.3-slim
EXPOSE 8080
COPY configs.json .
COPY secrets.json .
COPY server.js .
CMD node server.js
COPY server_v1.js .
CMD node server_v1.js

View file

@ -0,0 +1,6 @@
FROM node:6.12.3-slim
EXPOSE 8080
COPY configs.json .
COPY secrets.json .
COPY server_v3.js .
CMD node server_v3.js

View file

@ -0,0 +1,11 @@
var http = require('http');
var configs = require('./configs')
var secrets = require('./secrets')
var handleRequest = function (request, response) {
console.log('Received request for URL: ' + request.url);
response.writeHead(200);
response.end(configs.prefix + ' - Hello World!');
};
var www = http.createServer(handleRequest);
www.listen(8085); // changed here on purpose

View file

@ -1,8 +1,9 @@
#!/bin/bash
set -e
# Create private registry
## Create self signed certs
mkdir -p scripts/testing/certs
mkdir -p "$(pwd)"/scripts/testing/certs
openssl req \
-newkey rsa:2048 \
-nodes \
@ -12,9 +13,9 @@ openssl req \
-keyout "$(pwd)"/scripts/testing/certs/registry_auth.key \
-out "$(pwd)"/scripts/testing/certs/registry_auth.crt
## Create auth
mkdir -p scripts/testing/auth
mkdir -p "$(pwd)"/scripts/testing/auth
# Start registry
docker run --entrypoint htpasswd registry:2 -Bbn testuser testpwd > "$(pwd)"/scripts/testing/auth/htpasswd
docker run --rm --entrypoint htpasswd registry:2 -Bbn testuser testpwd > "$(pwd)"/scripts/testing/auth/htpasswd
docker run -d -p 15000:5000 --rm --name private_registry \
-v "$(pwd)"/scripts/testing/auth:/auth \
-e "REGISTRY_AUTH=htpasswd" \
@ -29,10 +30,8 @@ sleep 5
# Login to private registry
docker login -u testuser -p testpwd 127.0.0.1:15000
# Build private images
docker build -t my-private-service "$(pwd)"/scripts/testing -f "$(pwd)"/scripts/testing/Dockerfile_v1
docker tag my-private-service 127.0.0.1:15000/my-private-service:v1
docker build -t my-private-service "$(pwd)"/scripts/testing -f "$(pwd)"/scripts/testing/Dockerfile_v2
docker tag my-private-service 127.0.0.1:15000/my-private-service:v2
# Push private images into private registry
docker push 127.0.0.1:15000/my-private-service:v1
docker push 127.0.0.1:15000/my-private-service:v2
for i in $(seq 1 3); do
docker build -t tftest-service "$(pwd)"/scripts/testing -f "$(pwd)"/scripts/testing/Dockerfile_v${i}
docker tag tftest-service 127.0.0.1:15000/tftest-service:v${i}
docker push 127.0.0.1:15000/tftest-service:v${i}
done