-
Notifications
You must be signed in to change notification settings - Fork 6
/
Dockerfile
152 lines (138 loc) · 5.6 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
FROM ubuntu:16.04
EXPOSE \
# OpenStack Dashboard (Horizon)
80 \
# Identity Service (Keystone API)
5000 \
# Compute (EC2 API)
8773 \
# Compute (Nova API)
8774 \
# Compute (Metadata API)
8775 \
# Block Storage (Cinder API)
8776 \
# Image Service (Glance API)
9292
# Suppress unwanted debconf messages and questions during build
ARG DEBIAN_FRONTEND=noninteractive
#####################################################################
# Systemd workaround from solita/ubuntu-systemd and moby/moby#28614 #
#####################################################################
ENV container docker
# No need for graphical.target
RUN systemctl set-default multi-user.target
# Gracefully stop systemd
STOPSIGNAL SIGRTMIN+3
# Cleanup unneeded services
RUN find /etc/systemd/system \
/lib/systemd/system \
-path '*.wants/*' \
-not -name '*journald*' \
-not -name '*systemd-tmpfiles*' \
-not -name '*systemd-user-sessions*' \
-exec rm \{} \;
# Workaround for console output error moby/moby#27202, based on moby/moby#9212
CMD ["/bin/bash", "-c", "exec /sbin/init --log-target=journal 3>&1"]
####################
# DevStack Preload #
####################
# Get Missing External System Dependencies for DevStack Setup
RUN apt-get update && apt-get --assume-yes --no-install-recommends install \
# To Retrieve Fresh DevStack Sources
ca-certificates \
git \
# Host IP Management (ip)
iproute2 \
# Dependency of PyECLib
liberasurecode-dev \
# Dependency of python-nss
libnss3-dev \
# Dependency of systemd-python
libsystemd-dev \
# Enabling KVM Guests
libvirt-dev \
# Distribution Identification
lsb \
# Network Detection (arp)
net-tools \
# Preload Fixes from /devstack/tools/fixup_stuff.sh
python-virtualenv \
software-properties-common \
# Cleanup
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
ARG DEVSTACK_BRANCH="master"
ARG PROJECTS_BRANCH="master"
# This OpenStack project repositories will be downloaded
ARG PROJECTS=" \
keystone \
nova \
neutron \
glance \
horizon \
zun \
zun-ui \
kuryr-libnetwork \
"
# Clone DevStack, Requirements and OpenStack (Core) Projects
# - To properly detect a container environment,
# we need at least openstack-dev/devstack/commit/63666a2
RUN git clone git://git.openstack.org/openstack-dev/devstack --branch $DEVSTACK_BRANCH && \
git clone git://git.openstack.org/openstack/requirements --branch $DEVSTACK_BRANCH /opt/stack/requirements && \
for \
PROJECT in $PROJECTS; \
do \
git clone \
git://git.openstack.org/openstack/$PROJECT.git \
/opt/stack/$PROJECT \
--branch $PROJECTS_BRANCH \
--depth 1 \
--single-branch; \
done
# Pre-Install DevStack System Dependencies to Speedup Docker Run
RUN /devstack/tools/install_prereqs.sh \
# Install Additional Packages MySQL and RabbitMQ
# - TODO: Find all needed packages in $(grep --no-filename NOPRIME /devstack/files/apts/* | sed '/dist/d; s/\s*#.*//;')
# - TODO: If everything is actually in place, we could set OFFLINE=True in local.conf
&& echo 'mysql-server mysql-server/root_password password secret' | debconf-set-selections \
&& echo 'mysql-server mysql-server/root_password_again password secret' | debconf-set-selections \
&& apt-get update && apt-get --assume-yes --no-install-recommends install \
mysql-server \
rabbitmq-server \
&& service mysql start \
# Cleanup
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Install external pip, resolving missing python-setuptools and wheel errors
RUN curl --silent --show-error https://bootstrap.pypa.io/get-pip.py | python
# Solve dependency conflict for urllib3 with pre-installed requests
RUN pip install --upgrade --force-reinstall requests
# Install known working Python packages
RUN pip install \
--no-cache-dir \
--constraint /opt/stack/requirements/upper-constraints.txt \
--requirement /opt/stack/requirements/global-requirements.txt \
--requirement /opt/stack/requirements/test-requirements.txt
# Setup non-Root user "stack", as required by stack.sh
RUN useradd --shell /bin/bash --home-dir /opt/stack/ stack \
&& echo "stack ALL=(ALL) NOPASSWD: ALL" | tee /etc/sudoers.d/stack \
&& sudo chown --recursive stack /devstack/
# Copy DevStack configuration, if file has changed
COPY local.conf /devstack/
# This container starts systemd, so do not add an additional Docker CMD!
# Place any post-start calls in the Makefile.
# Actual DevStack setup has to happen in a running container,
# because of missing privileges during Docker build.
# Thats's right, we add ARGs and dependent labels at the end, because they will change on every build
ARG BUILD_DATE
ARG VCS_REF
ARG VERSION
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name="DockStack" \
org.label-schema.description="Docker on DevStack on Docker" \
org.label-schema.version=$VERSION-$BUILD_DATE-git-$VCS_REF \
org.label-schema.vendor="Jan Mattfeld" \
org.label-schema.vcs-url="https://github.com/janmattfeld/DockStack" \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.docker.cmd="docker run --privileged --detach devstack " \
org.label-schema.docker.params="DEVSTACK_BRANCH, PROJECTS_BRANCH, PROJECTS" \
org.label-schema.schema-version="1.0"