-
Notifications
You must be signed in to change notification settings - Fork 24
/
Dockerfile
116 lines (83 loc) · 2.9 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
FROM python:3.12.7
RUN apt-get clean all
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get dist-upgrade -y
# Git
# ---
# required by github dependencies in requirements.txt
RUN apt-get -y install git
# mysql CL client
# -------------------------
# - good for debugging sometimes
RUN apt-get install -y mysql\*
# libmysqlclient
# --------------
# - required to be able to install mysqlclient with pip
# https://stackoverflow.com/questions/5178292/pip-install-mysql-python-fails-with-environmenterror-mysql-config-not-found
RUN apt-get install -y default-libmysqlclient-dev
# mysql CL client
# -------------------------
# - good for debugging sometimes
RUN apt-get install -y mysql\*
# libmysqlclient
# --------------
# - required to be able to install mysqlclient with pip
# https://stackoverflow.com/questions/5178292/pip-install-mysql-python-fails-with-environmenterror-mysql-config-not-found
RUN apt-get install -y default-libmysqlclient-dev
# Apache
# ------
RUN apt-get install -y \
apache2 \
apache2-dev \
vim
# mod_wsgi
# --------
RUN pip install mod_wsgi
RUN /bin/bash -c 'mod_wsgi-express install-module | tee /etc/apache2/mods-available/wsgi.{load,conf}'
RUN a2enmod wsgi
RUN a2enmod headers
# ML: maybe better to map this file from outside?
RUN echo '\n\
<VirtualHost *:8080>\n\
WSGIDaemonProcess zeeguu_api home=/zeeguu-data/ python-path=/Zeeguu-API/\n\
WSGIScriptAlias / /Zeeguu-API/zeeguu_api.wsgi\n\
<Location />\n\
WSGIProcessGroup zeeguu_api\n\
WSGIApplicationGroup %{GLOBAL}\n\
</Location>\n\
<Directory "/Zeeguu-API">\n\
<Files "zeeguu_api.wsgi">\n\
Require all granted\n\
</Files>\n\
</Directory>\n\
ErrorLog ${APACHE_LOG_DIR}/error.log\n\
LogLevel info\n\
CustomLog ${APACHE_LOG_DIR}/access.log combined\n\
</VirtualHost>' > /etc/apache2/sites-available/zeeguu-api.conf
RUN chown -R www-data:www-data /var/www
# have apache listen on port 8080
RUN sed -i "s,Listen 80,Listen 8080,g" /etc/apache2/ports.conf
# Zeeguu-Api
# ----------
# Declare that this will be mounted from a volume
VOLUME /Zeeguu-API
# We need to copy the requirements file it in order to be able to install it
# However, we're not copying the whole folder, such that in case we make a change in the folder
# (e.g. to this build file) the whole cache is not invalidated and the build process does
# not have to start from scratch
RUN mkdir /Zeeguu-API
COPY ./requirements.txt /Zeeguu-API/requirements.txt
COPY ./setup.py /Zeeguu-API/setup.py
# Install requirements and setup
WORKDIR /Zeeguu-API
RUN python -m pip install -r requirements.txt
RUN python setup.py develop
# Copy the rest of the files
# (this is done after the requirements are installed, so that the cache is not invalidated)
WORKDIR /Zeeguu-API
COPY . /Zeeguu-API
ENV ZEEGUU_CONFIG=/Zeeguu-API/default_docker.cfg
VOLUME /zeeguu-data
RUN a2dissite 000-default.conf
RUN a2ensite zeeguu-api