-
Notifications
You must be signed in to change notification settings - Fork 100
Expand file tree
/
Copy pathDockerfile
More file actions
102 lines (85 loc) · 2.87 KB
/
Dockerfile
File metadata and controls
102 lines (85 loc) · 2.87 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
ARG PY_VERSION=3.10
# Base image used for all stages
FROM python:${PY_VERSION} as base
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update -y \
&& apt-get install -yq \
inotify-tools \
iputils-ping \
lsb-release \
net-tools \
postgresql \
sendmail \
snmp \
tree \
vim \
&& apt-get clean \
&& rm -rf /var/cache/apt/archives/* /var/lib/apt/lists/*
# stage for python dependencies
FROM base as python_dependencies
ARG PYTHONUNBUFFERED=1
ARG PIP_NO_CACHE_DIR=off
ARG PIP_NO_WARN_SCRIPT_LOCATION=0
ARG PIP_DISABLE_ROOT_WARNING=ignore
ARG PIP_DISABLE_PIP_VERSION_CHECK=1
COPY python_dependencies/requirements.txt /tmp/requirements.txt
RUN pip install --upgrade -r /tmp/requirements.txt
# stage for yangsuite setup
FROM python_dependencies as app_setup
EXPOSE 8480 57500 57501
ARG YS_ADMIN_USER=developer
ARG YS_ADMIN_PASS=developer
ARG YS_ADMIN_EMAIL=developer@example.com
ENV DOCKER_RUN=true \
MEDIA_ROOT=/ys-data/ \
STATIC_ROOT=/ys-static/ \
ALLOWED_HOSTS='*' \
YS_ADMIN_USER=${YS_ADMIN_USER} \
YS_ADMIN_PASS=${YS_ADMIN_PASS} \
YS_ADMIN_EMAIL=${YS_ADMIN_EMAIL} \
DJANGO_SETTINGS_MODULE=yangsuite.settings.production
ENV DJANGO_STATIC_ROOT=${STATIC_ROOT} \
DJANGO_ALLOWED_HOSTS=${ALLOWED_HOSTS}
COPY build-assets/ /build-assets
RUN groupadd --gid 1000 developer \
&& useradd \
--create-home \
--home-dir /home/developer \
--no-user-group \
--no-log-init \
--groups developer \
--shell /bin/bash developer \
&& echo 'alias ll="ls -al"' >> /root/.bashrc \
&& echo 'alias ll="ls -al"' >> /home/developer/.bashrc \
&& mkdir -p ${MEDIA_ROOT} \
&& mkdir -p ${STATIC_ROOT} \
&& mkdir -p /certificate \
&& chmod u+s /bin/ping \
&& chmod +x /build-assets/start_daphne.sh \
&& chmod +x /build-assets/monitor_logs.sh \
&& chmod +x /build-assets/pick_certificate.sh \
&& chmod +x /build-assets/start_environment.sh \
&& chmod +x /build-assets/migrate_and_start.sh \
&& chmod +x /build-assets/validate_certificate.sh \
&& chmod +x /build-assets/create_self_signed_cert.sh \
&& ./build-assets/create_self_signed_cert.sh \
&& ln -snf /usr/share/zoneinfo/${CONTAINER_TIMEZONE} /etc/localtime \
&& echo ${CONTAINER_TIMEZONE} > /etc/timezone \
&& YS_DIR=$(pip show yangsuite | grep "^Location"|cut -d" " -f 2)/ \
&& yangsuite \
--save-settings \
--configure-only \
--data-path ${MEDIA_ROOT} \
--static-root ${STATIC_ROOT} \
--allowed-hosts ${ALLOWED_HOSTS} \
--settings yangsuite.settings.production \
&& chown -R developer:developer \
${YS_DIR} \
/var/run/ \
/var/log/ \
/certificate \
${MEDIA_ROOT} \
${STATIC_ROOT} \
/build-assets/
ENTRYPOINT ["/build-assets/start_environment.sh"]
CMD tail -f /dev/null