Use https as default scheme, run behind gunicorn in container
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Armin Friedl 2020-11-09 05:37:17 +01:00
parent e231c63332
commit 557ae95406
4 changed files with 5 additions and 1 deletions

View file

@ -7,3 +7,4 @@ SNIP_DATABASE_TRACK_MODIFICATIONS=False
SNIP_FLASK_SECRET=secret SNIP_FLASK_SECRET=secret
SNIP_FLASK_ENVIRONMENT=development SNIP_FLASK_ENVIRONMENT=development
SNIP_FLASK_DEBUG=True SNIP_FLASK_DEBUG=True
SNIP_FLASK_PREFERRED_URL_SCHEME=http

View file

@ -9,10 +9,11 @@ COPY . /app
WORKDIR /app WORKDIR /app
RUN pipenv install RUN pipenv install
RUN pipenv install gunicorn
ENV SNIP_DATABASE="sqlite" ENV SNIP_DATABASE="sqlite"
ENV SNIP_DATABASE_URI="sqlite:////data/snip.db" ENV SNIP_DATABASE_URI="sqlite:////data/snip.db"
ENV SNIP_FLASK_HOST="0.0.0.0" ENV SNIP_FLASK_HOST="0.0.0.0"
EXPOSE 5000 EXPOSE 5000
CMD ["pipenv", "run", "python", "-m", "snip"] CMD ["pipenv", "run", "gunicorn", "-b0.0.0.0:5000", "snip:app"]

View file

@ -24,6 +24,7 @@ app = Flask(__name__)
app.config.update( app.config.update(
SECRET_KEY = snip_config.SNIP_FLASK_SECRET.get_secret_value(), SECRET_KEY = snip_config.SNIP_FLASK_SECRET.get_secret_value(),
PREFERRED_URL_SCHEME = snip_config.SNIP_FLASK_PREFERRED_URL_SCHEME,
SQLALCHEMY_DATABASE_URI = snip_config.SNIP_DATABASE_URI, SQLALCHEMY_DATABASE_URI = snip_config.SNIP_DATABASE_URI,
SQLALCHEMY_TRACK_MODIFICATIONS = snip_config.SNIP_DATABASE_TRACK_MODIFICATION) SQLALCHEMY_TRACK_MODIFICATIONS = snip_config.SNIP_DATABASE_TRACK_MODIFICATION)

View file

@ -43,6 +43,7 @@ class SnipConfig(BaseModel):
SNIP_FLASK_ENVIRONMENT: Literal['development', 'production'] = 'production' SNIP_FLASK_ENVIRONMENT: Literal['development', 'production'] = 'production'
SNIP_FLASK_DEBUG: bool = False SNIP_FLASK_DEBUG: bool = False
SNIP_FLASK_SKIP_DOTENV: int = 1 SNIP_FLASK_SKIP_DOTENV: int = 1
SNIP_FLASK_PREFERRED_URL_SCHEME: Literal['http', 'https'] = 'https'
# Non-standard flask settings # Non-standard flask settings
SNIP_FLASK_HOST: str = "localhost" SNIP_FLASK_HOST: str = "localhost"
SNIP_FLASK_PORT: int = 5000 SNIP_FLASK_PORT: int = 5000