forked from hypothesis/h
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
72 lines (55 loc) · 1.87 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
FROM node:alpine as build
ENV NODE_ENV production
COPY . .
RUN npm install --production && npm run build
FROM alpine:3.7
MAINTAINER Hypothes.is Project and contributors
# Install system build and runtime dependencies.
RUN apk add --no-cache \
ca-certificates \
collectd \
collectd-disk \
collectd-nginx \
libffi \
libpq \
nginx \
python2 \
py2-pip \
git
# Create the hypothesis user, group, home directory and package directory.
RUN addgroup -S hypothesis && adduser -S -G hypothesis -h /var/lib/hypothesis hypothesis
WORKDIR /var/lib/hypothesis
# Ensure nginx state and log directories writeable by unprivileged user.
RUN chown -R hypothesis:hypothesis /var/log/nginx /var/lib/nginx /var/tmp/nginx
# Copy minimal data to allow installation of dependencies.
COPY requirements.txt ./
# Install build deps, build, and then clean up.
RUN apk add --no-cache --virtual build-deps \
build-base \
libffi-dev \
postgresql-dev \
python-dev \
&& pip install --no-cache-dir -U pip supervisor \
&& pip install --no-cache-dir -r requirements.txt \
&& apk del build-deps
# Copy nginx config
COPY conf/nginx.conf /etc/nginx/nginx.conf
# Copy collectd config
COPY conf/collectd.conf /etc/collectd/collectd.conf
RUN mkdir /etc/collectd/collectd.conf.d \
&& chown hypothesis:hypothesis /etc/collectd/collectd.conf.d
# Copy the rest of the application files.
COPY . .
# If we're building from a git clone, ensure that .git is writeable
RUN [ -d .git ] && chown -R hypothesis:hypothesis .git || :
# Copy frontend assets.
COPY --from=build /build build
# Expose the default port.
EXPOSE 5000
# Set the application environment
ENV PATH /var/lib/hypothesis/bin:$PATH
ENV PYTHONIOENCODING utf_8
ENV PYTHONPATH /var/lib/hypothesis:$PYTHONPATH
# Start the web server by default
USER hypothesis
CMD ["init-env", "supervisord", "-c" , "conf/supervisord.conf"]