Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 16 additions & 24 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,46 @@
version: '3.8'

services:
web:
image: nginx:alpine
ports:
- "8049:80" # Проброс порта 8049 на 80
- "8049:80" # Снаружи 8049 → внутри 80
networks:
- frontend-net
volumes:
- type: bind
source: ./nginx/app.conf
target: /etc/nginx/conf.d/default.conf
read_only: true
- type: bind
source: ./nginx/index.html
target: /usr/share/nginx/html/index.html
read_only: true
- type: bind
source: ./nginx/styles.css
target: /usr/share/nginx/html/styles.css
read_only: true
- type: bind
source: ./nginx/script.js
target: /usr/share/nginx/html/script.js
read_only: true
# 1) Конфиг nginx
- ./nginx/app.conf:/etc/nginx/conf.d/default.conf:ro
# 2) Статические файлы
- ./nginx/index.html:/usr/share/nginx/html/index.html:ro
- ./nginx/styles.css:/usr/share/nginx/html/styles.css:ro
- ./nginx/script.js:/usr/share/nginx/html/script.js:ro
depends_on:
- simple_python_app

simple_python_app:
build: ./simple_python_app # собираем образ из вашего Dockerfile
image: simple_python_app:latest
build: ./simple_python_app # Убедитесь, что у вас есть Dockerfile в этой директории
ports:
- "5000:8000" # снаружи 5000 → внутри 8000 (uvicorn)
environment:
API_DB_HOST: db
API_DB_PASS: apipass
API_DB_PORT: "5432"
API_DB_NAME: api
API_DB_USER: apiuser
API_DB_PASS: apipass
networks:
- frontend-net
- backend-net
ports:
- "5000:8000" # Проброс порта 5000 на 8000 (порт, на котором работает Uvicorn)
depends_on:
db:
condition: service_healthy
condition: service_healthy # ждем, пока БД будет здоровой

db:
image: postgres:16.2-alpine
environment:
POSTGRES_PASSWORD: apipass
POSTGRES_DB: api
POSTGRES_USER: apiuser
POSTGRES_PASSWORD: apipass
volumes:
- dbdata:/var/lib/postgresql/data
networks:
Expand All @@ -58,7 +51,6 @@ services:
timeout: 5s
retries: 10
start_period: 30s
start_interval: 1s

networks:
frontend-net:
Expand Down
2 changes: 1 addition & 1 deletion nginx/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Мое приложение</title>
<title>Мое приложениe!</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
Expand Down
Empty file added simple_python_app/__init__.py
Empty file.
9 changes: 9 additions & 0 deletions simple_python_app/test_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from fastapi.testclient import TestClient
from app import app

client = TestClient(app)

def test_root():
response = client.get("/")
assert response.status_code == 200
assert "postgres_version" in response.json()
Loading