-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathDockerfile
executable file
·125 lines (101 loc) · 3.64 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
115
116
117
118
119
120
121
122
123
124
125
FROM ubuntu:20.04
MAINTAINER Forrest Kim <[email protected]>
#############################################
## Arguments ##
#############################################
ARG AA_USER
ARG AA_GROUP
ARG UID
ARG GID
# ARG ACCOUNT_AUTHENTICATED_LOGIN_REDIRECTS
# ARG GOOGLE_SECRET_KEY
# ARG GLOBUS_SECRET_KEY
# ARG ACCOUNT_DEFAULT_HTTP_PROTOCOL
# ARG SECURE_SSL_REDIRECT
# ARG DB_URI
# ARG S3_FILE_DOWNLOADS
# ARG AWS_PROFILE_NAME
# ARG S3_DOWNLOADS_BUCKET_PATH
# ARG S3_STATIC_FILES
#############################################
## System updates ##
#############################################
RUN apt-get -y update && \
apt-get -y upgrade && \
apt-get -y install wget git bzip2 libcurl4-gnutls-dev gcc python3-dev libmysqlclient-dev && \
apt-get purge && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
ENV LANG C.UTF-8
#############################################
## Create the config directory ##
#############################################
RUN mkdir /config
#############################################
## Install Python ##
#############################################
RUN apt-get update && apt-get install -y \
python3.8 \
python3-pip \
python3-venv
#############################################
## Create the webapp environment ##
#############################################
COPY ./requirements.txt /src/requirements.txt
RUN python3 -m venv /opt/venv
RUN /bin/bash -c "source /opt/venv/bin/activate && \
pip install -r /src/requirements.txt"
#############################################
## Set-up working directory ##
#############################################
WORKDIR /srv/caper/
COPY ./caper/ /srv/caper/
# RUN git clone [email protected]:mesirovlab/caper.git /srv/caper/
#############################################
## Configure the repository ##
#############################################
# # Add settings.py to config dir
# RUN cp /caper/settings.py /config/settings.py
# RUN rm /caper/settings.py
# RUN ln -s /srv/config/settings.py /srv/caper/caper/settings.py
# # Add the templates to the config dir
# RUN cp -r /srv/caper/templates /config/
# RUN rm -r /srv/caper/templates
# RUN ln -s /config/templates /srv/caper/templates
# # Add the static files to the config dir
# RUN cp -r /srv/caper/static /config/
# RUN rm -r /srv/caper/static
# RUN ln -s /config/static /srv/caper/static
RUN /bin/bash -c "source /opt/venv/bin/activate && \
source /srv/caper/config.sh && \
/srv/caper/manage.py makemigrations"
RUN /bin/bash -c "source /opt/venv/bin/activate && \
source /srv/caper/config.sh && \
/srv/caper/manage.py migrate --run-syncdb"
RUN /bin/bash -c "source /opt/venv/bin/activate && \
source /srv/caper/config.sh && \
/srv/caper/manage.py collectstatic --noinput"
# COPY ./start-server.sh /srv/caper/start-server.sh
#############################################
## Start the webapp ##
#############################################
RUN mkdir -p /srv/logs/
COPY ./run-manage-py.sh /srv/run-manage-py.sh
RUN apt-get update && apt-get install vim --yes
# Create user if specified
RUN /bin/bash -c "if [[ -z '${UID}' || -z '${AA_USER}' || -z '${GID}' ]] ; \
then echo 'Running as root'; \
export AA_USER=root; \
else echo 'Running as ${UID} ${AA_USER}'; \
addgroup --gid ${GID} ${AA_GROUP}; \
useradd -ms /bin/bash -u ${UID} ${AA_USER}; \
chown ${AA_USER}:${GID} -R /srv; \
su - ${AA_USER}; \
fi"
# Check which user is set
RUN whoami
RUN echo ${AA_USER}
USER ${AA_USER}
RUN whoami
EXPOSE 8000
CMD ["/srv/run-manage-py.sh","&"]