AArch64 support
[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 scratch
16 ADD centos-7-docker.tar.xz /
17 CMD ["/bin/bash"]
18 MAINTAINER Balint Varga <balint.varga@nokia.com>
19
20 ARG SWIFT
21 ENV SWIFT_VERSION=$SWIFT
22 ENV GOPATH /build
23 ENV PATH /usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
24
25 COPY get-package build-pip common_scripts/wait-for-files /usr/bin/
26 COPY nginx.repo /etc/yum.repos.d/
27
28 RUN yum remove -y subscription-manager \
29     && yum -y install \
30       tar \
31       bzip2 \
32       python27-python-pip \
33     && yum clean all \
34     && mkdir -p ${GOPATH} \
35     && chmod 755 /usr/bin/build-pip /usr/bin/get-package /usr/bin/wait-for-files \
36     && echo "console" > /etc/securetty \
37     && chmod 400 /etc/shadow \
38     && chmod 700 /root
39
40 COPY supervisord.conf /etc/supervisord.conf
41 COPY mainstart.sh /usr/bin/mainstart.sh
42 COPY healthchecker.sh /usr/bin/healthchecker.sh
43 COPY source-list.txt ${GOPATH}/
44
45 RUN useradd -u 146 -s /sbin/nologin swift \
46 &&  mkdir -p /var/run/rsyncd \
47 &&  chown -R swift:swift /var/run/rsyncd \
48 &&  mkdir -p /var/lock/swift_locks \
49 &&  chown -R swift:swift /var/lock/swift_locks \
50 &&  mkdir -p /var/log/swift \
51 &&  chown -R swift:swift /var/log/swift \
52 &&  chmod 644 ${GOPATH}/source-list.txt \
53 &&  yum install -y --setopt=skip_missing_names_on_install=False \
54       gcc \
55       make \
56       autoconf \
57       memcached \
58       rsync \
59       automake \
60       libtool \
61       libffi \
62       libffi-devel \
63       python-devel \
64       openssl-devel \
65       libxml2-devel \
66       libxslt-devel \
67       nginx \
68
69 # prepare nginx service
70 &&  touch /run/nginx.pid \
71 &&  chown -R swift:swift /var/lib/nginx /var/log/nginx /run/nginx.pid \
72
73 # liberasurecode
74 &&  mkdir ${GOPATH}/liberasurecode \
75 &&  cd ${GOPATH}/liberasurecode \
76 &&  get-package liberasurecode \
77 &&  ./autogen.sh \
78 &&  ./configure \
79 &&  make -j$(nproc) \
80 &&  make install \
81
82 # gf-complete
83 &&  mkdir ${GOPATH}/gf-complete \
84 &&  cd ${GOPATH}/gf-complete \
85 &&  get-package gf-complete \
86 &&  autoreconf --force --install \
87 &&  ./configure \
88 &&  make -j$(nproc) \
89 &&  make install \
90
91 # jerasure
92 &&  mkdir ${GOPATH}/Jerasure \
93 &&  cd ${GOPATH}/Jerasure \
94 &&  get-package Jerasure \
95 &&  autoreconf --force --install \
96 &&  ./configure LDFLAGS=-L${GOPATH}/other/gf-complete/src/.libs/ CPPFLAGS=-I${GOPATH}/other/gf-complete/include ax_cv_gcc_x86_cpuid_0x00000001=0 \
97 &&  make -j$(nproc) \
98 &&  make install \
99
100 # nasm
101 &&  mkdir ${GOPATH}/nasm \
102 &&  cd ${GOPATH}/nasm \
103 &&  get-package nasm \
104 &&  ./configure \
105 &&  make -j$(nproc) \
106 &&  make install \
107
108 # isa-l
109 &&  mkdir ${GOPATH}/isa-l \
110 &&  cd ${GOPATH}/isa-l \
111 &&  get-package isa-l \
112 &&  ./autogen.sh \
113 &&  ./configure \
114 &&  make -j$(nproc) \
115 &&  make install \
116
117 # setuptools
118 &&  mkdir ${GOPATH}/setuptools \
119 &&  get-package python-setuptools \
120 &&  python bootstrap.py \
121 &&  python setup.py install \
122 &&  cd ${GOPATH} \
123
124 # workaround, because the new chardet python package can't override the old one correctly
125 &&  curl -fsSL -k https://bootstrap.pypa.io/get-pip.py -o get-pip.py \
126 &&  python get-pip.py \
127 &&  pip uninstall -y chardet \
128
129 # python dependencies
130 &&  build-pip python-enum-compat python-eventlet python-dnspython python-greenlet python-netifaces python-pastedeploy python-six \
131 python-pycparser python-cffi python-xattr \
132 python-idna python-enum34 python-ipaddress python-cryptography \
133 python-PyECLib python-supervisor python-supervisor-stdout \
134 python-lxml python-chardet python-requests \
135
136 # swift
137 &&  mkdir -p ${GOPATH}/pip \
138 &&  cd ${GOPATH}/pip \
139 &&  curl -fsSL -k https://tarballs.openstack.org/swift/swift-${SWIFT_VERSION}.tar.gz | tar zx --strip-components=1 -C ${GOPATH}/pip/ \
140 &&  python setup.py install \
141 &&  rm -rf ${GOPATH}/pip/* \
142
143 # register the library path
144 &&  echo '/usr/local/lib' > /etc/ld.so.conf \
145 &&  ldconfig \
146
147 # rights
148 &&  chmod +x /usr/bin/mainstart.sh \
149 &&  mkdir -p /var/swift/recon \
150 &&  mkdir -p /var/cache/swift \
151 &&  mkdir /var/run/supervisor \
152 &&  chown -R swift /var/swift/recon \
153 &&  chown -R swift /var/cache/swift \
154 &&  chown -R swift /var/run/supervisor \
155
156 # cleaning
157 &&  yum --setopt=tsflags=noscripts remove -y gcc libffi-devel autoconf automake libtool python-devel openssl-devel \
158 &&  yum clean all \
159 &&  rm -rf /etc/yum.repos.d/luxembourg.repo \
160 &&  rm -rf ${GOPATH} \
161 &&  setcap 'cap_setgid,cap_setuid,cap_net_bind_service=+ep' /usr/bin/rsync
162
163 ENTRYPOINT ["/usr/bin/mainstart.sh"]