-
Notifications
You must be signed in to change notification settings - Fork 293
/
Dockerfile
65 lines (54 loc) · 2.53 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
FROM awesto/fedora-uwsgi-python:5
LABEL Description="Run django-angular demo" Maintainer="Jacob Rief <jacob.rief@gmail.com>"
# install and configure Redis
RUN dnf install -y redis
RUN mkdir -p /web/redis
COPY docker-files/redis.ini /etc/uwsgi.d/redis.ini
COPY docker-files/redis.conf /etc/redis.conf
RUN chown redis.redis /etc/uwsgi.d/redis.ini
RUN chown -R redis.redis /web/redis
RUN useradd -M -d /web -g uwsgi -s /bin/bash django
# install the basic Django package
RUN echo 2 | alternatives --config python
RUN python -V
# RUN pip install --upgrade pip
# RUN pip install --force-reinstall uwsgi
RUN pip install django==1.10.7
# copy the local django-angular file into a temporary folder
RUN mkdir -p /tmp/django-angular
COPY LICENSE.txt /tmp/django-angular
COPY README.md /tmp/django-angular
COPY MANIFEST.in /tmp/django-angular
COPY setup.py /tmp/django-angular
ADD djng /tmp/django-angular/djng
# and from there install it into the site-package using setup.py
RUN pip install /tmp/django-angular
RUN rm -rf /tmp/django-angular
# create the example project
RUN mkdir -p /web/workdir/{media,static}
ADD examples/server /web/django-angular-demo/server
ADD client /web/django-angular-demo/client
COPY docker-files/wsgi_runserver.py /web/django-angular-demo/wsgi_runserver.py
COPY docker-files/wsgi_websocket.py /web/django-angular-demo/wsgi_websocket.py
COPY examples/manage.py /web/django-angular-demo/manage.py
COPY examples/package.json /web/django-angular-demo/package.json
COPY examples/requirements.txt /tmp/requirements.txt
RUN pip install -r /tmp/requirements.txt
RUN pip install django-websocket-redis
# install packages under node_modules/ outside of PyPI
WORKDIR /web/django-angular-demo
RUN npm install
# add uwsgi.ini file into workdir, so that touching this file restarts the Django server
COPY docker-files/uwsgi-emperor.ini /etc/uwsgi.ini
COPY docker-files/uwsgi-websocket.ini /web/workdir/uwsgi-websocket.ini
RUN ln -s /web/workdir/uwsgi-websocket.ini /etc/uwsgi.d/djangular-websocket.ini
COPY docker-files/uwsgi-runserver.ini /web/workdir/uwsgi-runserver.ini
RUN ln -s /web/workdir/uwsgi-runserver.ini /etc/uwsgi.d/djangular-runserver.ini
# collect static files
RUN CLIENT_SRC_DIR=/web/django-angular-demo/client/src NODE_MODULES_DIR=/web/django-angular-demo/node_modules DJANGO_STATIC_ROOT=/web/workdir/static ./manage.py collectstatic --noinput
RUN chown -R django.uwsgi /web/{logs,workdir}
# share media files
VOLUME /web/workdir/media
# when enabling the CMD disable deamonize in uwsgi.ini
EXPOSE 9002
CMD ["/usr/sbin/uwsgi", "--ini", "/etc/uwsgi.ini"]