updated both docker files to work on self hosting

This commit is contained in:
iritmaximus
2023-05-17 21:34:42 +03:00
parent 4df72b9288
commit fbd97abb19
2 changed files with 23 additions and 5 deletions
+20 -5
View File
@@ -1,11 +1,26 @@
# syntax=docker/dockerfile:1
FROM python:alpine
WORKDIR /app
RUN pip install --upgrade pip
COPY requirements.txt requirements.txt
RUN pip3 install -r requirements.txt
RUN adduser -D nonroot
RUN mkdir /home/app/ && chown -R nonroot:nonroot /home/app
WORKDIR /home/app
USER nonroot
COPY . .
COPY --chown=nonroot:nonroot requirements.txt requirements.txt
CMD [ "gunicorn", "-w", "4", "flaskr:app", "-b", "0.0.0.0:5000", "--access-logfile", "-", "--error-logfile", "-"]
# venv
ENV VIRTUAL_ENV=/home/app/venv
# python setup
RUN python -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
RUN export FLASK_APP=__init__.py
RUN pip install -r requirements.txt
COPY --chown=nonroot:nonroot flaskr flaskr
ENTRYPOINT ["gunicorn"]
CMD [ "-w", "4", "flaskr:app", "-b", "0.0.0.0:5000", "--access-logfile", "-", "--error-logfile", "-"]
# CMD ["python", "run.py"]
# CMD [ "gunicorn", "-w", "4", "flaskr:app", "-b", "0.0.0.0:5000"]
@@ -1,8 +1,11 @@
version: "2"
services:
flask:
build:
context: .
dockerfile: Dockerfile
# command: sh -c "gunicorn -w 4 flaskr:app -b 0.0.0.0:5000 --access-logfile '-' --error-logfile '-'"
# command: sh -c "ls"
ports:
- "5000:5000"
volumes: