Last active
September 28, 2023 02:28
-
-
Save BroHui/9f39db6f15bf19b77699b062212e787f to your computer and use it in GitHub Desktop.
Django 1.11 LTS ship on Docker with uwsgi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker run --rm -it --name django -p 8081:8081 -v /root/django1.11/demo:/data -e "UWSGI_INI=/data/demo.ini" django1.11-elite |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3.9" | |
services: | |
api: | |
build: docker/ | |
ports: | |
- "8082:8000" | |
volumes: | |
- ./src:/data | |
environment: | |
- DEBUG=1 | |
- ALLOWED_HOSTS=* | |
networks: | |
default: | |
external: true | |
name: yours |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
APP_ROOT='/data' | |
STATIC_ROOT='/usr/src/static' | |
MEDIA_ROOT='/usr/src/media' | |
mkdir -pv $MEDIA_ROOT | |
cd $APP_ROOT | |
# collect statics | |
sed -i '/^MEDIA_ROOT/c\MEDIA_ROOT="'$MEDIA_ROOT'"' `find . | grep settings.py` | |
sed -i '/^STATIC_ROOT/c\STATIC_ROOT="'$STATIC_ROOT'"' `find . | grep settings.py` | |
python manage.py collectstatic --noinput | |
# remove debug symbol | |
#sed -i '/^DEBUG/c\DEBUG=False' `find . | grep settings.py` | |
exec $@ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM python:2.7.18-slim-stretch as base | |
WORKDIR /wheels | |
COPY ./requirements.txt . | |
RUN apt-get update && \ | |
apt-get install -y \ | |
default-libmysqlclient-dev \ | |
libmariadbclient18 \ | |
gcc | |
RUN pip install -U pip \ | |
&& pip install --no-cache-dir wheel \ | |
&& pip wheel --no-cache-dir --wheel-dir=/wheels -r requirements.txt | |
FROM python:2.7.18-slim-stretch | |
ENV PYTHONUNBUFFERED 1 | |
COPY --from=base /wheels /wheels | |
COPY --from=base /usr/lib/x86_64-linux-gnu/libmariadbclient.so.18.0.0 /usr/lib/x86_64-linux-gnu/ | |
RUN pip install -U pip \ | |
&& pip install -f /wheels -r /wheels/requirements.txt \ | |
&& rm -rf /wheels \ | |
&& rm -rf /root/.cache/pip/* \ | |
&& ln -sf /usr/lib/x86_64-linux-gnu/libmariadbclient.so.18.0.0 /usr/lib/x86_64-linux-gnu/libmariadbclient.so.18 | |
WORKDIR /data | |
COPY ./docker-entrypoint.sh / | |
ENTRYPOINT ["sh", "/docker-entrypoint.sh"] | |
CMD ["uwsgi", "--chdir", "/data", \ | |
"--module", "demo.wsgi", \ | |
"--master", \ | |
"--processes", "5", \ | |
"--http", "0.0.0.0:8000", \ | |
"--vacuum", \ | |
"--static-map", "/static=/usr/src/static", \ | |
"--static-map", "/media=/usr/src/media" \ | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Django == 1.11 | |
MySQL-python==1.2.5 | |
uwsgi >= 1.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[uwsgi] | |
chdir = /data | |
module = zbgroup.wsgi | |
master = true | |
processes = 4 | |
threads = 2 | |
listen = 3000 | |
max-requests = 65535 | |
optimize = 2 | |
socket = 0.0.0.0:8080 | |
http = 0.0.0.0:8081 | |
vacuum = true | |
#disable-logging = true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment