chore(docker): include .env, fix port, install dotenv
This commit is contained in:
parent
6c994db855
commit
f396c98cbe
2 changed files with 12 additions and 6 deletions
|
|
@ -2,7 +2,7 @@
|
||||||
__pycache__/
|
__pycache__/
|
||||||
*.py[cod]
|
*.py[cod]
|
||||||
*.log
|
*.log
|
||||||
.env
|
!.env
|
||||||
venv/
|
venv/
|
||||||
.venv/
|
.venv/
|
||||||
dist/
|
dist/
|
||||||
|
|
|
||||||
16
Dockerfile
16
Dockerfile
|
|
@ -16,17 +16,17 @@ RUN python -m pip install --upgrade pip && \
|
||||||
pip wheel --no-deps -r requirements.txt -w /wheels && \
|
pip wheel --no-deps -r requirements.txt -w /wheels && \
|
||||||
pip wheel --no-deps gunicorn -w /wheels
|
pip wheel --no-deps gunicorn -w /wheels
|
||||||
|
|
||||||
|
|
||||||
FROM python:3.10-slim AS runtime
|
FROM python:3.10-slim AS runtime
|
||||||
|
|
||||||
ENV PYTHONDONTWRITEBYTECODE=1 \
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||||
PYTHONUNBUFFERED=1 \
|
PYTHONUNBUFFERED=1 \
|
||||||
PIP_NO_CACHE_DIR=1 \
|
PIP_NO_CACHE_DIR=1 \
|
||||||
PORT=8000 \
|
PORT=5000 \
|
||||||
WSGI_MODULE=server:app \
|
WSGI_MODULE=server:app \
|
||||||
GUNICORN_WORKERS=2 \
|
GUNICORN_WORKERS=2 \
|
||||||
GUNICORN_THREADS=4 \
|
GUNICORN_THREADS=4 \
|
||||||
GUNICORN_TIMEOUT=60
|
GUNICORN_TIMEOUT=60 \
|
||||||
|
FLASK_APP=server.py
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
|
@ -35,13 +35,19 @@ RUN groupadd -g 10001 app && useradd -m -u 10001 -g app app
|
||||||
COPY --from=builder /wheels /wheels
|
COPY --from=builder /wheels /wheels
|
||||||
RUN pip install --no-cache-dir /wheels/* && rm -rf /wheels
|
RUN pip install --no-cache-dir /wheels/* && rm -rf /wheels
|
||||||
|
|
||||||
|
# Install python-dotenv if not already in requirements.txt
|
||||||
|
RUN pip install python-dotenv
|
||||||
|
|
||||||
USER app
|
USER app
|
||||||
|
|
||||||
COPY --chown=app:app . .
|
COPY --chown=app:app . .
|
||||||
|
|
||||||
EXPOSE 8000
|
# Copy .env file specifically
|
||||||
|
COPY --chown=app:app .env .env
|
||||||
|
|
||||||
|
EXPOSE 5000
|
||||||
|
|
||||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
|
||||||
CMD python -c "import os,socket; s=socket.socket(); s.settimeout(2); s.connect(('127.0.0.1', int(os.getenv('PORT', '8000')))); s.close()"
|
CMD python -c "import os,socket; s=socket.socket(); s.settimeout(2); s.connect(('127.0.0.1', int(os.getenv('PORT', '5000')))); s.close()"
|
||||||
|
|
||||||
CMD ["sh", "-c", "exec gunicorn $WSGI_MODULE --bind=0.0.0.0:$PORT --workers=$GUNICORN_WORKERS --threads=$GUNICORN_THREADS --timeout=$GUNICORN_TIMEOUT --access-logfile=- --error-logfile=- --keep-alive=5"]
|
CMD ["sh", "-c", "exec gunicorn $WSGI_MODULE --bind=0.0.0.0:$PORT --workers=$GUNICORN_WORKERS --threads=$GUNICORN_THREADS --timeout=$GUNICORN_TIMEOUT --access-logfile=- --error-logfile=- --keep-alive=5"]
|
||||||
Loading…
Add table
Add a link
Reference in a new issue