moving to docker

This commit is contained in:
2023-05-14 20:28:29 +03:00
parent 6f7219ff7b
commit d5802fa48f
62 changed files with 87 additions and 0 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
**/node_modules
*.pyc
**/__pycache__
**/postgres_data

8
api/Dockerfile Normal file
View File

@ -0,0 +1,8 @@
FROM python:3.11.3
WORKDIR /app
ENV PYTHONBUFFERED=1
COPY requirements.txt /app
RUN pip install -r requirements.txt --no-cache-dir
COPY /app /app
ENTRYPOINT ["python"]
CMD ["manage.py", "runserver", "0.0.0.0:8000"]

3
api/requirements.txt Normal file
View File

@ -0,0 +1,3 @@
django
django-rest-framework
pygments

View File

@ -0,0 +1,34 @@
services:
api:
build:
context: api
ports:
- "5000"
environment:
- POSTGRES_PASSWORD=password
- POSTGRES_USER=postgres
- POSTGRES_DB=flask
- PYTHONBUFFERED=0
react:
build:
context: react
ports:
- "3000"
nginx:
image: nginx:1.23.4
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
- ./static:/static
depends_on:
- api
ports:
- "3000:3000"
postgres:
image: postgres:15.1
restart: always
volumes:
- ./postgres_data:/var/lib/postgresql/data/
environment:
POSTGRES_USER: user
POSTGRES_PASSWORD: password
POSTGRES_DB: db

24
nginx.conf Normal file
View File

@ -0,0 +1,24 @@
server {
listen 3000;
server_name 192.168.1.121;
location / {
proxy_pass http://react:3000/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache off;
}
location /api/ {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Headers' '*';
add_header 'Access-Control-Allow-Methods' '*';
proxy_pass http://api:8000/api/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache off;
}
}

17
react/Dockerfile Normal file
View File

@ -0,0 +1,17 @@
FROM node:20.1
WORKDIR /app
COPY /app /app
# COPY package.json /app/package.json
# COPY package-lock.json /app/package-lock.json
# Same as npm install
# RUN npm ci
# COPY . /app
#
ENV CI=true
ENV PORT=3000
ENV HOST=0.0.0.0
CMD [ "npm", "start" ]

View File

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

View File

Before

Width:  |  Height:  |  Size: 9.4 KiB

After

Width:  |  Height:  |  Size: 9.4 KiB

View File

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
static/15761328864140.gif Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 726 KiB