forked from VariantEffect/MaveDB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
123 lines (96 loc) · 3.68 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
FROM python:3.6 AS base
# Argument list for dockerfile script.
ARG DJANGO_REQUIREMENTS=production
RUN echo "Requirements: ${DJANGO_REQUIREMENTS}.txt"
ENV PYTHONUNBUFFERED 1
ENV DJANGO_REQUIREMENTS ${DJANGO_REQUIREMENTS}
###############################################################################
# Base configuration stage
###############################################################################
FROM base as builder
ENV APP_USER=mavedb
# Update the default application repository sources list and install
# required dependencies
RUN useradd -m ${APP_USER}
RUN apt-get update && apt-get -y upgrade
RUN apt-get install -y build-essential
RUN apt-get install -y git wget curl pandoc graphviz
# Local directory with project source
ENV HOST_SRC=.
# Directory in container where web app will live
ENV SRV_DIR=/srv
# Directory for local binaries
ENV LOCAL_BIN=/usr/local/bin/
# Directory in container for Django source files in web app directory
ENV APP_SOURCE=${SRV_DIR}/app
RUN mkdir -p ${APP_SOURCE}
# Directory in container for database mount for backup/restore etc
ENV DATABASE_BACKUP=${HOME}/database
RUN mkdir -p ${DATABASE_BACKUP}
# Directory in container for application and celery logs
ENV APP_LOGS=${APP_SOURCE}/logs
RUN mkdir -p ${APP_SOURCE}
# Directory in container for Django media files
ENV APP_MEDIA=${APP_LOGS}/media
RUN mkdir -p ${APP_MEDIA}
# Directory in container for Django static files
ENV APP_STATIC=${APP_SOURCE}/static
RUN mkdir -p ${APP_STATIC}
# Set up celery logging locations
ENV CELERY_LOG_DIR /var/log/celery
ENV CELERY_PID_DIR /var/run/celery
RUN mkdir -p ${CELERY_LOG_DIR}
RUN mkdir -p ${CELERY_PID_DIR}
# Create application subdirectories
WORKDIR ${APP_SOURCE}
RUN mkdir -p media static logs
RUN mkdir ${HOME}/database
COPY ${HOST_SRC}/requirements/base.txt .
COPY ${HOST_SRC}/requirements/${DJANGO_REQUIREMENTS}.txt .
RUN pip3 install --no-cache-dir wheel
RUN pip3 install --no-cache-dir -r ${DJANGO_REQUIREMENTS}.txt
###############################################################################
# App configuration stage
###############################################################################
FROM builder as app
WORKDIR ${APP_SOURCE}
COPY ${HOST_SRC} .
# Build the Sphinx documentation for MaveDB
WORKDIR ${APP_SOURCE}/docs
RUN make html
# Build the Sphinx documentation for mavehgvs
WORKDIR /tmp
# get the correct mavehgvs version by tag
RUN RAW_MAVE_HGVS_VERSION=`pip3 show mavehgvs | grep Version`; \
MAVE_HGVS_VERSION="v${RAW_MAVE_HGVS_VERSION##* }"; \
git clone --depth 1 --branch ${MAVE_HGVS_VERSION} https://github.com/VariantEffect/mavehgvs.git
WORKDIR /tmp/mavehgvs/docs/
RUN make html
RUN mv _build ${APP_SOURCE}/docs/build/docs/mavehgvs
RUN rm -rf /tmp/mavehgvs
# Build the Sphinx documentation for MaveTools
WORKDIR /tmp
RUN git clone --depth 1 https://github.com/VariantEffect/mavetools.git
WORKDIR /tmp/mavetools/docs/
RUN make html
RUN mv _build ${APP_SOURCE}/docs/build/docs/mavetools
RUN rm -rf /tmp/mavetools
WORKDIR ${APP_SOURCE}
RUN chown -R ${APP_USER}:${APP_USER} ${APP_SOURCE}
RUN chown -R ${APP_USER}:${APP_USER} ${APP_MEDIA}
RUN chown -R ${APP_USER}:${APP_USER} ${APP_STATIC}
RUN chown -R ${APP_USER}:${APP_USER} ${APP_LOGS}
# Create log directories for worker and pid logs
RUN mkdir -p /var/log/celery/
RUN mkdir -p /var/run/celery/
RUN chown -R ${APP_USER}:${APP_USER} /var/log/celery/
RUN chown -R ${APP_USER}:${APP_USER} /var/run/celery/
# Copy entrypoint script into the image
COPY ${HOST_SRC}/docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
# Port to expose for external comms
EXPOSE 8000
# Run entrypoint script in maveric source root
USER ${APP_USER}
WORKDIR ${APP_SOURCE}
ENTRYPOINT ["docker-entrypoint.sh"]