lots of things

This commit is contained in:
2019-11-14 16:16:31 +01:00
parent 73b587d23d
commit 19b5488d22
11 changed files with 88 additions and 2 deletions

View File

@@ -14,6 +14,7 @@ before_install:
- sudo mv docker-compose /usr/local/bin
before_script:
- export REACT_APP_USERS_SERVICE_URL=http://127.0.0.1
- docker-compose up -d --build
script:

View File

@@ -1,6 +1,18 @@
version: '3.7'
services:
client:
container_name: client
build:
context: ./services/client
dockerfile: Dockerfile-prod
args:
- NODE_ENV=production
- REACT_APP_USERS_SERVICE_URL=${REACT_APP_USERS_SERVICE_URL}
ports:
- "3007:80"
depends_on:
- users
users:
build:
context: ./services/users
@@ -32,3 +44,4 @@ services:
- "80:80"
depends_on:
- users
- client

View File

@@ -1,6 +1,20 @@
version: '3.7'
services:
client:
build:
context: ./services/client
dockerfile: services/client/Dockerfile-prod
volumes:
- './services/client:/usr/src/app'
- '/usr/src/app/node_mdules'
ports:
- 3007:3000
environment:
- NODE_ENV=development
- REACT_APP_USERS_SERVICE_URL=${REACT_APP_USERS_SERVICE_URL}
depends_on:
- users
users:
build:
context: ./services/users
@@ -34,4 +48,5 @@ services:
- "80:80"
depends_on:
- users
- client

View File

@@ -3,6 +3,15 @@ server {
listen 80;
location / {
proxy_pass http://client:3000;
proxy_redirect default;
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-Host $server_name;
}
location /users {
proxy_pass http://users:5000;
proxy_redirect default;
proxy_set_header Host $host;

View File

@@ -3,6 +3,15 @@ server {
listen 80;
location / {
proxy_pass http://client:80;
proxy_redirect default;
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-Host $server_name;
}
location /users {
proxy_pass http://users:5000;
proxy_redirect default;
proxy_set_header Host $host;

View File

@@ -13,6 +13,8 @@ psycopg2-binary = "*"
flask-testing = "*"
coverage = "*"
flake8 = "*"
flask-debugtoolbar = "*"
flask-cors = "*"
[requires]
python_version = "3.8"

View File

@@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
"sha256": "77ca234305c2fbf685654a912edd73bd100774766adeb44a9cafa01deb77a205"
"sha256": "e69adbf7b4a00904ef2c27e32b8d3c4b3fea6781f3d1db45fe78c1c0a58320a1"
},
"pipfile-spec": 6,
"requires": {
@@ -23,6 +23,12 @@
],
"version": "==8.0.0"
},
"blinker": {
"hashes": [
"sha256:471aee25f3992bd325afa3772f1063dbdbbca947a041b8b89466dc00d606f8b6"
],
"version": "==1.4"
},
"click": {
"hashes": [
"sha256:2335065e6395b9e67ca716de5f7526736bfa6ceead690adf616d925bdc622b13",
@@ -91,6 +97,22 @@
"index": "pypi",
"version": "==1.1.1"
},
"flask-cors": {
"hashes": [
"sha256:72170423eb4612f0847318afff8c247b38bd516b7737adfc10d1c2cdbb382d16",
"sha256:f4d97201660e6bbcff2d89d082b5b6d31abee04b1b3003ee073a6fd25ad1d69a"
],
"index": "pypi",
"version": "==3.0.8"
},
"flask-debugtoolbar": {
"hashes": [
"sha256:3d9657bc0c3633ace429e3ff451742bb59d1b7a7b95c9eb23a65ac9be2812959",
"sha256:ec810083123aae0632eb32ba11e1cb4cdace81e7ce6c5009dd06c5204afbce52"
],
"index": "pypi",
"version": "==0.10.1"
},
"flask-restful": {
"hashes": [
"sha256:ecd620c5cc29f663627f99e04f17d1f16d095c83dc1d618426e2ad68b03092f8",

View File

@@ -1,17 +1,23 @@
import os
from flask import Flask
from flask_cors import CORS
from flask_debugtoolbar import DebugToolbarExtension
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
toolbar = DebugToolbarExtension()
cors = CORS()
def create_app(script_info=None):
def create_app():
app = Flask(__name__)
app_settings = os.getenv('APP_SETTINGS')
app.config.from_object(app_settings)
db.init_app(app)
toolbar.init_app(app)
cors.init_app(app)
from project.api.users import users_blueprint
app.register_blueprint(users_blueprint)

View File

@@ -5,10 +5,13 @@ class BaseConfig:
TESTING = False
SQLALCHEMY_TRACK_MODIFICATIONS = False
SECRET_KEY = 'my_precious'
DEBUG_TB_ENABLED = False
DEBUG_TB_INTERCEPT_REDIRECTS = False
class DevelopmentConfig(BaseConfig):
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL')
DEBUG_TB_ENABLED = True
class ProductionConfig(BaseConfig):

View File

@@ -21,6 +21,7 @@ class TestDevelopmentConfig(TestCase):
app.config['SQLALCHEMY_DATABASE_URI'] ==
os.environ.get('DATABASE_URL')
)
self.assertTrue(app.config['DEBUG_TB_ENABLED'])
class TestTestingConfig(TestCase):
@@ -36,6 +37,7 @@ class TestTestingConfig(TestCase):
app.config['SQLALCHEMY_DATABASE_URI'] ==
os.environ.get('DATABASE_TEST_URL')
)
self.assertFalse(app.config['DEBUG_TB_ENABLED'])
class TestProductionConfig(TestCase):
@@ -46,6 +48,7 @@ class TestProductionConfig(TestCase):
def test_app_is_testing(self):
self.assertTrue(app.config['SECRET_KEY'] == 'my_precious')
self.assertFalse(app.config['TESTING'])
self.assertFalse(app.config['DEBUG_TB_ENABLED'])
if __name__ == "__main__":

View File

@@ -1,9 +1,12 @@
-i https://pypi.org/simple
aniso8601==8.0.0
blinker==1.4
click==7.0
coverage==4.5.4
entrypoints==0.3
flake8==3.7.9
flask-cors==3.0.8
flask-debugtoolbar==0.10.1
flask-restful==0.3.7
flask-sqlalchemy==2.4.1
flask-testing==0.7.1