File tree Expand file tree Collapse file tree 4 files changed +41
-0
lines changed
Expand file tree Collapse file tree 4 files changed +41
-0
lines changed Original file line number Diff line number Diff line change 1+ FROM python:3.6-alpine
2+
3+ ENV FLASK_APP flasky.py
4+ ENV FLASK_CONFIG production
5+
6+ RUN adduser -D flasky
7+ USER flasky
8+
9+ WORKDIR /home/flasky
10+
11+ COPY requirements requirements
12+ RUN python -m venv venv
13+ RUN venv/bin/pip install -r requirements/docker.txt
14+
15+ COPY app app
16+ COPY migrations migrations
17+ COPY flasky.py config.py boot.sh ./
18+
19+ # run-time configuration
20+ EXPOSE 5000
21+ ENTRYPOINT ["./boot.sh" ]
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+ source venv/bin/activate
3+ flask deploy
4+ exec gunicorn -b :5000 --access-logfile - --error-logfile - flasky:app
Original file line number Diff line number Diff line change @@ -86,11 +86,25 @@ def init_app(cls, app):
8686 app .logger .addHandler (file_handler )
8787
8888
89+ class DockerConfig (ProductionConfig ):
90+ @classmethod
91+ def init_app (cls , app ):
92+ ProductionConfig .init_app (app )
93+
94+ # log to stderr
95+ import logging
96+ from logging import StreamHandler
97+ file_handler = StreamHandler ()
98+ file_handler .setLevel (logging .INFO )
99+ app .logger .addHandler (file_handler )
100+
101+
89102config = {
90103 'development' : DevelopmentConfig ,
91104 'testing' : TestingConfig ,
92105 'production' : ProductionConfig ,
93106 'heroku' : HerokuConfig ,
107+ 'docker' : DockerConfig ,
94108
95109 'default' : DevelopmentConfig
96110}
Original file line number Diff line number Diff line change 1+ -r common.txt
2+ gunicorn==19.7.1
You can’t perform that action at this time.
0 commit comments