-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
75 lines (62 loc) · 2.33 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
FROM ubuntu:20.04
#
# Dockerfile for the 4DGB Browser Runner
#
# This Dockerfile installs all the necessary Python3 and Javascript
# dependencies for the 4DGB Browser.
# When run, a container will import a project from whatever is mounted
# at the '/project' directory, build a release from it, then start up
# a server via gunicorn for it.
#
# Install dependencies
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
python3 python3 python3-pip rsync cpanminus gosu \
ca-certificates build-essential curl nginx jq
RUN ln -s /usr/bin/python3 /usr/bin/python
# Install scroller (for pretty output!)
RUN cpanm Term::Scroller
# Setup NodeJS PPA
RUN curl -fsSL 'https://deb.nodesource.com/setup_16.x' > setup_16.x
RUN bash setup_16.x
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y nodejs
#Setup Directories/Permissions
# We need to set permissions on a few things so nginx can
# read them when running as www-data (instead of root)
RUN mkdir -p /var/lib/nginx /var/log/nginx \
&& touch /run/nginx.pid \
&& chown -R www-data:www-data /var/lib/nginx /run/nginx.pid /var/log/nginx \
# If the container is using a tty, then we'll need to be in the tty group
# in order to write to stdout
&& usermod -aG tty www-data
WORKDIR /srv
# Javascript Stuff
COPY package.json ./
COPY client-js ./client-js
RUN npm install \
&& npx webpack --config client-js/webpack.config.js
# Python Stuff
COPY server/requirements.txt ./server/requirements.txt
RUN pip3 install -r ./server/requirements.txt \
&& pip3 install gunicorn pandas
# Persistent volume to store the project release directory
VOLUME /srv/release
# Server Configuration
COPY bin/db_pop ./
COPY bin/docker-entrypoint ./entrypoint
COPY bin/docker-setup ./setup
COPY server/ ./server
RUN chmod +x ./entrypoint ./setup
#Determine if this is going to be a production, or a local setup
ARG MODE=local
ENV MODE ${MODE}
RUN if [ "${MODE}" != "production" ] && [ "${MODE}" != "local" ] ; then \
echo "MODE must be either 'production' or 'local'" \
&& exit 1 \
; fi
# If in production mode, symlink nginx's access log to stdout
RUN if [ "${MODE}" = "production" ] ; then \
ln -sf /dev/stdout /var/log/nginx/access.log \
; fi
RUN cp ./server/nginx-${MODE}.conf /etc/nginx/nginx.conf
ENV BROWSERCONTAINER "yes"
ENTRYPOINT [ "./entrypoint" ]