-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
85 lines (62 loc) · 3.12 KB
/
Dockerfile
File metadata and controls
85 lines (62 loc) · 3.12 KB
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
FROM ubuntu:16.04
ENV DEBIAN_FRONTEND noninteractive
# We need GITHUB_USER and GITHUB_TOKEN passed in as
# --build-arg GITHUB_USER=...
# --build-arg GITHUB_TOKEN=...
# so that we can access github to post comments.
# User *MUST* provide this for posting to github to work.
ARG GITHUB_USER
ARG GITHUB_TOKEN
ARG GITHUB_SECRET
RUN echo "checking if gave GITHUB_USER build arg" && test -n "$GITHUB_USER"
RUN echo "checking if gave GITHUB_TOKEN build arg" && test -n "$GITHUB_TOKEN"
RUN echo "checking if gave GITHUB_SECRET build arg" && test -n "$GITHUB_SECRET"
# We need OX_WEB_USER and OX_PASSWD_HASH if you want to be able to login
# to the server without manually providing a user/password database.
ARG OX_WEB_USER=disabled
ARG OX_PASSWD_HASH=disabled
RUN echo "if OX_WEB_USER build arg empty server will not start" && test -n "$OX_WEB_USER"
RUN echo "if OX_PASSWD_HASH build arg empty server will not start" && test -n "$OX_PASSWD_HASH"
# Need to do an apt-get update early on or lots of things won't work.
RUN apt-get update
# Need a few things early on so install them first
RUN apt-get -y install software-properties-common wget iproute2
RUN add-apt-repository -y ppa:certbot/certbot
RUN apt-get update && \
apt-get -y install curl python3 build-essential python3-pip && \
apt-get -y install libffi-dev git screen apache2-utils && \
apt-get -y install lynx nano openssh-server redis-server
# Setup the user to run ox_herd making sure to:
# 1. Make the primary group www-data so WSGI works if you later decide
# to use it. This is helpful since if you "git pull" some new files,
# you want them to have group www-data so the WSGI web server can
# read them.
# 2. Setup profile properly
RUN useradd -ms /bin/bash ox_user && \
usermod -g www-data ox_user && \
usermod -a -G www-data ox_user && \
echo "[pytest/DEFAULT]" > /home/ox_user/.ox_herd_conf && \
echo "github_user = $GITHUB_USER" >> /home/ox_user/.ox_herd_conf && \
echo "github_token = $GITHUB_TOKEN" >> /home/ox_user/.ox_herd_conf && \
echo "github_secret = $GITHUB_SECRET" >> /home/ox_user/.ox_herd_conf && \
echo "[STUB_USER_DB]" >> /home/ox_user/.ox_herd_conf && \
echo "$OX_WEB_USER = $OX_PASSWD_HASH" >> /home/ox_user/.ox_herd_conf && \
echo "# Include some profile setting items" >> /home/ox_user/.profile && \
echo "export LC_ALL=C.UTF-8" >> /home/ox_user/.profile && \
echo "export LANG=C.UTF-8" >> /home/ox_user/.profile && \
echo "export PYTHONPATH=/home/ox_user/ox_server/ox_herd:/home/ox_user/ox_server/ox_herd/ox_herd" \
>> /home/ox_user/.profile
# Setup log directory and pull in setup items.
WORKDIR /home/ox_user/ox_server
# Next add the ox_herd directory we are running from
COPY . ox_herd
RUN pip3 install -r ./ox_herd/requirements.txt
RUN mkdir -p /home/ox_user/ox_server/logs
ADD ./scripts/server_start.sh /ox_server/
# In case you are running docker on windows, need to make sure
# you strip the \r out of the start script
RUN sed -i.bak 's/\r$//' /ox_server/server_start.sh
RUN chmod ugo+rx /ox_server/server_start.sh
RUN chown -R ox_user:www-data /home/ox_user
WORKDIR /ox_server
CMD ["bash", "/ox_server/server_start.sh"]