compose the basics

This commit is contained in:
nora 2022-09-03 21:03:33 +02:00
parent 99d5edbb94
commit c97168fe00
4 changed files with 62 additions and 3 deletions

15
docker/compose.sh Executable file
View file

@ -0,0 +1,15 @@
#!/usr/bin/env bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
if [ "$STAGE" = "prod" ] ;
then
export NGINX_CONF_PATH=../nginx/nginx.conf
EXTRA_ARGS="-f $SCRIPT_DIR/production.yml"
else
export NGINX_CONF_PATH=../nginx/nginx.local.conf
fi
export REGISTRY_CONF_DIR=../registry
docker compose -f "$SCRIPT_DIR/docker-compose.yml" $@ up -d

24
docker/docker-compose.yml Normal file
View file

@ -0,0 +1,24 @@
version: '3.3'
services:
nginx:
container_name: nginx-c
restart: always
image: nginx:latest
ports:
- "80:80"
volumes:
- "${NGINX_CONF_PATH}:/etc/nginx/nginx.conf:ro"
networks:
- internal
registry:
container_name: registry-c
restart: always
image: registry:2
volumes:
- "${REGISTRY_CONF_DIR}/config.yml:/etc/docker/registry/config.yml"
- "/var/lib/docker/registry:/var/lib/registry"
networks:
- internal
networks:
internal:

17
docker/production.yml Normal file
View file

@ -0,0 +1,17 @@
version: '3.3'
services:
nginx:
volumes:
- "/etc/letsencrypt:/etc/nginx/certs:ro"
ports:
- "443:443"
registry:
volumes:
- "/etc/letsencrypt:/etc/letsencrypt"
- "/etc/htpasswd:/htpasswd"
environment:
- REGISTRY_HTTP_TLS_CERTIFICATE=/etc/letsencrypt/live/nilstrieb.dev/fullchain.pem
- REGISTRY_HTTP_TLS_KEY=/etc/letsencrypt/live/nilstrieb.dev/privkey.pem
- REGISTRY_AUTH=htpasswd
- REGISTRY_AUTH_HTPASSWD_REALM=Realm
- REGISTRY_AUTH_HTPASSWD_PATH=/htpasswd

View file

@ -15,11 +15,12 @@ http {
listen 80; listen 80;
server_name "docker.nilstrieb.dev"; server_name "docker.nilstrieb.dev";
set $target "http://registry:5000/";
client_max_body_size 0; client_max_body_size 0;
location / { location / {
proxy_pass http://registry:5000/; proxy_pass $target;
} }
} }
@ -27,9 +28,10 @@ http {
listen 80; listen 80;
server_name "cors-school.nilstrieb.dev"; server_name "cors-school.nilstrieb.dev";
set $target "http://cors-school-frontend/";
location / { location / {
proxy_pass http://cors-school-frontend/; proxy_pass $target;
} }
} }
@ -37,9 +39,10 @@ http {
listen 80; listen 80;
server_name "api.cors-school.nilstrieb.dev"; server_name "api.cors-school.nilstrieb.dev";
set $target "http://cors-school-backend:8080/";
location / { location / {
proxy_pass http://cors-school-backend:8080/; proxy_pass $target;
add_header Access-Control-Allow-Origin cors-school.nilstrieb.dev; add_header Access-Control-Allow-Origin cors-school.nilstrieb.dev;
} }
} }