Docker Test with Nginx
This commit is contained in:
parent
886f22ac85
commit
1a3bee1846
14 changed files with 70 additions and 34 deletions
|
|
@ -4,27 +4,46 @@ services:
|
||||||
nginx:
|
nginx:
|
||||||
image: nginx:latest
|
image: nginx:latest
|
||||||
volumes:
|
volumes:
|
||||||
- ./conf/nginx.conf:/etc/nginx/nginx.conf
|
- ./frontend/conf/nginx.conf:/etc/nginx/nginx.conf
|
||||||
- ./logs/nginx:/etc/nginx/logs
|
- ./frontend/logs/nginx:/etc/nginx/logs
|
||||||
- ./cert:/etc/nginx/cert
|
- ./frontend/cert:/etc/nginx/cert
|
||||||
networks:
|
networks:
|
||||||
- net
|
- net
|
||||||
ports:
|
ports:
|
||||||
- 80:80
|
- 80:80
|
||||||
|
depends_on:
|
||||||
|
- server
|
||||||
|
|
||||||
|
server:
|
||||||
|
container_name: server
|
||||||
|
build: frontend/backend
|
||||||
|
command: python -m flask run
|
||||||
|
ports:
|
||||||
|
- "4200:4200"
|
||||||
|
volumes:
|
||||||
|
- ./frontend/backend:/data/frontend/backend
|
||||||
|
- ./frontend/app.py:/data/frontend/app.py
|
||||||
|
- ./frontend/config.py:/data/frontend/config.py
|
||||||
|
environment:
|
||||||
|
- FLASK_APP=app.py
|
||||||
|
- FLASK_ENV=production
|
||||||
|
- FLASK_DEBUG=1
|
||||||
|
- FLASK_RUN_PORT=4200
|
||||||
|
- PYTHONUNBUFFERED=1
|
||||||
|
networks:
|
||||||
|
- net
|
||||||
|
depends_on:
|
||||||
|
- frontend
|
||||||
|
|
||||||
frontend:
|
frontend:
|
||||||
container_name: frontend
|
container_name: frontend
|
||||||
build: .
|
build: frontend
|
||||||
command: npm start
|
command: npm run build
|
||||||
# ports:
|
|
||||||
# - "4200:4200"
|
|
||||||
volumes:
|
volumes:
|
||||||
- ./src:/data/frontend
|
- ./frontend/src:/data/frontend
|
||||||
- ./node_modules:/data/frontend/node_modules
|
- ./frontend/node_modules:/data/frontend/node_modules
|
||||||
environment:
|
environment:
|
||||||
- NODE_ENV=production
|
- NODE_ENV=production
|
||||||
networks:
|
|
||||||
- net
|
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
net:
|
net:
|
||||||
|
|
|
||||||
2
frontend/.gitignore
vendored
2
frontend/.gitignore
vendored
|
|
@ -47,3 +47,5 @@ testem.log
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
|
|
||||||
package-lock.json
|
package-lock.json
|
||||||
|
|
||||||
|
backend/dist
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
"build": {
|
"build": {
|
||||||
"builder": "@angular-devkit/build-angular:browser",
|
"builder": "@angular-devkit/build-angular:browser",
|
||||||
"options": {
|
"options": {
|
||||||
"outputPath": "dist/",
|
"outputPath": "backend/dist/",
|
||||||
"index": "src/index.html",
|
"index": "src/index.html",
|
||||||
"main": "src/main.ts",
|
"main": "src/main.ts",
|
||||||
"polyfills": "src/polyfills.ts",
|
"polyfills": "src/polyfills.ts",
|
||||||
|
|
@ -42,13 +42,13 @@
|
||||||
"budgets": [
|
"budgets": [
|
||||||
{
|
{
|
||||||
"type": "initial",
|
"type": "initial",
|
||||||
"maximumWarning": "500kb",
|
"maximumWarning": "1mb",
|
||||||
"maximumError": "1mb"
|
"maximumError": "2mb"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "anyComponentStyle",
|
"type": "anyComponentStyle",
|
||||||
"maximumWarning": "2kb",
|
"maximumWarning": "4kb",
|
||||||
"maximumError": "4kb"
|
"maximumError": "8kb"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"fileReplacements": [
|
"fileReplacements": [
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
from . import create_app
|
from backend import create_app
|
||||||
import os
|
import os
|
||||||
|
|
||||||
app = create_app(os.environ.get('FLASK_ENV', None))
|
app = create_app(os.environ.get('FLASK_ENV'))
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app.run(host='0.0.0.0', DEBUG=True)
|
app.run(host='0.0.0.0', DEBUG=True)
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
FROM python:latest
|
FROM python:latest
|
||||||
WORKDIR /data/backend
|
WORKDIR /data/frontend/backend
|
||||||
COPY requirements.txt requirements.txt
|
COPY requirements.txt requirements.txt
|
||||||
RUN pip install --upgrade pip
|
RUN pip install --upgrade pip
|
||||||
RUN pip install -r requirements.txt
|
RUN pip install -r requirements.txt
|
||||||
COPY . .
|
COPY . .
|
||||||
|
WORKDIR /data/frontend
|
||||||
|
|
@ -5,3 +5,4 @@ PyJWT==2.3.0
|
||||||
pytest==6.2.5
|
pytest==6.2.5
|
||||||
psycopg2==2.9.2
|
psycopg2==2.9.2
|
||||||
Flask-Cors==3.0.10
|
Flask-Cors==3.0.10
|
||||||
|
requests==2.22.0
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
from flask import request, Blueprint, send_from_directory, current_app as app
|
from flask import request, Blueprint, send_from_directory, current_app as app
|
||||||
import requests
|
import requests
|
||||||
import os
|
|
||||||
from werkzeug.exceptions import HTTPException
|
from werkzeug.exceptions import HTTPException
|
||||||
from .responses import send_message, send_error
|
from .responses import send_message, send_error
|
||||||
from .sessionJWT import create_auth_token, check_auth_token
|
from .sessionJWT import create_auth_token, check_auth_token
|
||||||
|
|
@ -36,17 +35,17 @@ def handle_exception(e):
|
||||||
|
|
||||||
@bp.route('/', methods=['GET'])
|
@bp.route('/', methods=['GET'])
|
||||||
def root():
|
def root():
|
||||||
return send_from_directory("frontend/dist", "index.html")
|
return send_from_directory("dist", "index.html")
|
||||||
|
|
||||||
|
|
||||||
@bp.route('/frontend/dist/<path:path>', methods=['GET'])
|
@bp.route('/frontend/backend/dist/<path:path>', methods=['GET'])
|
||||||
def static(path):
|
def static(path):
|
||||||
return send_from_directory("frontend/dist", path)
|
return send_from_directory("dist", path)
|
||||||
|
|
||||||
|
|
||||||
@bp.route('/assets/<path:path>', methods=['GET'])
|
@bp.route('/assets/<path:path>', methods=['GET'])
|
||||||
def assets(path):
|
def assets(path):
|
||||||
return send_from_directory("frontend/dist/assets", path)
|
return send_from_directory("dist/assets", path)
|
||||||
|
|
||||||
|
|
||||||
# Login
|
# Login
|
||||||
|
|
@ -16,21 +16,21 @@ http {
|
||||||
proxy_send_timeout 90;
|
proxy_send_timeout 90;
|
||||||
proxy_read_timeout 90;
|
proxy_read_timeout 90;
|
||||||
proxy_buffers 32 4k;
|
proxy_buffers 32 4k;
|
||||||
|
|
||||||
upstream frontend {
|
upstream server {
|
||||||
server frontend:4200;
|
server server:4200;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen 80;
|
listen 80;
|
||||||
server_name wordpress;
|
server_name flask-aled;
|
||||||
access_log logs/access.log;
|
access_log logs/access.log;
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
proxy_pass http://frontend;
|
proxy_pass http://server;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,3 +19,17 @@
|
||||||
192.168.16.1 - - [28/Jan/2022:11:04:23 +0000] "GET /styles.f64087845b474dd2.css HTTP/1.1" 304 0 "http://localhost/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36 OPR/82.0.4227.50"
|
192.168.16.1 - - [28/Jan/2022:11:04:23 +0000] "GET /styles.f64087845b474dd2.css HTTP/1.1" 304 0 "http://localhost/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36 OPR/82.0.4227.50"
|
||||||
192.168.16.1 - - [28/Jan/2022:11:04:23 +0000] "GET /assets/logo.png HTTP/1.1" 304 0 "http://localhost/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36 OPR/82.0.4227.50"
|
192.168.16.1 - - [28/Jan/2022:11:04:23 +0000] "GET /assets/logo.png HTTP/1.1" 304 0 "http://localhost/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36 OPR/82.0.4227.50"
|
||||||
192.168.16.1 - - [28/Jan/2022:11:04:23 +0000] "GET /favicon.ico HTTP/1.1" 200 948 "http://localhost/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36 OPR/82.0.4227.50"
|
192.168.16.1 - - [28/Jan/2022:11:04:23 +0000] "GET /favicon.ico HTTP/1.1" 200 948 "http://localhost/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36 OPR/82.0.4227.50"
|
||||||
|
172.21.0.1 - - [01/Feb/2022:14:58:24 +0000] "GET / HTTP/1.1" 502 559 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36"
|
||||||
|
172.21.0.1 - - [01/Feb/2022:14:58:25 +0000] "GET /favicon.ico HTTP/1.1" 502 559 "http://localhost/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36"
|
||||||
|
172.21.0.1 - - [01/Feb/2022:14:58:30 +0000] "GET / HTTP/1.1" 502 559 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36"
|
||||||
|
172.21.0.1 - - [01/Feb/2022:14:58:30 +0000] "GET /favicon.ico HTTP/1.1" 502 559 "http://127.0.0.1/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36"
|
||||||
|
172.21.0.1 - - [01/Feb/2022:15:01:07 +0000] "GET / HTTP/1.1" 502 559 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36"
|
||||||
|
172.21.0.1 - - [01/Feb/2022:15:01:07 +0000] "GET /favicon.ico HTTP/1.1" 502 559 "http://127.0.0.1/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36"
|
||||||
|
172.22.0.1 - - [01/Feb/2022:15:14:43 +0000] "GET / HTTP/1.1" 502 559 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36"
|
||||||
|
172.22.0.1 - - [01/Feb/2022:15:14:43 +0000] "GET /favicon.ico HTTP/1.1" 502 559 "http://127.0.0.1/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36"
|
||||||
|
172.22.0.1 - - [01/Feb/2022:15:19:49 +0000] "GET / HTTP/1.1" 502 559 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36"
|
||||||
|
172.22.0.1 - - [01/Feb/2022:15:19:52 +0000] "GET /favicon.ico HTTP/1.1" 502 559 "http://localhost/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36"
|
||||||
|
172.22.0.1 - - [01/Feb/2022:15:22:17 +0000] "GET / HTTP/1.1" 502 559 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36"
|
||||||
|
172.22.0.1 - - [01/Feb/2022:15:22:18 +0000] "GET /favicon.ico HTTP/1.1" 502 559 "http://localhost/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36"
|
||||||
|
172.22.0.1 - - [01/Feb/2022:15:22:19 +0000] "GET / HTTP/1.1" 502 559 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36"
|
||||||
|
172.22.0.1 - - [01/Feb/2022:15:22:19 +0000] "GET /favicon.ico HTTP/1.1" 502 559 "http://localhost/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36"
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"ng": "ng",
|
"ng": "ng",
|
||||||
"start": "ng build && python flask run",
|
"start": "ng build --build-optimizer --baseHref=frontend/backend/dist/ && cd .. && python -m flask run",
|
||||||
"build": "ng build --build-optimizer --baseHref=frontend/dist/",
|
"build": "ng build --build-optimizer --baseHref=frontend/backend/dist/",
|
||||||
"watch": "ng build --watch --configuration development",
|
"watch": "ng build --watch --configuration development",
|
||||||
"test": "ng test"
|
"test": "ng test"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue