-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile
174 lines (143 loc) · 4.67 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# syntax=docker/dockerfile:1
ARG DOCKER_IMAGE_VERSION=26.0.0
ARG DOCKER_COMPOSE_VERSION=v2.25.0
ARG PROCPS_VERSION=v3.3.17
ARG NSENTER_VERSION=v2.40
ARG SLIRP4NETNS_VERSION=1.2.3
ARG REPO=axisecp
ARG ARCH=armv7hf
ARG VERSION=1.14
ARG UBUNTU_VERSION=22.04
ARG NATIVE_SDK=acap-native-sdk
FROM ${REPO}/${NATIVE_SDK}:${VERSION}-${ARCH}-ubuntu${UBUNTU_VERSION} AS sdk_image
FROM sdk_image AS build_image
# hadolint ignore=DL3009
RUN <<EOF
apt-get update
apt-get -q install -y -f --no-install-recommends \
automake \
autopoint \
gettext \
git \
libtool \
bison \
flex
ln -s /usr/bin/libtoolize /usr/bin/libtool
EOF
FROM build_image AS ps
ARG PROCPS_VERSION
ARG BUILD_DIR=/build
ARG EXPORT_DIR=/export
WORKDIR $BUILD_DIR
RUN git clone --depth 1 -b $PROCPS_VERSION 'https://gitlab.com/procps-ng/procps' .
ARG BUILD_CACHE=build.cache
RUN <<EOF
echo ac_cv_func_realloc_0_nonnull=yes >$BUILD_CACHE
echo ac_cv_func_malloc_0_nonnull=yes >>$BUILD_CACHE
EOF
RUN <<EOF
. /opt/axis/acapsdk/environment-setup*
./autogen.sh
./configure --host="${TARGET_PREFIX%*-}" \
--disable-shared \
--without-ncurses \
--cache-file="$BUILD_CACHE"
make ps/pscommand
$STRIP ps/pscommand
EOF
WORKDIR $EXPORT_DIR
RUN cp $BUILD_DIR/ps/pscommand ps
FROM build_image AS nsenter
ARG NSENTER_VERSION
ARG BUILD_DIR=/build
ARG EXPORT_DIR=/export
WORKDIR $BUILD_DIR
RUN git clone -b $NSENTER_VERSION 'https://github.com/util-linux/util-linux.git'
ARG BUILD_CACHE=build.cache
RUN <<EOF
echo ac_cv_func_realloc_0_nonnull=yes >$BUILD_CACHE
echo ac_cv_func_malloc_0_nonnull=yes >>$BUILD_CACHE
EOF
RUN <<EOF
cd util-linux
. /opt/axis/acapsdk/environment-setup*
./autogen.sh
./configure --host="${TARGET_PREFIX%*-}" \
--disable-shared \
--without-ncurses \
--cache-file="$BUILD_CACHE"
make nsenter
$STRIP nsenter
EOF
WORKDIR $EXPORT_DIR
RUN cp $BUILD_DIR/util-linux/nsenter nsenter
FROM sdk_image AS docker_binaries
WORKDIR /download
ARG ARCH
ARG DOCKER_IMAGE_VERSION
ARG DOCKER_COMPOSE_VERSION
ARG SLIRP4NETNS_VERSION
ARG ROOTLESS_EXTRAS_VERSION=${DOCKER_IMAGE_VERSION}
# Download and extract slirp4netns
RUN <<EOF
if [ "$ARCH" = "armv7hf" ]; then
export SLIRP4NETNS_ARCH="armv7l";
elif [ "$ARCH" = "aarch64" ]; then
export SLIRP4NETNS_ARCH="aarch64";
fi;
curl -Lo slirp4netns \
"https://github.com/rootless-containers/slirp4netns/releases/download/v${SLIRP4NETNS_VERSION}/slirp4netns-${SLIRP4NETNS_ARCH}";
chmod +x slirp4netns
EOF
# Download and extract docker scripts and docker-rootless-extras scripts
RUN <<EOF
if [ "$ARCH" = "armv7hf" ]; then
export DOCKER_ARCH="armhf";
export DOCKER_COMPOSE_ARCH="armv7";
elif [ "$ARCH" = "aarch64" ]; then
export DOCKER_ARCH="aarch64";
export DOCKER_COMPOSE_ARCH="aarch64";
fi;
curl -Lo docker_binaries.tgz "https://download.docker.com/linux/static/stable/${DOCKER_ARCH}/docker-${DOCKER_IMAGE_VERSION}.tgz" ;
tar -xz -f docker_binaries.tgz --strip-components=1 docker/docker ;
tar -xz -f docker_binaries.tgz --strip-components=1 docker/dockerd ;
tar -xz -f docker_binaries.tgz --strip-components=1 docker/docker-init ;
tar -xz -f docker_binaries.tgz --strip-components=1 docker/docker-proxy ;
curl -Lo docker-compose "https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-linux-${DOCKER_COMPOSE_ARCH}" ;
chmod +x docker-compose
curl -Lo docker-rootless-extras.tgz "https://download.docker.com/linux/static/stable/${DOCKER_ARCH}/docker-rootless-extras-${ROOTLESS_EXTRAS_VERSION}.tgz" ;
tar -xz -f docker-rootless-extras.tgz --strip-components=1 ;
EOF
FROM sdk_image AS build
WORKDIR /opt/app
COPY app .
COPY --from=ps /export/ps .
COPY --from=nsenter /export/nsenter .
COPY --from=docker_binaries \
/download/dockerd \
/download/docker-init \
/download/docker-proxy \
/download/docker \
/download/docker-compose \
/download/rootlesskit \
/download/rootlesskit-docker-proxy \
/download/slirp4netns ./
ARG BUILD_WITH_SANITIZERS
RUN <<EOF
. /opt/axis/acapsdk/environment-setup*
BUILD_WITH_SANITIZERS="$BUILD_WITH_SANITIZERS" \
acap-build . \
-a docker \
-a dockerd \
-a docker-compose \
-a docker-init \
-a docker-proxy \
-a ps \
-a slirp4netns \
-a rootlesskit \
-a rootlesskit-docker-proxy \
-a nsenter
EOF
ENTRYPOINT [ "/opt/axis/acapsdk/sysroots/x86_64-pokysdk-linux/usr/bin/eap-install.sh" ]
FROM scratch AS binaries
COPY --from=build /opt/app/*.eap /