Make docker default configuration production ready
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Armin Friedl 2020-11-08 14:42:55 +01:00
parent 9d10f4f5b9
commit 1782a97bcb
4 changed files with 11 additions and 7 deletions

View file

@ -1 +0,0 @@
SNIP_STAGE=local

View file

@ -3,15 +3,16 @@ FROM python:3.8-alpine
RUN apk update && apk add su-exec \ RUN apk update && apk add su-exec \
&& pip3 install pipenv && pip3 install pipenv
RUN mkdir -p /data
COPY . /app COPY . /app
WORKDIR /app WORKDIR /app
RUN pipenv install RUN pipenv install
ENV FLASK_APP=snip ENV SNIP_DATABASE="sqlite"
ENV FLASK_ENV=production ENV SNIP_DATABASE_URI="sqlite:////data/snip.db"
ENV SNIP_FLASK_HOST="0.0.0.0"
RUN ["pipenv", "run", "python", "-c", "from snip import db; db.create_all()"]
EXPOSE 5000 EXPOSE 5000
CMD ["pipenv", "run", "flask", "run", "--host=0.0.0.0"] CMD ["pipenv", "run", "python", "-m", "snip"]

View file

@ -1,4 +1,5 @@
from . import app from . import app
from . import snip_config
if __name__ == "__main__": if __name__ == "__main__":
app.run() app.run(host=snip_config.SNIP_FLASK_HOST, port=snip_config.SNIP_FLASK_PORT)

View file

@ -43,6 +43,9 @@ 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
# Non-standard flask settings
SNIP_FLASK_HOST: str = "localhost"
SNIP_FLASK_PORT: int = 5000
# Snip settings # Snip settings
SNIP_STAGE: Optional[str] SNIP_STAGE: Optional[str]