Skip to content

Commit 3e5493a

Browse files
author
asim3 from runner
committed
update Dockefile Python Web
1 parent 41ff2b9 commit 3e5493a

File tree

1 file changed

+13
-28
lines changed

1 file changed

+13
-28
lines changed

data/docker/build/index.md

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -40,49 +40,34 @@ CMD [ "/my_app/manage.py" ]
4040
```
4141

4242

43-
## Django
43+
## Python Web
4444
```dockerfile
45-
FROM python:3.11-bullseye
46-
47-
ENV APP_HOME=/home/d_user/web
45+
FROM python:3.11-slim-bullseye
4846

49-
RUN addgroup --system d_group && adduser --system d_user && adduser d_user d_group
47+
RUN apt-get update && apt-get install -y gcc python3-dev libpq-dev
5048

51-
RUN install -d -m 0750 -o d_user -g d_group $APP_HOME /tmp/d_dir
49+
RUN adduser --system --shell /bin/bash --uid 1000 --group --disabled-password --disabled-login d_user
5250

53-
WORKDIR $APP_HOME
51+
ENV APP_HOME=/home/d_user/web
5452

55-
COPY --chown=d_user:d_group --chmod=550 ./entrypoint.sh $APP_HOME/entrypoint.sh
53+
RUN install -d -m 0750 -o d_user -g d_user $APP_HOME $APP_HOME/tmp
5654

57-
COPY --chown=d_user:d_group --chmod=550 ./requirements.txt $APP_HOME/requirements.txt
55+
COPY --chown=d_user:d_user --chmod=550 ./requirements.txt $APP_HOME/requirements.txt
5856

5957
RUN pip install --no-cache-dir -r $APP_HOME/requirements.txt
6058

61-
COPY --chown=d_user:d_group --chmod=550 ./__proj__ $APP_HOME
59+
COPY --chown=d_user:d_user --chmod=550 ./__proj__ $APP_HOME
6260

63-
USER d_user
61+
WORKDIR $APP_HOME
6462

65-
ENTRYPOINT ["/home/d_user/web/entrypoint.sh"]
63+
USER d_user
6664

67-
# nano entrypoint.sh
68-
# python manage.py migrate
69-
# python manage.py collectstatic --noinput
70-
# gunicorn --bind :8000 --workers 3 __proj__.wsgi
71-
```
65+
ENTRYPOINT ["gunicorn --bind :8000 --workers 3 __proj__.wsgi"]
7266

67+
## Django
68+
CMD [ "python3", "-m" , "flask", "run", "--host=0.0.0.0"]
7369

7470
## Flask
75-
```dockerfile
76-
FROM python:3.11-slim-bullseye
77-
78-
COPY requirements.txt /flask/requirements.txt
79-
80-
RUN pip3 install -r /flask/requirements.txt
81-
82-
COPY . /flask
83-
84-
WORKDIR /flask
85-
8671
CMD [ "python3", "-m" , "flask", "run", "--host=0.0.0.0"]
8772
```
8873

0 commit comments

Comments
 (0)