forked from gravitational/teleport
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile-multiarch-base
124 lines (106 loc) · 4.04 KB
/
Dockerfile-multiarch-base
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
# #############################################################################
# This image provides platform setup and GCC required for all platforms.
#
# 64-bit centos7 provides devtools-10 for arm64, devtools-11 for amd64 and
# gcc 4.8 for 32-bit archs. This image builds modern gcc from sources.
# It guarantees that we would use the same GCC version for all builds,
# and we would be able to upgrade GCC to a newer version if required.
# #############################################################################
FROM centos:7 AS base
# Automatically supplied by the Docker buildkit
ARG TARGETARCH
ARG GCC_VERSION=10.4.0
ARG CMAKE3_VERSION=3.12.3
# #############################################################################
# Platform-specific customisation.
# #############################################################################
## ARM 32 #####################################################################
FROM base AS platform-setup-arm
ENV GCC_BUILD_FLAGS="--build arm-unknown-linux-gnueabi --with-float=hard --with-mode=arm"
ENV GOLANG_ARCH=armv6l
ENV RUST_ARCH=armv7-unknown-linux-gnueabihf
RUN echo "armhfp" > /etc/yum/vars/basearch && \
echo "armv7hl" > /etc/yum/vars/arch && \
echo "armv7hl-redhat-linux-gnu" > /etc/rpm/platform
## ARM 64 #####################################################################
FROM base AS platform-setup-arm64
ENV GCC_BUILD_FLAGS="--build aarch64-unknown-linux-gnu"
ENV GOLANG_ARCH=arm64
ENV RUST_ARCH=aarch64-unknown-linux-gnu
# Installing the kerenel packages causes the update to hang on aarch64, so we
# skip upgrading them.
RUN echo "aarch64-redhat-linux-gnu" > /etc/rpm/platform
## 386 ########################################################################
FROM base AS platform-setup-386
ENV GCC_BUILD_FLAGS="--build i386-unknown-linux-gnu"
ENV GOLANG_ARCH=386
ENV RUST_ARCH=i686-unknown-linux-gnu
## AMD 64 #####################################################################
FROM base AS platform-setup-amd64
ENV GCC_BUILD_FLAGS="--build x86_64-unknown-linux-gnu"
ENV GOLANG_ARCH=amd64
ENV RUST_ARCH=x86_64-unknown-linux-gnu
## GCC built from sources #####################################################
FROM platform-setup-$TARGETARCH AS gcc
ENV LANGUAGE=en_US.UTF-8 \
LANG=en_US.UTF-8 \
LC_ALL=en_US.UTF-8 \
LC_CTYPE=en_US.UTF-8
RUN yum update -y && \
yum install -y \
autoconf-archive \
automake \
binutils \
bzip2 \
elfutils-libelf-devel-static \
file \
flex \
gcc \
gcc-c++ \
git \
glibc-devel \
glibc-static \
libstdc++-devel \
libstdc++-static \
libtool \
libudev-devel \
make \
pam-devel \
perl-IPC-Cmd \
texinfo \
wget \
which \
zip \
zlib-devel \
zlib-static && \
yum clean all && \
localedef -c -i en_US -f UTF-8 en_US.UTF-8
#tree \
# \
# Compile & install GCC
RUN wget https://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.gz && \
tar -zxvf gcc-${GCC_VERSION}.tar.gz && \
cd gcc-${GCC_VERSION} && \
./contrib/download_prerequisites && \
./configure --disable-checking --enable-languages=c,c++ --disable-multilib ${GCC_BUILD_FLAGS} || : && \
cat config.log && \
make -j$(nproc) && \
make install && \
cd .. && \
rm -rf gcc-${GCC_VERSION}.tar.gz gcc-${GCC_VERSION}
# Use the new compiler
ENV LD_LIBRARY_PATH=/usr/local/lib64:/usr/local/lib32:/usr/local/lib:$LD_LIBRARY_PATH
ENV CC=/usr/local/bin/gcc
ENV CXX=/usr/local/bin/g++
ENV PATH=/usr/local/bin:$PATH
# Install CMake3. CMake3 is required for most dependencies.
RUN wget https://cmake.org/files/v3.12/cmake-${CMAKE3_VERSION}.tar.gz && \
tar xzvf cmake-${CMAKE3_VERSION}.tar.gz && \
cd cmake-${CMAKE3_VERSION} && \
./bootstrap --prefix=/usr/local && \
make -j$(nproc) && \
make install && \
cd .. && \
rm -rf cmake-${CMAKE3_VERSION}.tar.gz cmake-${CMAKE3_VERSION}
# Provide cmake3 alias executable
RUN ln -s /usr/local/bin/cmake /usr/bin/cmake3