-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.prod
57 lines (51 loc) · 2.09 KB
/
Dockerfile.prod
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
# cra build environment
FROM node:13.12.0-alpine as build
WORKDIR /app
COPY package.json /app/package.json
COPY package-lock.json /app/package-lock.json
RUN npm ci --silent
RUN npm install
RUN npm install axios
COPY src /app/src
COPY public /app/public
RUN npm run build
#-------------------------------------------------
# production environment
FROM ubuntu:18.04
WORKDIR /django_static
EXPOSE 80
# configure apache
RUN apt-get update && \
apt-get -y install apache2
COPY --from=build /app/build /var/www/html
RUN echo '. /etc/apache2/envvars' > /root/run_apache.sh && \
echo 'service apache2 start' >> /root/run_apache.sh && \
chmod 755 /root/run_apache.sh
# configure django
RUN apt-get update
RUN apt-get install python3-pip libapache2-mod-wsgi-py3 -y
COPY django/settings.py /tmp/settings.py
COPY django/urls.py /tmp/urls.py
COPY django/pages /tmp/pages
COPY django/leads /tmp/leads
COPY 000-default.conf /tmp/000-default.conf
RUN echo 'pip3 install virtualenv' > /root/run_django.sh && \
echo 'virtualenv myprojectenv' >> /root/run_django.sh && \
echo '. myprojectenv/bin/activate' >> /root/run_django.sh && \
echo 'pip3 install django' >> /root/run_django.sh && \
echo 'pip3 install djangorestframework' >> /root/run_django.sh && \
echo 'pip3 install requests' >> /root/run_django.sh && \
echo 'django-admin.py startproject myproject .' >> /root/run_django.sh && \
echo 'cp /tmp/settings.py /django_static/myproject/settings.py' >> /root/run_django.sh && \
echo 'cp /tmp/urls.py /django_static/myproject/urls.py' >> /root/run_django.sh && \
echo 'cp -r /tmp/pages /django_static/' >> /root/run_django.sh && \
echo 'cp -r /tmp/leads /django_static/' >> /root/run_django.sh && \
echo 'cp /tmp/000-default.conf /etc/apache2/sites-available/000-default.conf' >> /root/run_django.sh && \
echo 'deactivate' >> /root/run_django.sh && \
chmod 755 /root/run_django.sh
# integrate commands into a shell file
RUN echo '/root/run_django.sh' > /root/execute.sh && \
echo '/root/run_apache.sh' >> /root/execute.sh && \
echo 'sleep infinity' >> /root/execute.sh && \
chmod 755 /root/execute.sh
CMD /root/execute.sh