-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
70 lines (57 loc) · 1.73 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
66
67
68
69
70
FROM ubuntu:16.04
MAINTAINER Hang Park <hangpark@kaist.ac.kr>
# Install packages
RUN apt-get update \
&& apt-get install -y \
gcc \
python3.5-dev \
mysql-client \
nginx \
python-virtualenv \
npm \
nodejs-legacy \
git \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Configure Nginx
WORKDIR /etc/nginx/sites-available
ADD nginx.conf exampleproject
WORKDIR /etc/nginx/sites-enabled
RUN rm default \
&& ln -s ../sites-available/exampleproject ./exampleproject \
&& echo "\ndaemon off;" >> /etc/nginx/nginx.conf
# Configure uWSGI
RUN mkdir -p /tmp/uwsgi
# Download frontend dependencies
WORKDIR /app/exampleproject
ADD package.json package.json
ADD bower.json bower.json
RUN npm install \
&& node_modules/bower/bin/bower install --allow-root
# Set python virtual environment
WORKDIR /app/exampleproject
RUN mkdir -p /app/exampleproject
ADD requirements.txt requirements.txt
RUN virtualenv --python=python3 venv \
&& /bin/bash -c "source venv/bin/activate && pip install -r requirements.txt"
# Add whole project
WORKDIR /app/exampleproject
ADD ./ ./
# Configure Django settings
ENV DJANGO_SETTINGS_MODULE exampleproject.settings.production
# Compile frontends and collect static files
WORKDIR /app/exampleproject
RUN node_modules/gulp/bin/gulp.js \
&& /bin/bash -c "source venv/bin/activate && python manage.py collectstatic --noinput"
# Compile document
WORKDIR /app/exampleproject/docs
RUN /bin/bash -c "source ../venv/bin/activate && make html"
# Move to root directory
WORKDIR /app/exampleproject
# Configure server encoding
ENV LANG C.UTF-8
# Expose ports
EXPOSE 80 443
# Run server
RUN chmod +x /app/exampleproject/docker-entrypoint.sh
ENTRYPOINT /app/exampleproject/docker-entrypoint.sh