Debian Codegraph @

Dockerfile

raw
1 #
2 # kas - setup tool for bitbake based projects
3 #
4 # Copyright (c) Siemens AG, 2017-2025
5 #
6 # Permission is hereby granted, free of charge, to any person obtaining a copy
7 # of this software and associated documentation files (the "Software"), to deal
8 # in the Software without restriction, including without limitation the rights
9 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 # copies of the Software, and to permit persons to whom the Software is
11 # furnished to do so, subject to the following conditions:
12 #
13 # The above copyright notice and this permission notice shall be
14 # included in all copies or substantial portions of the Software.
15 #
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 # SOFTWARE.
23
24 ARG DEBIAN_TAG=trixie-slim
25
26 FROM debian:${DEBIAN_TAG} AS kas-base
27
28 ARG SOURCE_DATE_EPOCH
29 ARG CACHE_SHARING=locked
30
31 ARG DEBIAN_TAG=trixie-slim
32 ENV DEBIAN_BASE_IMAGE_TAG=${DEBIAN_TAG}
33
34 ARG TARGETPLATFORM
35 ARG DEBIAN_FRONTEND=noninteractive
36 ENV LANG=en_US.utf8
37 RUN --mount=type=cache,target=/var/cache/apt,sharing=${CACHE_SHARING} \
38 --mount=type=cache,target=/var/lib/apt,sharing=${CACHE_SHARING} \
39 rm -f /etc/apt/apt.conf.d/docker-clean && \
40 echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-packages.conf && \
41 if echo "${DEBIAN_TAG}" | grep -q "[0-9]"; then \
42 cp /etc/apt/sources.list.d/debian.sources /etc/apt/sources.list.d/debian.sources~; \
43 sed -i -e 's|^URIs:|#|' -e 's|^# http://snapshot\.|URIs: http://snapshot.|' \
44 /etc/apt/sources.list.d/debian.sources; \
45 echo 'Acquire::Check-Valid-Until "false";' > /etc/apt/apt.conf.d/use-snapshot.conf; \
46 echo 'Acquire::Retries "10";' >> /etc/apt/apt.conf.d/use-snapshot.conf; \
47 echo 'Acquire::Retries::Delay::Maximum "600";' >> /etc/apt/apt.conf.d/use-snapshot.conf; \
48 fi && \
49 apt-get update && \
50 apt-get install -y locales && \
51 localedef -i en_US -c -f UTF-8 en_US.UTF-8 && \
52 apt-get install --no-install-recommends -y \
53 python3-pip python3-setuptools python3-wheel python3-yaml python3-distro python3-jsonschema \
54 python3-newt python3-colorlog python3-kconfiglib python3-websockets \
55 gosu lsb-release file vim less procps tree tar bzip2 zstd pigz lz4 unzip tmux libncurses-dev \
56 git-lfs mercurial iproute2 ssh-client telnet curl rsync gnupg awscli sudo \
57 socat bash-completion python3-shtab python3-git python3-gnupg python3-cairo && \
58 rm -rf /var/log/* /tmp/* /var/tmp/* /var/cache/ldconfig/aux-cache && \
59 rm -f /etc/gitconfig && \
60 git config --system filter.lfs.clean 'git-lfs clean -- %f' && \
61 git config --system filter.lfs.smudge 'git-lfs smudge -- %f' && \
62 git config --system filter.lfs.process 'git-lfs filter-process' && \
63 git config --system filter.lfs.required true
64
65 RUN --mount=type=bind,target=/kas,rw \
66 pip3 --proxy=$https_proxy install \
67 --no-deps \
68 --no-build-isolation \
69 --break-system-packages \
70 /kas && \
71 install -d /usr/local/share/bash-completion/completions/ && \
72 shtab --shell=bash -u kas.kas.kas_get_argparser --error-unimportable --prog kas \
73 > /usr/local/share/bash-completion/completions/kas && \
74 rm -rf $(pip3 cache dir) && \
75 rm -f /usr/local/bin/kas-container && \
76 install -m 0755 /kas/contrib/oe-git-proxy /usr/bin/ && \
77 install -m 0755 /kas/container-entrypoint / && \
78 kas --version
79
80 ENV GIT_PROXY_COMMAND="oe-git-proxy" \
81 NO_PROXY="*"
82
83 RUN echo "builder ALL=NOPASSWD: ALL" > /etc/sudoers.d/builder-nopasswd && \
84 chmod 660 /etc/sudoers.d/builder-nopasswd && \
85 echo "Defaults env_keep += \"ftp_proxy http_proxy https_proxy no_proxy\"" \
86 > /etc/sudoers.d/env_keep && chmod 660 /etc/sudoers.d/env_keep && \
87 groupadd builder -g 30000 && \
88 useradd builder -u 30000 -g 30000 --create-home --home-dir /builder
89
90 ENTRYPOINT ["/container-entrypoint"]
91
92 #
93 # kas-isar image
94 #
95
96 FROM kas-base AS kas-isar
97
98 ARG SOURCE_DATE_EPOCH
99 ARG CACHE_SHARING=locked
100
101 # The install package list are actually taking 1:1 from their documentation,
102 # so there some packages that can already installed by other downstream layers.
103 # This will not change any image sizes on all the layers in use.
104 ENV LC_ALL=en_US.UTF-8
105 RUN --mount=type=cache,target=/var/cache/apt,sharing=${CACHE_SHARING} \
106 --mount=type=cache,target=/var/lib/apt,sharing=${CACHE_SHARING} \
107 apt-get update && \
108 apt-get install -y -f --no-install-recommends \
109 bzip2 mmdebstrap arch-test apt-utils dosfstools \
110 dpkg-dev gettext-base git mtools parted python3 \
111 quilt qemu-user-static reprepro sudo unzip git-buildpackage \
112 pristine-tar '(^sbuild-schroot$|^sbuild$)' schroot zstd \
113 umoci skopeo \
114 python3-botocore \
115 bubblewrap \
116 debootstrap \
117 uidmap acl && \
118 rm -f /etc/apt/apt.conf.d/use-snapshot.conf /etc/apt/apt.conf.d/keep-packages.conf && \
119 if [ -f "/etc/apt/sources.list.d/debian.sources~" ]; then \
120 mv -f /etc/apt/sources.list.d/debian.sources~ /etc/apt/sources.list.d/debian.sources; \
121 fi && \
122 rm -rf /var/log/* /tmp/* /var/tmp/* /var/cache/ldconfig/aux-cache && \
123 sbuild-adduser builder && \
124 sed -i 's|# kas-isar: ||g' /container-entrypoint
125
126 USER builder
127
128 #
129 # kas image
130 #
131
132 FROM kas-base AS kas
133
134 ARG SOURCE_DATE_EPOCH
135 ARG CACHE_SHARING=locked
136
137 # The install package list are actually taking 1:1 from their documentation
138 # (exception: pylint3 -> pylint), so there some packages that can already
139 # installed by other downstream layers. This will not change any image sizes
140 # on all the layers in use.
141 RUN --mount=type=cache,target=/var/cache/apt,sharing=${CACHE_SHARING} \
142 --mount=type=cache,target=/var/lib/apt,sharing=${CACHE_SHARING} \
143 apt-get update && \
144 apt-get install --no-install-recommends -y \
145 gawk wget git diffstat unzip texinfo \
146 gcc build-essential chrpath socat cpio python3 python3-pip python3-pexpect \
147 xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1 libsdl1.2-dev \
148 pylint xterm python3-subunit mesa-common-dev zstd lz4 && \
149 if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
150 apt-get install --no-install-recommends -y gcc-multilib g++-multilib; \
151 fi && \
152 rm -f /etc/apt/apt.conf.d/use-snapshot.conf /etc/apt/apt.conf.d/keep-packages.conf && \
153 if [ -f "/etc/apt/sources.list.d/debian.sources~" ]; then \
154 mv -f /etc/apt/sources.list.d/debian.sources~ /etc/apt/sources.list.d/debian.sources; \
155 fi && \
156 rm -rf /var/log/* /tmp/* /var/tmp/* /var/cache/ldconfig/aux-cache
157
158 USER builder