diff --git a/.snipenv b/.snipenv index a2a9f68..e69de29 100644 --- a/.snipenv +++ b/.snipenv @@ -1 +0,0 @@ -SNIP_STAGE=local diff --git a/Dockerfile b/Dockerfile index 8692a75..a395853 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,15 +3,16 @@ FROM python:3.8-alpine RUN apk update && apk add su-exec \ && pip3 install pipenv +RUN mkdir -p /data + COPY . /app WORKDIR /app RUN pipenv install -ENV FLASK_APP=snip -ENV FLASK_ENV=production - -RUN ["pipenv", "run", "python", "-c", "from snip import db; db.create_all()"] +ENV SNIP_DATABASE="sqlite" +ENV SNIP_DATABASE_URI="sqlite:////data/snip.db" +ENV SNIP_FLASK_HOST="0.0.0.0" EXPOSE 5000 -CMD ["pipenv", "run", "flask", "run", "--host=0.0.0.0"] +CMD ["pipenv", "run", "python", "-m", "snip"] diff --git a/snip/__main__.py b/snip/__main__.py index 8a1b435..ef70c70 100644 --- a/snip/__main__.py +++ b/snip/__main__.py @@ -1,4 +1,5 @@ from . import app +from . import snip_config if __name__ == "__main__": - app.run() + app.run(host=snip_config.SNIP_FLASK_HOST, port=snip_config.SNIP_FLASK_PORT) diff --git a/snip/config.py b/snip/config.py index 4524647..12d9324 100644 --- a/snip/config.py +++ b/snip/config.py @@ -43,6 +43,9 @@ class SnipConfig(BaseModel): SNIP_FLASK_ENVIRONMENT: Literal['development', 'production'] = 'production' SNIP_FLASK_DEBUG: bool = False SNIP_FLASK_SKIP_DOTENV: int = 1 + # Non-standard flask settings + SNIP_FLASK_HOST: str = "localhost" + SNIP_FLASK_PORT: int = 5000 # Snip settings SNIP_STAGE: Optional[str]