mirror of
https://github.com/ijaric/voice_assistant.git
synced 2025-07-12 05:03:24 +00:00
Merge pull request #9 from ijaric/features/#6_nginx
Шаблоны nginx для сервисов #6
This commit is contained in:
commit
5ddcfe32ad
|
@ -4,6 +4,7 @@ POSTGRES_USER=user
|
|||
POSTGRES_PASSWORD=Qwe123
|
||||
POSTGRES_NAME=api_db
|
||||
|
||||
NGINX_PORT=80
|
||||
API_HOST=0.0.0.0
|
||||
API_PORT=8000
|
||||
|
||||
|
|
|
@ -1,14 +1,23 @@
|
|||
FROM python:3.11
|
||||
|
||||
RUN apt-get update \
|
||||
&& DEBIAN_FRONTEND=noninteractive \
|
||||
&& apt-get install -y net-tools netcat-traditional curl \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN mkdir --parents /opt/app
|
||||
COPY pyproject.toml /opt/app/pyproject.toml
|
||||
COPY poetry.lock /opt/app/poetry.lock
|
||||
COPY poetry.toml /opt/app/poetry.toml
|
||||
|
||||
WORKDIR /opt/app
|
||||
|
||||
ENV PYTHONPATH '/opt/app'
|
||||
|
||||
COPY pyproject.toml ./
|
||||
RUN pip install poetry \
|
||||
&& poetry install --no-dev
|
||||
|
||||
COPY bin bin
|
||||
COPY lib lib
|
||||
COPY entrypoint.sh .
|
||||
COPY bin /opt/app/bin
|
||||
COPY lib /opt/app/lib
|
||||
COPY entrypoint.sh /opt/app/entrypoint.sh
|
||||
|
||||
RUN chmod +x /opt/app/entrypoint.sh
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
version: "3"
|
||||
|
||||
services:
|
||||
db:
|
||||
postgres:
|
||||
image: postgres:15.2
|
||||
restart: always
|
||||
environment:
|
||||
POSTGRES_USER: ${POSTGRES_USER}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
||||
|
@ -13,7 +14,6 @@ services:
|
|||
- "${POSTGRES_PORT}:${POSTGRES_PORT}"
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data/
|
||||
restart: always
|
||||
networks:
|
||||
- backend_network
|
||||
|
||||
|
@ -24,24 +24,27 @@ services:
|
|||
image: fastapi_app
|
||||
restart: always
|
||||
entrypoint: ["/opt/app/entrypoint.sh"]
|
||||
env_file:
|
||||
- .env
|
||||
ports:
|
||||
- "${API_PORT}:${API_PORT}"
|
||||
depends_on:
|
||||
- db
|
||||
env_file:
|
||||
- .env
|
||||
- postgres
|
||||
networks:
|
||||
- backend_network
|
||||
- api_network
|
||||
|
||||
nginx:
|
||||
image: nginx:1.23.4
|
||||
image: nginx:1.25.1
|
||||
env_file:
|
||||
- .env
|
||||
ports:
|
||||
- "${NGINX_PORT}:${NGINX_PORT}"
|
||||
volumes:
|
||||
- ./nginx:/etc/nginx/:ro
|
||||
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
|
||||
- ./nginx/templates:/etc/nginx/templates
|
||||
depends_on:
|
||||
- api
|
||||
ports:
|
||||
- "80:80"
|
||||
networks:
|
||||
- api_network
|
||||
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
version: "3"
|
||||
|
||||
services:
|
||||
db:
|
||||
postgres:
|
||||
image: postgres:15.2
|
||||
restart: always
|
||||
environment:
|
||||
POSTGRES_USER: ${POSTGRES_USER}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
||||
POSTGRES_DB: ${POSTGRES_NAME}
|
||||
env_file:
|
||||
- .env
|
||||
ports:
|
||||
- "127.0.0.1:${API_PORT}:${API_PORT}"
|
||||
expose:
|
||||
- "${POSTGRES_PORT}"
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data/
|
||||
restart: always
|
||||
networks:
|
||||
- backend_network
|
||||
|
||||
|
@ -24,22 +24,27 @@ services:
|
|||
image: fastapi_app
|
||||
restart: always
|
||||
entrypoint: ["/opt/app/entrypoint.sh"]
|
||||
depends_on:
|
||||
- db
|
||||
env_file:
|
||||
- .env
|
||||
expose:
|
||||
- "${API_PORT}"
|
||||
depends_on:
|
||||
- postgres
|
||||
networks:
|
||||
- backend_network
|
||||
- api_network
|
||||
|
||||
nginx:
|
||||
image: nginx:1.23.4
|
||||
image: nginx:1.25.1
|
||||
env_file:
|
||||
- .env
|
||||
ports:
|
||||
- "${NGINX_PORT}:${NGINX_PORT}"
|
||||
volumes:
|
||||
- ./nginx:/etc/nginx/:ro
|
||||
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
|
||||
- ./nginx/templates:/etc/nginx/templates
|
||||
depends_on:
|
||||
- api
|
||||
ports:
|
||||
- "80:80"
|
||||
networks:
|
||||
- api_network
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
while ! (echo > /dev/tcp/db/5432) >/dev/null 2>&1; do
|
||||
sleep 1
|
||||
done
|
||||
while ! nc -z postgres 5432; do sleep 1; done;
|
||||
|
||||
exec .venv/bin/python -m bin
|
||||
exec .venv/bin/python -m bin
|
|
@ -6,7 +6,7 @@ from .project import *
|
|||
__all__ = [
|
||||
"ApiSettings",
|
||||
"LoggingSettings",
|
||||
"get_logging_config",
|
||||
"PostgresSettings",
|
||||
"ProjectSettings",
|
||||
"get_logging_config",
|
||||
]
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
server {
|
||||
listen 80 default_server;
|
||||
listen [::]:80 default_server;
|
||||
server_name _;
|
||||
|
||||
location /api {
|
||||
proxy_pass http://api:8000/api;
|
||||
}
|
||||
|
||||
}
|
|
@ -5,18 +5,19 @@ events {
|
|||
}
|
||||
|
||||
http {
|
||||
server_tokens off;
|
||||
include mime.types;
|
||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||
'"$http_user_agent" "$http_x_forwarded_for" "$request_id"';
|
||||
|
||||
server_tokens off;
|
||||
access_log /dev/stdout main;
|
||||
|
||||
sendfile on;
|
||||
tcp_nodelay on;
|
||||
tcp_nopush on;
|
||||
client_max_body_size 200m;
|
||||
|
||||
|
||||
gzip on;
|
||||
gzip_comp_level 3;
|
||||
gzip_min_length 1000;
|
||||
|
@ -27,11 +28,12 @@ http {
|
|||
application/x-javascript
|
||||
text/xml
|
||||
text/javascript;
|
||||
|
||||
|
||||
add_header X-Request-Id $request_id;
|
||||
proxy_redirect off;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
|
||||
include conf.d/site.conf;
|
||||
include conf.d/api.conf;
|
||||
}
|
||||
|
|
11
src/fastapi_app/nginx/templates/api.conf.template
Normal file
11
src/fastapi_app/nginx/templates/api.conf.template
Normal file
|
@ -0,0 +1,11 @@
|
|||
server {
|
||||
listen ${NGINX_PORT} default_server;
|
||||
listen [::]:${NGINX_PORT} default_server;
|
||||
server_name _;
|
||||
|
||||
location /api {
|
||||
proxy_pass http://api:${API_PORT}/api;
|
||||
proxy_set_header X-Request-Id $request_id;
|
||||
}
|
||||
|
||||
}
|
6
src/fastapi_app/poetry.lock
generated
6
src/fastapi_app/poetry.lock
generated
|
@ -937,13 +937,13 @@ pycryptodome = ["pyasn1", "pycryptodome (>=3.3.1,<4.0.0)"]
|
|||
|
||||
[[package]]
|
||||
name = "pyupgrade"
|
||||
version = "3.11.1"
|
||||
version = "3.12.0"
|
||||
description = "A tool to automatically upgrade syntax for newer versions."
|
||||
optional = false
|
||||
python-versions = ">=3.8.1"
|
||||
files = [
|
||||
{file = "pyupgrade-3.11.1-py2.py3-none-any.whl", hash = "sha256:6e9dd362394b3068123e06ca268de5845d41e2bb29f387b38323cc1009fb3100"},
|
||||
{file = "pyupgrade-3.11.1.tar.gz", hash = "sha256:3e6c7689d2f3ae418c6a60ee981477fe9130eccaed3e33dac6c21274cf7d45f4"},
|
||||
{file = "pyupgrade-3.12.0-py2.py3-none-any.whl", hash = "sha256:c6f9c129560b9538e75b93fb0aee20508faae454714e8373d462e408985bd96a"},
|
||||
{file = "pyupgrade-3.12.0.tar.gz", hash = "sha256:defc292ffaf402942b8fccaa97491964063e343fc1993230e44890b971dc1234"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
|
|
Loading…
Reference in New Issue
Block a user