images.py 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263
  1. import os
  2. from pathlib import Path
  3. import dagger
  4. _ALPINE_COMMON_PACKAGES = [
  5. "alpine-sdk",
  6. "autoconf",
  7. "automake",
  8. "bash",
  9. "binutils",
  10. "bison",
  11. "cmake",
  12. "curl",
  13. "curl-static",
  14. "elfutils-dev",
  15. "flex",
  16. "gcc",
  17. "git",
  18. "gnutls-dev",
  19. "gzip",
  20. "jq",
  21. "libelf-static",
  22. "libmnl-dev",
  23. "libmnl-static",
  24. "libtool",
  25. "libuv-dev",
  26. "libuv-static",
  27. "lz4-dev",
  28. "lz4-static",
  29. "make",
  30. "mongo-c-driver-dev",
  31. "mongo-c-driver-static",
  32. "musl-fts-dev",
  33. "ncurses",
  34. "ncurses-static",
  35. "netcat-openbsd",
  36. "ninja",
  37. "openssh",
  38. "pcre2-dev",
  39. "pkgconfig",
  40. "protobuf-dev",
  41. "snappy-dev",
  42. "snappy-static",
  43. "util-linux-dev",
  44. "wget",
  45. "xz",
  46. "yaml-dev",
  47. "yaml-static",
  48. "zlib-dev",
  49. "zlib-static",
  50. "zstd-dev",
  51. "zstd-static",
  52. ]
  53. def build_alpine_3_18(client: dagger.Client, platform: dagger.Platform) -> dagger.Container:
  54. ctr = client.container(platform=platform).from_("alpine:3.18")
  55. pkgs = [pkg for pkg in _ALPINE_COMMON_PACKAGES]
  56. ctr = (
  57. ctr.with_exec(["apk", "add", "--no-cache"] + pkgs)
  58. )
  59. return ctr
  60. def build_alpine_3_19(client: dagger.Client, platform: dagger.Platform) -> dagger.Container:
  61. ctr = client.container(platform=platform).from_("alpine:3.19")
  62. pkgs = [pkg for pkg in _ALPINE_COMMON_PACKAGES]
  63. ctr = (
  64. ctr.with_exec(["apk", "add", "--no-cache"] + pkgs)
  65. )
  66. return ctr
  67. def static_build_openssl(client: dagger.Client, ctr: dagger.Container) -> dagger.Container:
  68. tree = (
  69. client.git(url="https://github.com/openssl/openssl", keep_git_dir=True)
  70. .tag("openssl-3.1.4").tree()
  71. )
  72. #
  73. # TODO: verify 32-bit builds
  74. #
  75. ctr = (
  76. ctr.with_directory("/openssl", tree)
  77. .with_workdir("/openssl")
  78. .with_env_variable("CFLAGS", "-fno-lto -pipe")
  79. .with_env_variable("LDFLAGS", "-static")
  80. .with_env_variable("PKG_CONFIG", "pkg-config --static")
  81. .with_exec(["sed", "-i", "s/disable('static', 'pic', 'threads');/disable('static', 'pic');/", "Configure"])
  82. .with_exec(["./config", "-static", "threads", "no-tests", "--prefix=/openssl-static", "--openssldir=/opt/netdata/etc/ssl"])
  83. .with_exec(["make", "V=1", "-j", str(os.cpu_count())])
  84. .with_exec(["make", "V=1", "-j", str(os.cpu_count()), "install_sw"])
  85. .with_exec(["ln", "-s", "/openssl-static/lib", "/openssl-static/lib64"])
  86. .with_exec(["perl", "configdata.pm", "--dump"])
  87. )
  88. return ctr
  89. def static_build_bash(client: dagger.Client, ctr: dagger.Container) -> dagger.Container:
  90. tree = (
  91. client.git(url="https://git.savannah.gnu.org/git/bash.git", keep_git_dir=True)
  92. .tag("bash-5.1").tree()
  93. )
  94. ctr = (
  95. ctr.with_directory("/bash", tree)
  96. .with_workdir("/bash")
  97. .with_env_variable("CFLAGS", "-pipe")
  98. .with_env_variable("LDFLAGS", "")
  99. .with_env_variable("PKG_CONFIG", "pkg-config --static")
  100. .with_env_variable("PKG_CONFIG_PATH", "/openssl-static/lib64/pkgconfig")
  101. .with_exec([
  102. "./configure", "--prefix", "/opt/netdata",
  103. "--without-bash-malloc",
  104. "--enable-static-link",
  105. "--enable-net-redirections",
  106. "--enable-array-variables",
  107. "--disable-progcomp",
  108. "--disable-profiling",
  109. "--disable-nls",
  110. "--disable-dependency-tracking",
  111. ])
  112. .with_exec(["echo", "-e", "all:\nclean:\ninstall:\n", ">", "examples/loadables/Makefile"])
  113. .with_exec(["make", "clean"])
  114. # see: https://gitweb.gentoo.org/repo/gentoo.git/tree/app-shells/bash/files/bash-5.1-parallel_make.patch?id=4c2ebbf4b8bc660beb98cc2d845c73375d6e4f50
  115. .with_exec(["make", "V=1", "-j", "2", "install"])
  116. .with_exec(["strip", "/opt/netdata/bin/bash"])
  117. )
  118. return ctr
  119. def static_build_curl(client: dagger.Client, ctr: dagger.Container) -> dagger.Container:
  120. tree = (
  121. client.git(url="https://github.com/curl/curl", keep_git_dir=True)
  122. .tag("curl-8_4_0").tree()
  123. )
  124. ctr = (
  125. ctr.with_directory("/curl", tree)
  126. .with_workdir("/curl")
  127. .with_env_variable("CFLAGS", "-I/openssl-static/include -pipe")
  128. .with_env_variable("LDFLAGS", "-static -L/openssl-static/lib64")
  129. .with_env_variable("PKG_CONFIG", "pkg-config --static")
  130. .with_env_variable("PKG_CONFIG_PATH", "/openssl-static/lib64/pkgconfig")
  131. .with_exec(["autoreconf", "-ifv"])
  132. .with_exec([
  133. "./configure", "--prefix=/curl-static",
  134. "--enable-optimize",
  135. "--disable-shared",
  136. "--enable-static",
  137. "--enable-http",
  138. "--disable-ldap",
  139. "--disable-ldaps",
  140. "--enable-proxy",
  141. "--disable-dict",
  142. "--disable-telnet",
  143. "--disable-tftp",
  144. "--disable-pop3",
  145. "--disable-imap",
  146. "--disable-smb",
  147. "--disable-smtp",
  148. "--disable-gopher",
  149. "--enable-ipv6",
  150. "--enable-cookies",
  151. "--with-ca-fallback",
  152. "--with-openssl",
  153. "--disable-dependency-tracking",
  154. ])
  155. .with_exec(["sed", "-i", "-e", "s/LDFLAGS =/LDFLAGS = -all-static/", "src/Makefile"])
  156. .with_exec(["make", "clean"])
  157. .with_exec(["make", "V=1", "-j", str(os.cpu_count()), "install"])
  158. .with_exec(["cp", "/curl-static/bin/curl", "/opt/netdata/bin/curl"])
  159. .with_exec(["strip", "/opt/netdata/bin/curl"])
  160. )
  161. return ctr
  162. def static_build_ioping(client: dagger.Client, ctr: dagger.Container) -> dagger.Container:
  163. tree = (
  164. client.git(url="https://github.com/koct9i/ioping", keep_git_dir=True)
  165. .tag("v1.3").tree()
  166. )
  167. ctr = (
  168. ctr.with_directory("/ioping", tree)
  169. .with_workdir("/ioping")
  170. .with_env_variable("CFLAGS", "-static -pipe")
  171. .with_exec(["mkdir", "-p", "/opt/netdata/usr/libexec/netdata/plugins.d"])
  172. .with_exec(["make", "V=1"])
  173. .with_exec(["install", "-o", "root", "-g", "root", "-m", "4750", "ioping", "/opt/netdata/usr/libexec/netdata/plugins.d"])
  174. .with_exec(["strip", "/opt/netdata/usr/libexec/netdata/plugins.d/ioping"])
  175. )
  176. return ctr
  177. def static_build_libnetfilter_acct(client: dagger.Client, ctr: dagger.Container) -> dagger.Container:
  178. tree = (
  179. client.git(url="git://git.netfilter.org/libnetfilter_acct", keep_git_dir=True)
  180. .tag("libnetfilter_acct-1.0.3").tree()
  181. )
  182. ctr = (
  183. ctr.with_directory("/libnetfilter_acct", tree)
  184. .with_workdir("/libnetfilter_acct")
  185. .with_env_variable("CFLAGS", "-static -I/usr/include/libmnl -pipe")
  186. .with_env_variable("LDFLAGS", "-static -L/usr/lib -lmnl")
  187. .with_env_variable("PKG_CONFIG", "pkg-config --static")
  188. .with_env_variable("PKG_CONFIG_PATH", "/usr/lib/pkgconfig")
  189. .with_exec(["autoreconf", "-ifv"])
  190. .with_exec([
  191. "./configure", "--prefix=/libnetfilter_acct-static",
  192. "--exec-prefix=/libnetfilter_acct-static",
  193. ])
  194. .with_exec(["make", "clean"])
  195. .with_exec(["make", "V=1", "-j", str(os.cpu_count()), "install"])
  196. )
  197. return ctr
  198. def static_build_netdata(client: dagger.Client, ctr: dagger.Container) -> dagger.Container:
  199. CFLAGS = [
  200. "-ffunction-sections",
  201. "-fdata-sections",
  202. "-static",
  203. "-O2",
  204. "-funroll-loops",
  205. "-I/openssl-static/include",
  206. "-I/libnetfilter_acct-static/include/libnetfilter_acct",
  207. "-I/curl-local/include/curl",
  208. "-I/usr/include/libmnl",
  209. "-pipe"
  210. ]
  211. LDFLAGS = [
  212. "-Wl,--gc-sections",
  213. "-static",
  214. "-L/openssl-static/lib64",
  215. "-L/libnetfilter_acct-static/lib",
  216. "-lnetfilter_acct",
  217. "-L/usr/lib",
  218. "-lmnl",
  219. "-L/usr/lib",
  220. "-lzstd",
  221. "-L/curl-local/lib",
  222. ]
  223. PKG_CONFIG = [
  224. "pkg-config",
  225. "--static",
  226. ]
  227. PKG_CONFIG_PATH = [
  228. "/openssl-static/lib64/pkgconfig",
  229. "/libnetfilter_acct-static/lib/pkgconfig",
  230. "/usr/lib/pkgconfig",
  231. "/curl-local/lib/pkgconfig",
  232. ]
  233. CMAKE_FLAGS=[
  234. "-DOPENSSL_ROOT_DIR=/openssl-static",
  235. "-DOPENSSL_LIBRARIES=/openssl-static/lib64",
  236. "-DCMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE=/openssl-static",
  237. "-DLWS_OPENSSL_INCLUDE_DIRS=/openssl-static/include",
  238. "-DLWS_OPENSSL_LIBRARIES=/openssl-static/lib64/libssl.a;/openssl-static/lib64/libcrypto.a",
  239. ]
  240. NETDATA_INSTALLER_CMD = [
  241. "./netdata-installer.sh", "--install-prefix", "/opt",
  242. "--dont-wait",
  243. "--dont-start-it",
  244. "--disable-exporting-mongodb",
  245. "--require-cloud",
  246. "--use-system-protobuf",
  247. "--dont-scrub-cflags-even-though-it-may-break-things",
  248. "--one-time-build",
  249. "--enable-lto",
  250. ]
  251. ctr = (
  252. ctr.with_workdir("/netdata")
  253. .with_env_variable("NETDATA_CMAKE_OPTIONS", "-DCMAKE_BUILD_TYPE=Debug")
  254. .with_env_variable("CFLAGS", " ".join(CFLAGS))
  255. .with_env_variable("LDFLAGS", " ".join(LDFLAGS))
  256. .with_env_variable("PKG_CONFIG", " ".join(PKG_CONFIG))
  257. .with_env_variable("PKG_CONFIG_PATH", ":".join(PKG_CONFIG_PATH))
  258. .with_env_variable("CMAKE_FLAGS", " ".join(CMAKE_FLAGS))
  259. .with_env_variable("EBPF_LIBC", "static")
  260. .with_env_variable("IS_NETDATA_STATIC_BINARY", "yes")
  261. .with_exec(NETDATA_INSTALLER_CMD)
  262. )
  263. return ctr
  264. def static_build(client, repo_path):
  265. cmake_build_release_path = os.path.join(repo_path, "cmake-build-release")
  266. ctr = build_alpine_3_18(client, dagger.Platform("linux/x86_64"))
  267. ctr = static_build_openssl(client, ctr)
  268. ctr = static_build_bash(client, ctr)
  269. ctr = static_build_curl(client, ctr)
  270. ctr = static_build_ioping(client, ctr)
  271. ctr = static_build_libnetfilter_acct(client, ctr)
  272. ctr = (
  273. ctr.with_directory("/netdata", client.host().directory(repo_path), exclude=[
  274. f"{cmake_build_release_path}/*",
  275. "fluent-bit/build",
  276. ])
  277. )
  278. # TODO: link bin/sbin
  279. ctr = static_build_netdata(client, ctr)
  280. build_dir = ctr.directory('/opt/netdata')
  281. artifact_dir = os.path.join(Path.home(), f'ci/netdata-static')
  282. output_task = build_dir.export(artifact_dir)
  283. return output_task
  284. _CENTOS_COMMON_PACKAGES = [
  285. "autoconf",
  286. "autoconf-archive",
  287. "autogen",
  288. "automake",
  289. "bison",
  290. "bison-devel",
  291. "cmake",
  292. "cups-devel",
  293. "curl",
  294. "diffutils",
  295. "elfutils-libelf-devel",
  296. "findutils",
  297. "flex",
  298. "flex-devel",
  299. "freeipmi-devel",
  300. "gcc",
  301. "gcc-c++",
  302. "git-core",
  303. "golang",
  304. "json-c-devel",
  305. "libyaml-devel",
  306. "libatomic",
  307. "libcurl-devel",
  308. "libmnl-devel",
  309. "libnetfilter_acct-devel",
  310. "libtool",
  311. "libuuid-devel",
  312. "libuv-devel",
  313. "libzstd-devel",
  314. "lm_sensors",
  315. "lz4-devel",
  316. "make",
  317. "ninja-build",
  318. "openssl-devel",
  319. "openssl-perl",
  320. "patch",
  321. "pcre2-devel",
  322. "pkgconfig",
  323. "pkgconfig(libmongoc-1.0)",
  324. "procps",
  325. "protobuf-c-devel",
  326. "protobuf-compiler",
  327. "protobuf-devel",
  328. "rpm-build",
  329. "rpm-devel",
  330. "rpmdevtools",
  331. "snappy-devel",
  332. "systemd-devel",
  333. "wget",
  334. "zlib-devel",
  335. ]
  336. def build_amazon_linux_2(client: dagger.Client, platform: dagger.Platform) -> dagger.Container:
  337. ctr = client.container(platform=platform).from_("amazonlinux:2")
  338. pkgs = [pkg for pkg in _CENTOS_COMMON_PACKAGES]
  339. ctr = (
  340. ctr.with_exec(["yum", "update", "-y"])
  341. .with_exec(["yum", "install", "-y"] + pkgs)
  342. .with_exec(["yum", "clean", "all"])
  343. .with_exec(["c_rehash"])
  344. .with_exec([
  345. "mkdir", "-p",
  346. "/root/rpmbuild/BUILD",
  347. "/root/rpmbuild/RPMS",
  348. "/root/rpmbuild/SOURCES",
  349. "/root/rpmbuild/SPECS",
  350. "/root/rpmbuild/SRPMS",
  351. ])
  352. )
  353. if platform == "linux/x86_64":
  354. machine = "x86_64"
  355. elif platform == "linux/arm64":
  356. machine = "aarch64"
  357. else:
  358. raise Exception("Amaxon Linux 2 supports only linux/amd64 and linux/arm64 platforms.")
  359. repo_path = str(Path(__file__).parent.parent.parent)
  360. this_path = os.path.join(repo_path, "packaging/dag")
  361. ctr = (
  362. ctr.with_file(f"cmake-{machine}.sha256", client.host().file(f"{this_path}/cmake-{machine}.sha256"))
  363. .with_exec([
  364. "curl", "--fail", "-sSL", "--connect-timeout", "20", "--retry", "3", "--output", f"cmake-{machine}.sh",
  365. f"https://github.com/Kitware/CMake/releases/download/v3.27.6/cmake-3.27.6-linux-{machine}.sh",
  366. ])
  367. .with_exec(["sha256sum", "-c", f"cmake-{machine}.sha256"])
  368. .with_exec(["chmod", "u+x", f"./cmake-{machine}.sh"])
  369. .with_exec([f"./cmake-{machine}.sh", "--skip-license", "--prefix=/usr/local"])
  370. )
  371. return ctr
  372. def build_centos_7(client: dagger.Client, platform: dagger.Platform) -> dagger.Container:
  373. ctr = client.container(platform=platform).from_("centos:7")
  374. pkgs = [pkg for pkg in _CENTOS_COMMON_PACKAGES] + ["bash"]
  375. ctr = (
  376. ctr.with_exec(["yum", "install", "-y", "epel-release"])
  377. .with_exec(["yum", "update", "-y"])
  378. .with_exec(["yum", "install", "-y"] + pkgs)
  379. .with_exec(["yum", "clean", "all"])
  380. .with_exec(["c_rehash"])
  381. .with_exec([
  382. "mkdir", "-p",
  383. "/root/rpmbuild/BUILD",
  384. "/root/rpmbuild/RPMS",
  385. "/root/rpmbuild/SOURCES",
  386. "/root/rpmbuild/SPECS",
  387. "/root/rpmbuild/SRPMS",
  388. ])
  389. )
  390. if platform == "linux/x86_64":
  391. machine = "x86_64"
  392. elif platform == "linux/arm64":
  393. machine = "aarch64"
  394. else:
  395. raise Exception("CentOS 7 supports only linux/amd64 and linux/arm64 platforms.")
  396. repo_path = str(Path(__file__).parent.parent.parent)
  397. this_path = os.path.join(repo_path, "packaging/dag")
  398. ctr = (
  399. ctr.with_file(f"cmake-{machine}.sha256", client.host().file(f"{this_path}/cmake-{machine}.sha256"))
  400. .with_exec([
  401. "curl", "--fail", "-sSL", "--connect-timeout", "20", "--retry", "3", "--output", f"cmake-{machine}.sh",
  402. f"https://github.com/Kitware/CMake/releases/download/v3.27.6/cmake-3.27.6-linux-{machine}.sh",
  403. ])
  404. .with_exec(["sha256sum", "-c", f"cmake-{machine}.sha256"])
  405. .with_exec(["chmod", "u+x", f"./cmake-{machine}.sh"])
  406. .with_exec([f"./cmake-{machine}.sh", "--skip-license", "--prefix=/usr/local"])
  407. )
  408. return ctr
  409. _ROCKY_LINUX_COMMON_PACKAGES = [
  410. "autoconf",
  411. "autoconf-archive",
  412. "automake",
  413. "bash",
  414. "bison",
  415. "cmake",
  416. "cups-devel",
  417. "curl",
  418. "libcurl-devel",
  419. "diffutils",
  420. "elfutils-libelf-devel",
  421. "findutils",
  422. "flex",
  423. "freeipmi-devel",
  424. "gcc",
  425. "gcc-c++",
  426. "git",
  427. "golang",
  428. "json-c-devel",
  429. "libatomic",
  430. "libmnl-devel",
  431. "libtool",
  432. "libuuid-devel",
  433. "libuv-devel",
  434. "libyaml-devel",
  435. "libzstd-devel",
  436. "lm_sensors",
  437. "lz4-devel",
  438. "make",
  439. "ninja-build",
  440. "nc",
  441. "openssl-devel",
  442. "openssl-perl",
  443. "patch",
  444. "pcre2-devel",
  445. "pkgconfig",
  446. "pkgconfig(libmongoc-1.0)",
  447. "procps",
  448. "protobuf-c-devel",
  449. "protobuf-compiler",
  450. "protobuf-devel",
  451. "python3",
  452. "python3-pyyaml",
  453. "rpm-build",
  454. "rpm-devel",
  455. "rpmdevtools",
  456. "snappy-devel",
  457. "systemd-devel",
  458. "wget",
  459. "zlib-devel",
  460. ]
  461. def build_rocky_linux_8(client: dagger.Client, platform: dagger.Platform) -> dagger.Container:
  462. ctr = client.container(platform=platform).from_("rockylinux:8")
  463. pkgs = [pkg for pkg in _ROCKY_LINUX_COMMON_PACKAGES] + ["autogen"]
  464. ctr = (
  465. ctr.with_exec(["dnf", "distro-sync", "-y", "--nodocs"])
  466. .with_exec(["dnf", "install", "-y", "--nodocs", "dnf-command(config-manager)", "epel-release"])
  467. .with_exec(["dnf", "config-manager", "--set-enabled", "powertools"])
  468. .with_exec(["dnf", "clean", "packages"])
  469. .with_exec([
  470. "dnf", "install", "-y", "--nodocs", "--setopt=install_weak_deps=False", "--setopt=diskspacecheck=False",
  471. ] + pkgs)
  472. .with_exec(["rm", "-rf", "/var/cache/dnf"])
  473. .with_exec(["c_rehash"])
  474. .with_exec([
  475. "mkdir", "-p",
  476. "/root/rpmbuild/BUILD",
  477. "/root/rpmbuild/RPMS",
  478. "/root/rpmbuild/SOURCES",
  479. "/root/rpmbuild/SPECS",
  480. "/root/rpmbuild/SRPMS",
  481. ])
  482. )
  483. return ctr
  484. def build_rocky_linux_9(client: dagger.Client, platform: dagger.Platform) -> dagger.Container:
  485. ctr = client.container(platform=platform).from_("rockylinux:9")
  486. pkgs = [pkg for pkg in _ROCKY_LINUX_COMMON_PACKAGES]
  487. ctr = (
  488. ctr.with_exec(["dnf", "distro-sync", "-y", "--nodocs"])
  489. .with_exec(["dnf", "install", "-y", "--nodocs", "dnf-command(config-manager)", "epel-release"])
  490. .with_exec(["dnf", "config-manager", "--set-enabled", "crb"])
  491. .with_exec(["dnf", "clean", "packages"])
  492. .with_exec([
  493. "dnf", "install", "-y", "--allowerasing", "--nodocs", "--setopt=install_weak_deps=False", "--setopt=diskspacecheck=False",
  494. ] + pkgs)
  495. .with_exec(["rm", "-rf", "/var/cache/dnf"])
  496. .with_exec(["c_rehash"])
  497. .with_exec([
  498. "mkdir", "-p",
  499. "/root/rpmbuild/BUILD",
  500. "/root/rpmbuild/RPMS",
  501. "/root/rpmbuild/SOURCES",
  502. "/root/rpmbuild/SPECS",
  503. "/root/rpmbuild/SRPMS",
  504. ])
  505. )
  506. return ctr
  507. _CENTOS_STREAM_COMMON_PACKAGES = [
  508. "autoconf",
  509. "autoconf-archive",
  510. "automake",
  511. "bash",
  512. "bison",
  513. "cmake",
  514. "cups-devel",
  515. "curl",
  516. "libcurl-devel",
  517. "libyaml-devel",
  518. "diffutils",
  519. "elfutils-libelf-devel",
  520. "findutils",
  521. "flex",
  522. "freeipmi-devel",
  523. "gcc",
  524. "gcc-c++",
  525. "git",
  526. "golang",
  527. "json-c-devel",
  528. "libatomic",
  529. "libmnl-devel",
  530. "libtool",
  531. "libuuid-devel",
  532. "libuv-devel",
  533. # "libzstd-devel",
  534. "lm_sensors",
  535. "lz4-devel",
  536. "make",
  537. "ninja-build",
  538. "nc",
  539. "openssl-devel",
  540. "openssl-perl",
  541. "patch",
  542. "pcre2-devel",
  543. "pkgconfig",
  544. "pkgconfig(libmongoc-1.0)",
  545. "procps",
  546. "protobuf-c-devel",
  547. "protobuf-compiler",
  548. "protobuf-devel",
  549. "python3",
  550. "python3-pyyaml",
  551. "rpm-build",
  552. "rpm-devel",
  553. "rpmdevtools",
  554. "snappy-devel",
  555. "systemd-devel",
  556. "wget",
  557. "zlib-devel",
  558. ]
  559. def build_centos_stream_8(client: dagger.Client, platform: dagger.Platform) -> dagger.Container:
  560. ctr = client.container(platform=platform).from_("quay.io/centos/centos:stream8")
  561. pkgs = [pkg for pkg in _CENTOS_STREAM_COMMON_PACKAGES] + ["autogen"]
  562. ctr = (
  563. ctr.with_exec(["dnf", "distro-sync", "-y", "--nodocs"])
  564. .with_exec(["dnf", "install", "-y", "--nodocs", "dnf-command(config-manager)", "epel-release"])
  565. .with_exec(["dnf", "config-manager", "--set-enabled", "powertools"])
  566. .with_exec(["dnf", "clean", "packages"])
  567. .with_exec([
  568. "dnf", "install", "-y", "--nodocs", "--setopt=install_weak_deps=False", "--setopt=diskspacecheck=False",
  569. ] + pkgs)
  570. .with_exec(["rm", "-rf", "/var/cache/dnf"])
  571. .with_exec(["c_rehash"])
  572. .with_exec([
  573. "mkdir", "-p",
  574. "/root/rpmbuild/BUILD",
  575. "/root/rpmbuild/RPMS",
  576. "/root/rpmbuild/SOURCES",
  577. "/root/rpmbuild/SPECS",
  578. "/root/rpmbuild/SRPMS",
  579. ])
  580. )
  581. return ctr
  582. def build_centos_stream_9(client: dagger.Client, platform: dagger.Platform) -> dagger.Container:
  583. ctr = client.container(platform=platform).from_("quay.io/centos/centos:stream9")
  584. pkgs = [pkg for pkg in _CENTOS_STREAM_COMMON_PACKAGES]
  585. ctr = (
  586. ctr.with_exec(["dnf", "distro-sync", "-y", "--nodocs"])
  587. .with_exec(["dnf", "install", "-y", "--nodocs", "dnf-command(config-manager)", "epel-release"])
  588. .with_exec(["dnf", "config-manager", "--set-enabled", "crb"])
  589. .with_exec(["dnf", "clean", "packages"])
  590. .with_exec([
  591. "dnf", "install", "-y", "--allowerasing", "--nodocs", "--setopt=install_weak_deps=False", "--setopt=diskspacecheck=False",
  592. ] + pkgs)
  593. .with_exec(["rm", "-rf", "/var/cache/dnf"])
  594. .with_exec(["c_rehash"])
  595. .with_exec([
  596. "mkdir", "-p",
  597. "/root/rpmbuild/BUILD",
  598. "/root/rpmbuild/RPMS",
  599. "/root/rpmbuild/SOURCES",
  600. "/root/rpmbuild/SPECS",
  601. "/root/rpmbuild/SRPMS",
  602. ])
  603. )
  604. return ctr
  605. _ORACLE_LINUX_COMMON_PACKAGES = list(_ROCKY_LINUX_COMMON_PACKAGES)
  606. def build_oracle_linux_9(client: dagger.Client, platform: dagger.Platform) -> dagger.Container:
  607. ctr = client.container(platform=platform).from_("oraclelinux:9")
  608. pkgs = [pkg for pkg in _ORACLE_LINUX_COMMON_PACKAGES]
  609. repo_path = str(Path(__file__).parent.parent.parent)
  610. this_path = os.path.join(repo_path, "packaging/dag")
  611. ctr = (
  612. ctr.with_file("/etc/yum.repos.d/ol9-epel.repo", client.host().file(f"{this_path}/ol9-epel.repo"))
  613. .with_exec(["dnf", "config-manager", "--set-enabled", "ol9_codeready_builder"])
  614. .with_exec(["dnf", "config-manager", "--set-enabled", "ol9_developer_EPEL"])
  615. .with_exec(["dnf", "distro-sync", "-y", "--nodocs"])
  616. .with_exec(["dnf", "clean", "-y", "packages"])
  617. .with_exec([
  618. "dnf", "install", "-y", "--nodocs", "--setopt=install_weak_deps=False", "--setopt=diskspacecheck=False",
  619. ] + pkgs)
  620. .with_exec(["rm", "-rf", "/var/cache/dnf"])
  621. .with_exec(["c_rehash"])
  622. .with_exec([
  623. "mkdir", "-p",
  624. "/root/rpmbuild/BUILD",
  625. "/root/rpmbuild/RPMS",
  626. "/root/rpmbuild/SOURCES",
  627. "/root/rpmbuild/SPECS",
  628. "/root/rpmbuild/SRPMS",
  629. ])
  630. )
  631. return ctr
  632. def build_oracle_linux_8(client: dagger.Client, platform: dagger.Platform) -> dagger.Container:
  633. ctr = client.container(platform=platform).from_("oraclelinux:8")
  634. pkgs = [pkg for pkg in _ORACLE_LINUX_COMMON_PACKAGES] + ["autogen"]
  635. repo_path = str(Path(__file__).parent.parent.parent)
  636. this_path = os.path.join(repo_path, "packaging/dag")
  637. ctr = (
  638. ctr.with_file("/etc/yum.repos.d/ol8-epel.repo", client.host().file(f"{this_path}/ol8-epel.repo"))
  639. .with_exec(["dnf", "config-manager", "--set-enabled", "ol8_codeready_builder"])
  640. .with_exec(["dnf", "distro-sync", "-y", "--nodocs"])
  641. .with_exec(["dnf", "clean", "-y", "packages"])
  642. .with_exec([
  643. "dnf", "install", "-y", "--nodocs", "--setopt=install_weak_deps=False", "--setopt=diskspacecheck=False",
  644. ] + pkgs)
  645. .with_exec(["rm", "-rf", "/var/cache/dnf"])
  646. .with_exec(["c_rehash"])
  647. .with_exec([
  648. "mkdir", "-p",
  649. "/root/rpmbuild/BUILD",
  650. "/root/rpmbuild/RPMS",
  651. "/root/rpmbuild/SOURCES",
  652. "/root/rpmbuild/SPECS",
  653. "/root/rpmbuild/SRPMS",
  654. ])
  655. )
  656. return ctr
  657. _OPENSUSE_COMMON_PACKAGES = [
  658. "autoconf",
  659. "autoconf-archive",
  660. "autogen",
  661. "automake",
  662. "bison",
  663. "cmake",
  664. "cups",
  665. "cups-devel",
  666. "curl",
  667. "diffutils",
  668. "flex",
  669. "freeipmi-devel",
  670. "gcc",
  671. "gcc-c++",
  672. "git-core",
  673. "go",
  674. "json-glib-devel",
  675. "judy-devel",
  676. "libatomic1",
  677. "libcurl-devel",
  678. "libelf-devel",
  679. "liblz4-devel",
  680. "libjson-c-devel",
  681. "libyaml-devel",
  682. "libmnl0",
  683. "libmnl-devel",
  684. "libnetfilter_acct1",
  685. "libnetfilter_acct-devel",
  686. "libpcre2-8-0",
  687. "libopenssl-devel",
  688. "libtool",
  689. "libuv-devel",
  690. "libuuid-devel",
  691. "libzstd-devel",
  692. "make",
  693. "ninja",
  694. "patch",
  695. "pkg-config",
  696. "protobuf-devel",
  697. "rpm-build",
  698. "rpm-devel",
  699. "rpmdevtools",
  700. "snappy-devel",
  701. "systemd-devel",
  702. "tar",
  703. "wget",
  704. "xen-devel",
  705. ]
  706. def build_opensuse_tumbleweed(client: dagger.Client, platform: dagger.Platform) -> dagger.Container:
  707. ctr = client.container(platform=platform).from_("opensuse/tumbleweed:latest")
  708. pkgs = [pkg for pkg in _OPENSUSE_COMMON_PACKAGES] + ["protobuf-c"]
  709. ctr = (
  710. ctr.with_exec(["zypper", "update", "-y"])
  711. .with_exec([
  712. "zypper", "install", "-y", "--allow-downgrade",
  713. ] + pkgs)
  714. .with_exec(["zypper", "clean"])
  715. .with_exec(["rm", "-rf", "/var/cache/zypp/*/*"])
  716. .with_exec(["c_rehash"])
  717. .with_exec([
  718. "mkdir", "-p",
  719. "/usr/src/packages/BUILD",
  720. "/usr/src/packages/RPMS",
  721. "/usr/src/packages/SOURCES",
  722. "/usr/src/packages/SPECS",
  723. "/usr/src/packages/SRPMS",
  724. ])
  725. )
  726. return ctr
  727. def build_opensuse_15_5(client: dagger.Client, platform: dagger.Platform) -> dagger.Container:
  728. ctr = client.container(platform=platform).from_("opensuse/leap:15.5")
  729. pkgs = [pkg for pkg in _OPENSUSE_COMMON_PACKAGES] + ["libprotobuf-c-devel"]
  730. ctr = (
  731. ctr.with_exec(["zypper", "update", "-y"])
  732. .with_exec([
  733. "zypper", "install", "-y", "--allow-downgrade",
  734. ] + pkgs)
  735. .with_exec(["zypper", "clean"])
  736. .with_exec(["rm", "-rf", "/var/cache/zypp/*/*"])
  737. .with_exec(["c_rehash"])
  738. .with_exec([
  739. "mkdir", "-p",
  740. "/usr/src/packages/BUILD",
  741. "/usr/src/packages/RPMS",
  742. "/usr/src/packages/SOURCES",
  743. "/usr/src/packages/SPECS",
  744. "/usr/src/packages/SRPMS",
  745. ])
  746. )
  747. return ctr
  748. def build_opensuse_15_4(client: dagger.Client, platform: dagger.Platform) -> dagger.Container:
  749. crt = client.container(platform=platform).from_("opensuse/leap:15.4")
  750. pkgs = [pkg for pkg in _OPENSUSE_COMMON_PACKAGES] + ["libprotobuf-c-devel"]
  751. crt = (
  752. crt.with_exec(["zypper", "update", "-y"])
  753. .with_exec([
  754. "zypper", "install", "-y", "--allow-downgrade",
  755. ] + pkgs)
  756. .with_exec(["zypper", "clean"])
  757. .with_exec(["rm", "-rf", "/var/cache/zypp/*/*"])
  758. .with_exec(["c_rehash"])
  759. .with_exec([
  760. "mkdir", "-p",
  761. "/usr/src/packages/BUILD",
  762. "/usr/src/packages/RPMS",
  763. "/usr/src/packages/SOURCES",
  764. "/usr/src/packages/SPECS",
  765. "/usr/src/packages/SRPMS",
  766. ])
  767. )
  768. return crt
  769. _FEDORA_COMMON_PACKAGES = [
  770. "autoconf",
  771. "autoconf-archive",
  772. "autogen",
  773. "automake",
  774. "bash",
  775. "bison",
  776. "cmake",
  777. "cups-devel",
  778. "curl",
  779. "diffutils",
  780. "elfutils-libelf-devel",
  781. "findutils",
  782. "flex",
  783. "freeipmi-devel",
  784. "gcc",
  785. "gcc-c++",
  786. "git-core",
  787. "golang",
  788. "json-c-devel",
  789. "libcurl-devel",
  790. "libyaml-devel",
  791. "Judy-devel",
  792. "libatomic",
  793. "libmnl-devel",
  794. "libnetfilter_acct-devel",
  795. "libtool",
  796. "libuuid-devel",
  797. "libuv-devel",
  798. "libzstd-devel",
  799. "lz4-devel",
  800. "make",
  801. "ninja-build",
  802. "openssl-devel",
  803. "openssl-perl",
  804. "patch",
  805. "pcre2-devel",
  806. "pkgconfig",
  807. ]
  808. def build_fedora_37(client: dagger.Client, platform: dagger.Platform) -> dagger.Container:
  809. ctr = client.container(platform=platform).from_("fedora:37")
  810. pkgs = [pkg for pkg in _FEDORA_COMMON_PACKAGES]
  811. ctr = (
  812. ctr.with_exec(["dnf", "distro-sync", "-y", "--nodocs"])
  813. .with_exec(["dnf", "clean", "-y", "packages"])
  814. .with_exec([
  815. "dnf", "install", "-y", "--nodocs", "--setopt=install_weak_deps=False", "--setopt=diskspacecheck=False",
  816. ] + pkgs)
  817. .with_exec(["rm", "-rf", "/var/cache/dnf"])
  818. .with_exec(["c_rehash"])
  819. .with_exec([
  820. "mkdir", "-p",
  821. "/root/rpmbuild/BUILD",
  822. "/root/rpmbuild/RPMS",
  823. "/root/rpmbuild/SOURCES",
  824. "/root/rpmbuild/SPECS",
  825. "/root/rpmbuild/SRPMS",
  826. ])
  827. )
  828. return ctr
  829. def build_fedora_38(client: dagger.Client, platform: dagger.Platform) -> dagger.Container:
  830. ctr = client.container(platform=platform).from_("fedora:38")
  831. pkgs = [pkg for pkg in _FEDORA_COMMON_PACKAGES]
  832. ctr = (
  833. ctr.with_exec(["dnf", "distro-sync", "-y", "--nodocs"])
  834. .with_exec(["dnf", "clean", "-y", "packages"])
  835. .with_exec([
  836. "dnf", "install", "-y", "--nodocs", "--setopt=install_weak_deps=False", "--setopt=diskspacecheck=False",
  837. ] + pkgs)
  838. .with_exec(["rm", "-rf", "/var/cache/dnf"])
  839. .with_exec(["c_rehash"])
  840. .with_exec([
  841. "mkdir", "-p",
  842. "/root/rpmbuild/BUILD",
  843. "/root/rpmbuild/RPMS",
  844. "/root/rpmbuild/SOURCES",
  845. "/root/rpmbuild/SPECS",
  846. "/root/rpmbuild/SRPMS",
  847. ])
  848. )
  849. return ctr
  850. def build_fedora_39(client: dagger.Client, platform: dagger.Platform) -> dagger.Container:
  851. ctr = client.container(platform=platform).from_("fedora:39")
  852. pkgs = [pkg for pkg in _FEDORA_COMMON_PACKAGES]
  853. ctr = (
  854. ctr.with_exec(["dnf", "distro-sync", "-y", "--nodocs"])
  855. .with_exec(["dnf", "clean", "-y", "packages"])
  856. .with_exec([
  857. "dnf", "install", "-y", "--nodocs", "--setopt=install_weak_deps=False", "--setopt=diskspacecheck=False",
  858. ] + pkgs)
  859. .with_exec(["rm", "-rf", "/var/cache/dnf"])
  860. .with_exec(["c_rehash"])
  861. .with_exec([
  862. "mkdir", "-p",
  863. "/root/rpmbuild/BUILD",
  864. "/root/rpmbuild/RPMS",
  865. "/root/rpmbuild/SOURCES",
  866. "/root/rpmbuild/SPECS",
  867. "/root/rpmbuild/SRPMS",
  868. ])
  869. )
  870. return ctr
  871. _DEBIAN_COMMON_PACKAGES = [
  872. "autoconf",
  873. "autoconf-archive",
  874. "autogen",
  875. "automake",
  876. "bison",
  877. "build-essential",
  878. "ca-certificates",
  879. "cmake",
  880. "curl",
  881. "dh-autoreconf",
  882. "dh-make",
  883. "dpkg-dev",
  884. "flex",
  885. "g++",
  886. "gcc",
  887. "git-buildpackage",
  888. "git-core",
  889. "golang",
  890. "libatomic1",
  891. "libcurl4-openssl-dev",
  892. "libcups2-dev",
  893. "libdistro-info-perl",
  894. "libelf-dev",
  895. "libipmimonitoring-dev",
  896. "libjson-c-dev",
  897. "libyaml-dev",
  898. "libjudy-dev",
  899. "liblz4-dev",
  900. "libmnl-dev",
  901. "libmongoc-dev",
  902. "libnetfilter-acct-dev",
  903. "libpcre2-dev",
  904. "libprotobuf-dev",
  905. "libprotoc-dev",
  906. "libsnappy-dev",
  907. "libsystemd-dev",
  908. "libssl-dev",
  909. "libtool",
  910. "libuv1-dev",
  911. "libzstd-dev",
  912. "make",
  913. "ninja-build",
  914. "pkg-config",
  915. "protobuf-compiler",
  916. "systemd",
  917. "uuid-dev",
  918. "wget",
  919. "zlib1g-dev",
  920. ]
  921. def build_debian_10(client: dagger.Client, platform: dagger.Platform) -> dagger.Container:
  922. ctr = client.container(platform=platform).from_("debian:buster")
  923. pkgs = [pkg for pkg in _DEBIAN_COMMON_PACKAGES] + ["dh-systemd", "libxen-dev"]
  924. ctr = (
  925. ctr.with_env_variable("DEBIAN_FRONTEND", "noninteractive")
  926. .with_exec(["apt-get", "update"])
  927. .with_exec(["apt-get", "upgrade", "-y"])
  928. .with_exec(["apt-get", "install", "-y", "--no-install-recommends"] + pkgs)
  929. .with_exec(["apt-get", "clean"])
  930. .with_exec(["c_rehash"])
  931. .with_exec(["rm", "-rf", "/var/lib/apt/lists/*"])
  932. )
  933. return ctr
  934. def build_debian_11(client: dagger.Client, platform: dagger.Platform) -> dagger.Container:
  935. ctr = client.container(platform=platform).from_("debian:bullseye")
  936. pkgs = [pkg for pkg in _DEBIAN_COMMON_PACKAGES] + ["libxen-dev"]
  937. ctr = (
  938. ctr.with_env_variable("DEBIAN_FRONTEND", "noninteractive")
  939. .with_exec(["apt-get", "update"])
  940. .with_exec(["apt-get", "upgrade", "-y"])
  941. .with_exec(["apt-get", "install", "-y", "--no-install-recommends"] + pkgs)
  942. .with_exec(["apt-get", "clean"])
  943. .with_exec(["c_rehash"])
  944. .with_exec(["rm", "-rf", "/var/lib/apt/lists/*"])
  945. )
  946. return ctr
  947. def build_debian_12(client: dagger.Client, platform: dagger.Platform) -> dagger.Container:
  948. ctr = client.container(platform=platform).from_("debian:bookworm")
  949. pkgs = [pkg for pkg in _DEBIAN_COMMON_PACKAGES]
  950. if platform != dagger.Platform("linux/i386"):
  951. pkgs.append("libxen-dev")
  952. ctr = (
  953. ctr.with_env_variable("DEBIAN_FRONTEND", "noninteractive")
  954. .with_exec(["apt-get", "update"])
  955. .with_exec(["apt-get", "upgrade", "-y"])
  956. .with_exec(["apt-get", "install", "-y", "--no-install-recommends"] + pkgs)
  957. .with_exec(["apt-get", "clean"])
  958. .with_exec(["c_rehash"])
  959. .with_exec(["rm", "-rf", "/var/lib/apt/lists/*"])
  960. )
  961. return ctr
  962. _UBUNTU_COMMON_PACKAGES = [
  963. "autoconf",
  964. "autoconf-archive",
  965. "autogen",
  966. "automake",
  967. "bison",
  968. "build-essential",
  969. "ca-certificates",
  970. "cmake",
  971. "curl",
  972. "dh-autoreconf",
  973. "dh-make",
  974. "dpkg-dev",
  975. "flex",
  976. "g++",
  977. "gcc",
  978. "git-buildpackage",
  979. "git-core",
  980. "golang",
  981. "libatomic1",
  982. "libcurl4-openssl-dev",
  983. "libcups2-dev",
  984. "libdistro-info-perl",
  985. "libelf-dev",
  986. "libipmimonitoring-dev",
  987. "libjson-c-dev",
  988. "libyaml-dev",
  989. "libjudy-dev",
  990. "liblz4-dev",
  991. "libmnl-dev",
  992. "libmongoc-dev",
  993. "libnetfilter-acct-dev",
  994. "libpcre2-dev",
  995. "libprotobuf-dev",
  996. "libprotoc-dev",
  997. "libsnappy-dev",
  998. "libsystemd-dev",
  999. "libssl-dev",
  1000. "libtool",
  1001. "libuv1-dev",
  1002. "libxen-dev",
  1003. "libzstd-dev",
  1004. "make",
  1005. "ninja-build",
  1006. "pkg-config",
  1007. "protobuf-compiler",
  1008. "systemd",
  1009. "uuid-dev",
  1010. "wget",
  1011. "zlib1g-dev",
  1012. ]
  1013. def build_ubuntu_20_04(client: dagger.Client, platform: dagger.Platform) -> dagger.Container:
  1014. ctr = client.container(platform=platform).from_("ubuntu:20.04")
  1015. pkgs = [pkg for pkg in _UBUNTU_COMMON_PACKAGES] + ["dh-systemd"]
  1016. ctr = (
  1017. ctr.with_env_variable("DEBIAN_FRONTEND", "noninteractive")
  1018. .with_exec(["apt-get", "update"])
  1019. .with_exec(["apt-get", "upgrade", "-y"])
  1020. .with_exec(["apt-get", "install", "-y", "--no-install-recommends"] + pkgs)
  1021. .with_exec(["apt-get", "clean"])
  1022. .with_exec(["c_rehash"])
  1023. .with_exec(["rm", "-rf", "/var/lib/apt/lists/*"])
  1024. )
  1025. #
  1026. # FIXME: add kitware for cmake on arm-hf
  1027. #
  1028. return ctr
  1029. def build_ubuntu_22_04(client: dagger.Client, platform: dagger.Platform) -> dagger.Container:
  1030. ctr = client.container(platform=platform).from_("ubuntu:22.04")
  1031. pkgs = [pkg for pkg in _UBUNTU_COMMON_PACKAGES]
  1032. ctr = (
  1033. ctr.with_env_variable("DEBIAN_FRONTEND", "noninteractive")
  1034. .with_exec(["apt-get", "update"])
  1035. .with_exec(["apt-get", "upgrade", "-y"])
  1036. .with_exec(["apt-get", "install", "-y", "--no-install-recommends"] + pkgs)
  1037. .with_exec(["apt-get", "clean"])
  1038. .with_exec(["c_rehash"])
  1039. .with_exec(["rm", "-rf", "/var/lib/apt/lists/*"])
  1040. )
  1041. return ctr
  1042. def build_ubuntu_23_04(client: dagger.Client, platform: dagger.Platform) -> dagger.Container:
  1043. ctr = client.container(platform=platform).from_("ubuntu:23.04")
  1044. pkgs = [pkg for pkg in _UBUNTU_COMMON_PACKAGES]
  1045. ctr = (
  1046. ctr.with_env_variable("DEBIAN_FRONTEND", "noninteractive")
  1047. .with_exec(["apt-get", "update"])
  1048. .with_exec(["apt-get", "upgrade", "-y"])
  1049. .with_exec(["apt-get", "install", "-y", "--no-install-recommends"] + pkgs)
  1050. .with_exec(["apt-get", "clean"])
  1051. .with_exec(["c_rehash"])
  1052. .with_exec(["rm", "-rf", "/var/lib/apt/lists/*"])
  1053. )
  1054. return ctr
  1055. def build_ubuntu_23_10(client: dagger.Client, platform: dagger.Platform) -> dagger.Container:
  1056. ctr = client.container(platform=platform).from_("ubuntu:23.10")
  1057. pkgs = [pkg for pkg in _UBUNTU_COMMON_PACKAGES]
  1058. ctr = (
  1059. ctr.with_env_variable("DEBIAN_FRONTEND", "noninteractive")
  1060. .with_exec(["apt-get", "update"])
  1061. .with_exec(["apt-get", "upgrade", "-y"])
  1062. .with_exec(["apt-get", "install", "-y", "--no-install-recommends"] + pkgs)
  1063. .with_exec(["apt-get", "clean"])
  1064. .with_exec(["c_rehash"])
  1065. .with_exec(["rm", "-rf", "/var/lib/apt/lists/*"])
  1066. )
  1067. return ctr
  1068. def install_cargo(ctr: dagger.Container) -> dagger.Container:
  1069. bin_paths = [
  1070. "/root/.cargo/bin",
  1071. "/usr/local/sbin",
  1072. "/usr/local/bin",
  1073. "/usr/sbin",
  1074. "/usr/bin",
  1075. "/sbin",
  1076. "/bin",
  1077. ]
  1078. ctr = (
  1079. ctr.with_workdir("/")
  1080. .with_exec(["sh", "-c", "curl https://sh.rustup.rs -sSf | sh -s -- -y"])
  1081. .with_env_variable("PATH", ":".join(bin_paths))
  1082. .with_exec(["cargo", "new", "--bin", "hello"])
  1083. .with_workdir("/hello")
  1084. .with_exec(["cargo", "run", "-v", "-v"])
  1085. )
  1086. return ctr