Skip to content

Commit 09ff08a

Browse files
committed
Added nginx.
1 parent 802b5e5 commit 09ff08a

File tree

10 files changed

+237
-214
lines changed

10 files changed

+237
-214
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ docker compose up -v --built
77
```
88

99
### Просмотр
10-
Перейдите по адресу `0.0.0.0:3001/` для просмотра карты с грузами и машинами или `0.0.0.0:8001/docs/` для работы с API сервиса.
10+
Перейдите по адресу `0.0.0.0:8083/` для просмотра карты с грузами и машинами или `0.0.0.0:8001/docs/` для работы с API сервиса.

backend/.dockerignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Git
2+
.git
3+
.gitignore
4+
5+
# Byte-compiled / optimized / DLL files
6+
**/__pycache__/
7+
**/*.py[cod]
8+
9+
# Python
10+
.env
11+
.venv/
12+
venv/
13+
env/

backend/Dockerfile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ WORKDIR /backend_app
55
RUN apt-get update && apt-get install -y libpq-dev netcat
66
RUN pip3 install poetry
77

8-
COPY *.py locations.csv pytest.ini poetry.lock pyproject.toml ./
9-
COPY core/ ./core/
10-
COPY routers/ ./routers/
11-
COPY tasks/ ./tasks/
12-
COPY tests/ ./tests/
8+
COPY . .
9+
# COPY *.py locations.csv pytest.ini poetry.lock pyproject.toml ./
10+
# COPY core/ ./core/
11+
# COPY routers/ ./routers/
12+
# COPY tasks/ ./tasks/
13+
# COPY tests/ ./tests/
1314

1415
RUN poetry config virtualenvs.create false \
1516
&& poetry install --no-interaction --no-ansi

backend/poetry.lock

Lines changed: 167 additions & 174 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "backend"
33
version = "1.1.0"
44
description = "Сервис поиска ближайших машин для перевозки грузов."
5-
authors = ["dsuhoi <dsuh0i.h8@gmail.com>"]
5+
authors = ["Dan Sukhorukov <dsuh0i.h8@gmail.com>"]
66
license = "MIT"
77
readme = "README.md"
88

@@ -17,7 +17,7 @@ celery = "^5.3.1"
1717
uvicorn = "^0.22.0"
1818
pydantic = "^2.0.2"
1919
pydantic-settings = "^2.0.1"
20-
sqlalchemy = "^2.0.18"
20+
sqlalchemy = "^1.4.44"
2121
pandas = "^2.0.3"
2222
strawberry-graphql = {extras = ["fastapi"], version = "^0.194.4"}
2323
geoalchemy2 = "^0.14.0"

docker-compose.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ services:
5252
- ./.env
5353
depends_on:
5454
- backend
55-
55+
nginx:
56+
image: nginx:alpine
57+
ports:
58+
- 8083:8080
59+
volumes:
60+
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
61+
depends_on:
62+
- backend
63+
- frontend
5664
volumes:
5765
postgres_data:

frontend/Dockerfile

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
1-
# pull official base image
21
FROM node:13.12.0-alpine
32

4-
# set working directory
53
WORKDIR /frontend_app
64

7-
# add `/app/node_modules/.bin` to $PATH
85
ENV PATH /app/node_modules/.bin:$PATH
96

10-
# install app dependencies
117
COPY package.json package-lock.json ./
128
COPY src/ ./src/
139
COPY public/ ./public/
1410

1511
RUN npm install
1612

17-
# start app
1813
CMD ["npm", "start"]

frontend/nginx.conf

Lines changed: 0 additions & 22 deletions
This file was deleted.

frontend/src/components/MapComponent.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const MapComponent = () => {
6767
map.on("pointermove", (event) => {
6868
const feature = map.forEachFeatureAtPixel(
6969
event.pixel,
70-
(feature) => feature
70+
(feature) => feature,
7171
);
7272
if (feature) {
7373
const coordinate = event.coordinate;
@@ -83,7 +83,7 @@ const MapComponent = () => {
8383
});
8484

8585
const client = new ApolloClient({
86-
uri: "http://0.0.0.0:8001/graphql",
86+
uri: "/api/graphql",
8787
cache: new InMemoryCache(),
8888
});
8989

@@ -113,7 +113,7 @@ const MapComponent = () => {
113113
data.cars.forEach((item) => {
114114
const marker = new Feature({
115115
geometry: new Point(
116-
fromLonLat([item.loc.lng, item.loc.lat])
116+
fromLonLat([item.loc.lng, item.loc.lat]),
117117
),
118118
name: item.carNumber,
119119
description: "car",
@@ -126,7 +126,10 @@ const MapComponent = () => {
126126
data.cargo.forEach((item) => {
127127
const marker = new Feature({
128128
geometry: new Point(
129-
fromLonLat([item.pickUpLoc.lng, item.pickUpLoc.lat])
129+
fromLonLat([
130+
item.pickUpLoc.lng,
131+
item.pickUpLoc.lat,
132+
]),
130133
),
131134
name: item.id,
132135
description: item.description,

nginx/nginx.conf

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
worker_processes 1;
2+
3+
events { worker_connections 1024; }
4+
5+
http {
6+
sendfile on;
7+
8+
gzip on;
9+
gzip_http_version 1.1;
10+
gzip_disable "MSIE [1-6]\.";
11+
12+
upstream frontend {
13+
server frontend:3001;
14+
}
15+
16+
upstream backend {
17+
server backend:8001;
18+
}
19+
20+
server {
21+
listen 8080;
22+
23+
location / {
24+
proxy_pass http://frontend;
25+
}
26+
27+
location /api {
28+
rewrite /api/(.*) /$1 break;
29+
proxy_pass http://backend;
30+
}
31+
}
32+
}

0 commit comments

Comments
 (0)