diff --git a/docker/setup_net.sh b/docker/setup_net.sh new file mode 100755 index 0000000..eb391dc --- /dev/null +++ b/docker/setup_net.sh @@ -0,0 +1,9 @@ +NET_NAME="internal" + +if docker network inspect "$NET_NAME" > /dev/null 2>&1 ; +then + echo "Network $NET_NAME exists already..."; +else + echo "Creating network $NET_NAME..." + docker network create "$NET_NAME" +fi diff --git a/full_setup.sh b/full_setup.sh new file mode 100755 index 0000000..5634684 --- /dev/null +++ b/full_setup.sh @@ -0,0 +1,4 @@ +./docker/setup_net.sh + +./registry/run.sh +./nginx/run.sh \ No newline at end of file diff --git a/nginx/nginx.conf b/nginx/nginx.conf index 6709d63..860d2c3 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -6,10 +6,8 @@ http { server { listen 80; - location / { - return 200 'Hell, World!'; - add_header Content-Type text/plain; - } + server_name nilstrieb.dev; + return 302 http://blog.nilstrieb.dev$request_uri; } server { @@ -18,7 +16,8 @@ http { server_name registry.nilstrieb.dev; location / { - proxy_pass http://registry:5000/; + return 404 'No registry here...'; + #proxy_pass http://registry:5000/; } } diff --git a/nginx/run.sh b/nginx/run.sh index 125d147..d3a475f 100755 --- a/nginx/run.sh +++ b/nginx/run.sh @@ -1,6 +1,14 @@ #!/usr/bin/env bash -docker run -d -p 8080:80 --restart=always --name nginx \ - -v `pwd`/nginx.conf:/etc/nginx/nginx.conf:ro \ - $@ \ - nginx:latest \ No newline at end of file +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + + +if docker inspect nginx > /dev/null 2>&1 ; +then + echo "Registry container exists already..." +else + docker run -d -p 8080:80 --restart=always --name nginx \ + -v "$SCRIPT_DIR/nginx.conf:/etc/nginx/nginx.conf:ro" \ + --net internal \ + nginx:latest +fi \ No newline at end of file diff --git a/registry/run.sh b/registry/run.sh index ab5ec0d..9847c1b 100755 --- a/registry/run.sh +++ b/registry/run.sh @@ -1,6 +1,13 @@ #!/usr/bin/env bash -docker run -d -p 5000:5000 --restart=always --name registry \ - -v `pwd`/config.yml:/etc/docker/registry/config.yml \ - $@ \ - registry:2 \ No newline at end of file +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +if docker inspect registry > /dev/null 2>&1 ; +then + echo "Registry container exists already..." +else + docker run -d -p 5000:5000 --restart=always --name registry \ + -v "$SCRIPT_DIR/config.yml:/etc/docker/registry/config.yml" \ + --net internal \ + registry:2 +fi \ No newline at end of file