Debian Codegraph @

automation/build/README.md

raw symbols SCIP
1 Docker Containers
2 =================
3
4 These Docker containers should make it possible to build Xen in
5 any of the available environments on any system that supports
6 running Docker. They are organized by distro and tagged with
7 the version of that distro. They are available from the GitLab
8 Container Registry under the Xen project at the [registry] and
9 can be pulled with Docker from the following path:
10
11 ```
12 docker pull registry.gitlab.com/xen-project/xen/DISTRO:VERSION
13 ```
14
15 To see the list of available containers run `make` in this
16 directory. You will have to replace the `/` with a `:` to use
17 them.
18
19 Building Xen
20 ------------
21
22 From the top level of the source tree it should be possible to
23 run the following:
24
25 ```
26 ./automation/scripts/containerize make
27 ```
28
29 Which will cause the top level `make` to execute within the default
30 container, which is currently defined as Debian Stretch. Any arguments
31 specified to the script will be executed within the container from
32 the default shell.
33
34 There are several environment variables which the containerize script
35 understands.
36
37 - DOCKED_CMD: Whether to use docker or podman for running the containers.
38 podman can be used as a regular user (rootless podman), but for that
39 to work, /etc/subuid and /etc/subgid needs to containe the proper
40 entries, for such user.
41 docker is the default, for running with podman, do:
42
43 ```
44 DOCKER_CMD=podman ./automation/scripts/containerize make
45 ```
46
47 - CONTAINER: This overrides the container to use. For CentOS 7, use:
48
49 ```
50 CONTAINER=centos7 ./automation/scripts/containerize make
51 ```
52
53 - CONTAINER_PATH: This overrides the path that will be available under the
54 `/build` directory in the container, which is the default path.
55
56 ```
57 CONTAINER_PATH=/some/other/path ./automation/scripts/containerize ls
58 ```
59
60 - CONTAINER_ARGS: Allows you to pass extra arguments to Docker
61 when starting the container.
62
63 - CONTAINER_UID0: This specifies whether root is used inside the container.
64
65 - CONTAINER_NO_PULL: If set to 1, the script will not pull from docker hub.
66 This is useful when testing container locally.
67
68 If your docker host has Linux kernel > 4.11, and you want to use containers
69 that run old glibc (for example, CentOS 6 or SLES11SP4), you may need to add
70
71 ```
72 vsyscall=emulate
73 ```
74
75 to the host kernel command line. That enables a legacy interface that is used
76 by old glibc.
77
78
79 Building a container
80 --------------------
81
82 There is a makefile to make this process easier. You should be
83 able to run `make DISTRO/VERSION` to have Docker build the container
84 for you.
85
86 Xen's dockerfiles use heredocs, which depend on the standardised dockerfile
87 syntax introduced by [BuiltKit]. This should work by default starting with
88 docker 23.0, or podman/buildah v1.33. For older versions of docker, it can be
89 activated with `DOCKER_BUILDKIT=1` in the environment.
90
91 If you define the `PUSH` environment variable when running the
92 former `make` command, it will push the container to the [registry] if
93 you have access to do so and have your Docker logged into the registry.
94
95 To login you must run `docker login registry.gitlab.com`. For more
96 information see the [registry help].
97
98 This example shows how to refresh a container for a rolling release
99 such as openSUSE Tumbleweed. Login with the gitlab.com credentials.
100
101 ```
102 docker login registry.gitlab.com/xen-project/xen
103 make -C automation/build opensuse/tumbleweed-x86_64
104 env CONTAINER_NO_PULL=1 \
105 CONTAINER=tumbleweed \
106 CONTAINER_ARGS='-e CC=gcc -e CXX=g++ -e debug=y' \
107 automation/scripts/containerize automation/scripts/build < /dev/null
108 make -C automation/build opensuse/tumbleweed-x86_64 PUSH=1
109 ```
110
111 [BuildKit]: https://docs.docker.com/build/buildkit/
112 [registry]: https://gitlab.com/xen-project/xen/container_registry
113 [registry help]: https://docs.gitlab.com/ee/user/packages/container_registry/
114
115
116 Building/Running container for a different architecture
117 -------------------------------------------------------
118
119 On a x86 host, it is possible to build and run containers for other arch (like
120 running a container made for Arm) with docker taking care of running the
121 appropriate software to emulate that arch. For this, simply install the package
122 `qemu-user-static`, and that's it. Then you can start an Arm container on x86
123 host like you would start an x86 container.
124
125 If that doesn't work, you might find some information on
126 [multiarch/qemu-user-static](https://github.com/multiarch/qemu-user-static).