times_new_nginx-devserver

This commit is contained in:
perl 2024-10-05 07:22:27 +03:00
parent 02149a10da
commit 1c51fd54ab
8 changed files with 105 additions and 30 deletions

View File

@ -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;"]

View File

@ -2,17 +2,16 @@
#ARGS: SERVER_NAMES, CERT_FILE, CERT_KEY_FILE, CONT_IMG_VER #ARGS: SERVER_NAMES, CERT_FILE, CERT_KEY_FILE, CONT_IMG_VER
FROM nginx:stable-alpine FROM nginx:stable-alpine
USER nginx
EXPOSE 80 443
#http to https redirect #static site + http to https redirect server
COPY sites-enabled/http_redirect.conf /etc/nginx/sites-enabled/ COPY ./nginx_configs/nginx_static.conf /etc/nginx/nginx.conf
#site config
COPY docker_image_configs/static.conf.tmpl /etc/nginx/sites-enabled/static.conf
#set server name if arg not empty #set server name if arg not empty
ARG SERVER_NAMES ARG SERVER_NAMES
RUN if [ ! -z ${SERVER_NAMES} ]; then \ 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 fi
#set certificate file name if arg not empty #set certificate file name if arg not empty

View File

@ -4,3 +4,5 @@ services:
container_name: reverse container_name: reverse
hostname: reverse hostname: reverse
restart: always restart: always
extra_hosts:
- "host.docker.internal=host-gateway"

37
control.sh Normal file
View File

@ -0,0 +1,37 @@
#!/bin/bash
#exec 0<data
#exec 1>out.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"

View File

@ -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

View File

@ -1,3 +1,4 @@
name: reverse_default
include: include:
- path: - path:
- compose_extends/network.include.yaml - compose_extends/network.include.yaml
@ -7,10 +8,7 @@ services:
extends: extends:
file: compose_extends/docker-compose.base.yaml file: compose_extends/docker-compose.base.yaml
service: reverse service: reverse
extra_hosts:
- "host.docker.internal=host-gateway"
volumes: volumes:
- "./nginx.conf:/etc/nginx/nginx.conf:ro"
- "./locations:/etc/nginx/locations:ro" - "./locations:/etc/nginx/locations:ro"
- "./configuration:/etc/nginx/configuration:ro" - "./configuration:/etc/nginx/configuration:ro"
- "./sites-enabled:/etc/nginx/sites-enabled:ro" - "./sites-enabled:/etc/nginx/sites-enabled:ro"
@ -23,3 +21,12 @@ services:
- 443:443 - 443:443
networks: networks:
- services - 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

View File

@ -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;
}
}