2ff94a9f2f9a4c33ff5a179cb8d60271fbca09eb
[ta/caas-registry.git] / docker-build / swift / Dockerfile
1 # Copyright 2019 Nokia
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 FROM centos:7.6.1810
16 MAINTAINER Balint Varga <balint.varga@nokia.com>
17
18 ARG SWIFT
19 ENV SWIFT_VERSION=$SWIFT
20 ENV GOPATH /build
21 ENV PATH /usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
22
23 COPY get-package build-pip common_scripts/wait-for-files /usr/bin/
24 COPY nginx.repo /etc/yum.repos.d/
25
26 RUN yum remove -y subscription-manager \
27     && yum -y install \
28       tar \
29       bzip2 \
30       python27-python-pip \
31     && yum clean all \
32     && mkdir -p ${GOPATH} \
33     && chmod 755 /usr/bin/build-pip /usr/bin/get-package /usr/bin/wait-for-files \
34     && echo "console" > /etc/securetty \
35     && chmod 400 /etc/shadow \
36     && chmod 700 /root
37
38 COPY supervisord.conf /etc/supervisord.conf
39 COPY mainstart.sh /usr/bin/mainstart.sh
40 COPY healthchecker.sh /usr/bin/healthchecker.sh
41 COPY source-list.txt ${GOPATH}/
42
43 RUN useradd -u 146 -s /sbin/nologin swift \
44 &&  mkdir -p /var/run/rsyncd \
45 &&  chown -R swift:swift /var/run/rsyncd \
46 &&  mkdir -p /var/lock/swift_locks \
47 &&  chown -R swift:swift /var/lock/swift_locks \
48 &&  mkdir -p /var/log/swift \
49 &&  chown -R swift:swift /var/log/swift \
50 &&  chmod 644 ${GOPATH}/source-list.txt \
51 &&  yum install -y --setopt=skip_missing_names_on_install=False \
52       gcc \
53       make \
54       autoconf \
55       memcached \
56       rsync \
57       automake \
58       libtool \
59       libffi \
60       libffi-devel \
61       python-devel \
62       openssl-devel \
63       libxml2-devel \
64       libxslt-devel \
65       nginx \
66
67 # prepare nginx service
68 &&  touch /run/nginx.pid \
69 &&  chown -R swift:swift /var/lib/nginx /var/log/nginx /run/nginx.pid \
70
71 # liberasurecode
72 &&  mkdir ${GOPATH}/liberasurecode \
73 &&  cd ${GOPATH}/liberasurecode \
74 &&  get-package liberasurecode \
75 &&  ./autogen.sh \
76 &&  ./configure \
77 &&  make -j$(nproc) \
78 &&  make install \
79
80 # gf-complete
81 &&  mkdir ${GOPATH}/gf-complete \
82 &&  cd ${GOPATH}/gf-complete \
83 &&  get-package gf-complete \
84 &&  autoreconf --force --install \
85 &&  ./configure \
86 &&  make -j$(nproc) \
87 &&  make install \
88
89 # jerasure
90 &&  mkdir ${GOPATH}/Jerasure \
91 &&  cd ${GOPATH}/Jerasure \
92 &&  get-package Jerasure \
93 &&  autoreconf --force --install \
94 &&  ./configure LDFLAGS=-L${GOPATH}/other/gf-complete/src/.libs/ CPPFLAGS=-I${GOPATH}/other/gf-complete/include ax_cv_gcc_x86_cpuid_0x00000001=0 \
95 &&  make -j$(nproc) \
96 &&  make install \
97
98 # nasm
99 &&  mkdir ${GOPATH}/nasm \
100 &&  cd ${GOPATH}/nasm \
101 &&  get-package nasm \
102 &&  ./configure \
103 &&  make -j$(nproc) \
104 &&  make install \
105
106 # isa-l
107 &&  mkdir ${GOPATH}/isa-l \
108 &&  cd ${GOPATH}/isa-l \
109 &&  get-package isa-l \
110 &&  ./autogen.sh \
111 &&  ./configure \
112 &&  make -j$(nproc) \
113 &&  make install \
114
115 # setuptools
116 &&  mkdir ${GOPATH}/setuptools \
117 &&  get-package python-setuptools \
118 &&  python bootstrap.py \
119 &&  python setup.py install \
120 &&  cd ${GOPATH} \
121
122 # workaround, because the new chardet python package can't override the old one correctly
123 &&  curl -fsSL -k https://bootstrap.pypa.io/get-pip.py -o get-pip.py \
124 &&  python get-pip.py \
125 &&  pip uninstall -y chardet \
126
127 # python dependencies
128 &&  build-pip python-enum-compat python-eventlet python-dnspython python-greenlet python-netifaces python-pastedeploy python-six \
129 python-pycparser python-cffi python-xattr \
130 python-idna python-enum34 python-ipaddress python-cryptography \
131 python-PyECLib python-supervisor python-supervisor-stdout \
132 python-lxml python-chardet python-requests \
133
134 # swift
135 &&  mkdir -p ${GOPATH}/pip \
136 &&  cd ${GOPATH}/pip \
137 &&  curl -fsSL -k https://tarballs.openstack.org/swift/swift-${SWIFT_VERSION}.tar.gz | tar zx --strip-components=1 -C ${GOPATH}/pip/ \
138 &&  python setup.py install \
139 &&  rm -rf ${GOPATH}/pip/* \
140
141 # register the library path
142 &&  echo '/usr/local/lib' > /etc/ld.so.conf \
143 &&  ldconfig \
144
145 # rights
146 &&  chmod +x /usr/bin/mainstart.sh \
147 &&  mkdir -p /var/swift/recon \
148 &&  mkdir -p /var/cache/swift \
149 &&  mkdir /var/run/supervisor \
150 &&  chown -R swift /var/swift/recon \
151 &&  chown -R swift /var/cache/swift \
152 &&  chown -R swift /var/run/supervisor \
153
154 # cleaning
155 &&  yum --setopt=tsflags=noscripts remove -y gcc libffi-devel autoconf automake libtool python-devel openssl-devel \
156 &&  yum clean all \
157 &&  rm -rf /etc/yum.repos.d/luxembourg.repo \
158 &&  rm -rf ${GOPATH} \
159 &&  setcap 'cap_setgid,cap_setuid,cap_net_bind_service=+ep' /usr/bin/rsync
160
161 ENTRYPOINT ["/usr/bin/mainstart.sh"]