diff --git a/samples/nginx-flask-mysql/backend/Dockerfile b/samples/nginx-flask-mysql/backend/Dockerfile new file mode 100755 index 0000000..190d518 --- /dev/null +++ b/samples/nginx-flask-mysql/backend/Dockerfile @@ -0,0 +1,10 @@ +FROM python:3.6-alpine3.7 +EXPOSE 5000 +ENV PYTHONUNBUFFERED 1 +RUN mkdir /code +WORKDIR /code +ADD requirements.txt /code/ +RUN pip install -r requirements.txt +ADD . /code/ +ENV FLASK_APP hello.py +CMD flask run --host=0.0.0.0 diff --git a/samples/nginx-flask-mysql/backend/hello.py b/samples/nginx-flask-mysql/backend/hello.py new file mode 100755 index 0000000..a60da8d --- /dev/null +++ b/samples/nginx-flask-mysql/backend/hello.py @@ -0,0 +1,6 @@ +from flask import Flask +app = Flask(__name__) + +@app.route('/') +def hello_world(): + return 'Hello world' diff --git a/samples/nginx-flask-mysql/backend/requirements.txt b/samples/nginx-flask-mysql/backend/requirements.txt new file mode 100755 index 0000000..34ffbb7 --- /dev/null +++ b/samples/nginx-flask-mysql/backend/requirements.txt @@ -0,0 +1,6 @@ +click==6.7 +Flask==1.0.2 +itsdangerous==0.24 +Jinja2==2.10 +MarkupSafe==1.0 +Werkzeug==0.14.1 diff --git a/samples/nginx-flask-mysql/db/password.txt b/samples/nginx-flask-mysql/db/password.txt new file mode 100644 index 0000000..1f444cb --- /dev/null +++ b/samples/nginx-flask-mysql/db/password.txt @@ -0,0 +1 @@ +db-78n9n \ No newline at end of file diff --git a/samples/nginx-flask-mysql/docker-compose.yaml b/samples/nginx-flask-mysql/docker-compose.yaml new file mode 100644 index 0000000..a9f740f --- /dev/null +++ b/samples/nginx-flask-mysql/docker-compose.yaml @@ -0,0 +1,27 @@ +version: "3.7" +services: + backend: + build: backend + depends_on: + - db + db: + environment: + MYSQL_DATABASE: example + MYSQL_ROOT_PASSWORD_FILE: /run/secrets/db-password + image: mysql:5.7 + restart: always + secrets: + - db-password + volumes: + - db-data:/var/lib/mysql + proxy: + build: proxy + ports: + - 80:80 + depends_on: + - backend +volumes: + db-data: {} +secrets: + db-password: + file: db/password.txt diff --git a/samples/nginx-flask-mysql/proxy/Dockerfile b/samples/nginx-flask-mysql/proxy/Dockerfile new file mode 100755 index 0000000..f5760d0 --- /dev/null +++ b/samples/nginx-flask-mysql/proxy/Dockerfile @@ -0,0 +1,2 @@ +FROM nginx:1.13-alpine +COPY conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/samples/nginx-flask-mysql/proxy/conf b/samples/nginx-flask-mysql/proxy/conf new file mode 100755 index 0000000..2a272bc --- /dev/null +++ b/samples/nginx-flask-mysql/proxy/conf @@ -0,0 +1,8 @@ +server { + listen 80; + server_name localhost; + location / { + proxy_pass http://backend:5000; + } + +}