diff --git a/Dockerfiles/Dockerfile_devserver b/Dockerfiles/Dockerfile_devserver new file mode 100644 index 0000000..9a612ed --- /dev/null +++ b/Dockerfiles/Dockerfile_devserver @@ -0,0 +1,12 @@ +FROM nginx:stable-alpine +COPY --chmod=0440 ["./locations", "/etc/nginx/locations"] +COPY --chmod=0440 ["./configuration", "/etc/nginx/configuration"] +COPY --chmod=0440 ["./error-pages", "/etc/nginx/error-pages"] +COPY --chmod=0440 ["./resources", "/var/www/html/resources"] +COPY --chmod=0440 ["./resources", "/var/www/html/resources"] +COPY --chmod=0440 ["./nginx_configs/nginx.conf", "/etc/nginx/nginx.conf"] + +ARG CONT_IMG_VER +ENV CONT_IMG_VER=${CONT_IMG_VER:-v1.0.0} + +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/Dockerfiles/Dockerfile_staticsite b/Dockerfiles/Dockerfile_staticsite index 49e0fd4..ef2b812 100644 --- a/Dockerfiles/Dockerfile_staticsite +++ b/Dockerfiles/Dockerfile_staticsite @@ -2,17 +2,16 @@ #ARGS: SERVER_NAMES, CERT_FILE, CERT_KEY_FILE, CONT_IMG_VER FROM nginx:stable-alpine +USER nginx +EXPOSE 80 443 -#http to https redirect -COPY sites-enabled/http_redirect.conf /etc/nginx/sites-enabled/ - -#site config -COPY docker_image_configs/static.conf.tmpl /etc/nginx/sites-enabled/static.conf +#static site + http to https redirect server +COPY ./nginx_configs/nginx_static.conf /etc/nginx/nginx.conf #set server name if arg not empty ARG SERVER_NAMES RUN if [ ! -z ${SERVER_NAMES} ]; then \ - sed -i "s/server_name _;/server_name $SERVER_NAMES;/g" /etc/nginx/sites-enabled/static.conf ;\ + sed -i "s/server_name _;/server_name $SERVER_NAMES;/g" /etc/nginx/nginx.conf ;\ fi #set certificate file name if arg not empty diff --git a/compose_extends/docker-compose.base.yaml b/compose_extends/docker-compose.base.yaml index 1913f27..75ab8a0 100644 --- a/compose_extends/docker-compose.base.yaml +++ b/compose_extends/docker-compose.base.yaml @@ -4,3 +4,5 @@ services: container_name: reverse hostname: reverse restart: always + extra_hosts: + - "host.docker.internal=host-gateway" diff --git a/control.sh b/control.sh new file mode 100644 index 0000000..b251e47 --- /dev/null +++ b/control.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +#exec 0out.log +#exec 2>logs/error.log + +root_folder=`pwd` + +menu=" +[1] up dev reverse +[2] restart dev reverse +[3] down dev reverse +[4] ps dev reverse +" +input="" +while true +do + echo "$menu" + echo -n "Select function № on enter q to exit:\n" + read input + + if [ $input = "q" ] + then + break; + fi + + case "$input" in + 1) docker compose -f docker-compose-devserver.yaml -f docker-compose.limits.yaml up -d;break ;; + 2) docker compose -f docker-compose-devserver.yaml -f docker-compose.limits.yaml down && \ + docker compose -f docker-compose-devserver.yaml -f docker-compose.limits.yaml up -d;break ;; + 3) docker compose -f docker-compose-devserver.yaml -f docker-compose.limits.yaml down;break ;; + 4) docker compose -f docker-compose-devserver.yaml -f docker-compose.limits.yaml ps;break ;; + *) echo "key not found" + esac +done + +echo "end of the script" diff --git a/docker-compose-devserver.yaml b/docker-compose-devserver.yaml new file mode 100644 index 0000000..d6a6df2 --- /dev/null +++ b/docker-compose-devserver.yaml @@ -0,0 +1,38 @@ +name: reverse_dev +include: + - path: + - compose_extends/network.include.yaml + +services: + reverse: + extends: + file: compose_extends/docker-compose.base.yaml + service: reverse + build: + context: . + dockerfile: Dockerfiles/Dockerfile_devserver + args: + CONT_IMG_VER: "v1.0.0" + pull_policy: missing + volumes: + - "./sites-enabled:/etc/nginx/sites-enabled:ro" + ports: + - 80:80 + - 443:443 + networks: + - services + secrets: + - source: softsols_cert + target: /etc/nginx/ssl/live/softsols.ru/fullchain.pem + - source: softsols_key + target: /etc/nginx/ssl/live/softsols.ru/privkey.pem + +secrets: + softsols_cert: + name: softsols_cert + file: ./ssl/live/softsols.ru/fullchain.pem + external: false + softsols_key: + name: softsols_key + file: ./ssl/live/softsols.ru/privkey.pem + external: false \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index 4dcfaa8..ccf3a58 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,3 +1,4 @@ +name: reverse_default include: - path: - compose_extends/network.include.yaml @@ -7,10 +8,7 @@ services: extends: file: compose_extends/docker-compose.base.yaml service: reverse - extra_hosts: - - "host.docker.internal=host-gateway" volumes: - - "./nginx.conf:/etc/nginx/nginx.conf:ro" - "./locations:/etc/nginx/locations:ro" - "./configuration:/etc/nginx/configuration:ro" - "./sites-enabled:/etc/nginx/sites-enabled:ro" @@ -22,4 +20,13 @@ services: - 80:80 - 443:443 networks: - - services \ No newline at end of file + - services + configs: + - source: nginx_config + target: /etc/nginx/nginx.conf + +configs: + nginx_config: + name: times_new_nginx_config + file: ./nginx_config/nginx.conf + external: false diff --git a/docker_image_configs/static.conf.tmpl b/docker_image_configs/static.conf.tmpl deleted file mode 100644 index 4a73ca1..0000000 --- a/docker_image_configs/static.conf.tmpl +++ /dev/null @@ -1,20 +0,0 @@ -server { - listen 443 ssl; - listen [::]:443 ssl; - http2 on; - - server_name _; - - ssl_certificate /etc/nginx/ssl/cert.pem; - ssl_certificate_key /etc/nginx/ssl/key.pem; - ssl_protocols TLSv1.2 TLSv1.3; - ssl_ciphers HIGH:!aNULL:!MD5; - ssl_prefer_server_ciphers on; - include configuration/_includes.conf; - - location / { - root /var/www/html/; - index index.html; - try_files $uri $uri/ =404; - } -} \ No newline at end of file diff --git a/nginx.conf b/nginx_configs/nginx.conf similarity index 100% rename from nginx.conf rename to nginx_configs/nginx.conf