Debian Codegraph @

automation/build/yocto/yocto.dockerfile.in

raw
1 # syntax=docker/dockerfile:1
2
3 # Docker file to create an environment to build yocto with virtualization
4 #
5 # Arguments that can be passed during image creation using --build-arg:
6 # "host_uid=$(id -u)": to use current user uid for build user in the image
7 # "host_gid=$(id -g)": to use current user gid for build user in the image
8 # "ubuntu_version=VERS": to select the ubuntu version number
9
10 # Use standard ubuntu minimal.
11 ARG ubuntu_version=22.04
12 From ##DOCKERPLAT##ubuntu:$ubuntu_version AS base
13 LABEL maintainer.name="The Xen Project " \
14 maintainer.email="[email protected]"
15
16 ENV DEBIAN_FRONTEND=noninteractive
17
18 # Install minimal ubuntu requirements for yocto and other tools we need.
19 # See https://docs.yoctoproject.org/4.0.1/brief-yoctoprojectqs/index.html#build-host-packages
20 RUN apt-get update && \
21 apt-get --quiet --yes install \
22 gawk \
23 wget \
24 git \
25 diffstat \
26 unzip \
27 texinfo \
28 gcc \
29 build-essential \
30 chrpath \
31 socat \
32 cpio \
33 python3 \
34 python3-pip \
35 python3-pexpect \
36 xz-utils \
37 debianutils \
38 iputils-ping \
39 python3-git \
40 python3-jinja2 \
41 libegl1-mesa \
42 libsdl1.2-dev \
43 python3-subunit \
44 mesa-common-dev \
45 zstd \
46 liblz4-tool \
47 file \
48 vim \
49 bison \
50 expect \
51 locales \
52 liblz4-tool \
53 zstd \
54 openssl \
55 libssl3 \
56 ca-certificates \
57 && \
58 apt-get autoremove -y && \
59 apt-get clean && \
60 rm -rf /var/lib/apt/lists* /tmp/* /var/tmp/*
61
62 # Use bash as shell.
63 RUN rm /bin/sh && ln -s bash /bin/sh
64
65 # Fix local for yocto.
66 RUN locale-gen en_US.UTF-8 && update-locale LC_ALL=en_US.UTF-8 \
67 LANG=en_US.UTF-8
68 ENV LANG en_US.UTF-8
69 ENV LC_ALL en_US.UTF-8
70
71 # Create a user for the build (we don't want to build as root).
72 ENV USER_NAME docker-build
73 ARG host_uid=1000
74 ARG host_gid=1000
75 RUN groupadd -g $host_gid $USER_NAME && \
76 useradd -g $host_gid -m -s /bin/bash -u $host_uid $USER_NAME
77
78 # Switch to our user instead of root and start in its home.
79 USER $USER_NAME
80 WORKDIR /home/$USER_NAME
81
82 # Create needed directories
83 RUN mkdir -p /home/$USER_NAME/yocto-layers \
84 /home/$USER_NAME/yocto-cache \
85 /home/$USER_NAME/logs \
86 /home/$USER_NAME/bin \
87 /home/$USER_NAME/xen && \
88 chown $USER_NAME.$USER_NAME /home/$USER_NAME/*
89
90 # clone yocto repositories we need.
91 RUN for rep in \
92 https://github.com/openembedded/meta-openembedded \
93 https://git.yoctoproject.org/poky \
94 https://git.yoctoproject.org/meta-virtualization \
95 ; do \
96 git -C /home/$USER_NAME/yocto-layers \
97 clone -b ##YOCTOVERSION## --single-branch $rep; \
98 done
99
100 # The builder stage is building an initial cache state that we include in the
101 # final image.
102 From base AS builder
103
104 # This step can take one to several hours depending on your download bandwith
105 # and the speed of your computer.
106 COPY ./build-yocto.sh /
107 RUN /build-yocto.sh --dump-log ##YOCTOTARGET##
108
109 From base
110
111 # Only copy the cache status.
112 COPY --from=builder /home/$USER_NAME/yocto-cache /home/$USER_NAME/yocto-cache/.
113
114 LABEL maintainer.name="The Xen Project " \
115 maintainer.email="[email protected]"
116