File tree Expand file tree Collapse file tree 3 files changed +32
-9
lines changed Expand file tree Collapse file tree 3 files changed +32
-9
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,9 @@ unreleased
2
2
----------
3
3
4
4
- Add Alpine 3.21, deprecate Alpine 3.20. (@MisterDA , #225 )
5
+ - Cache packages downloads for Apt (Debian, Ubuntu) and pacman (Arch
6
+ Linux) based distributions using BuildKit cache mounts.
7
+ (@MisterDA , #224 )
5
8
6
9
v8.2.4 2024-11-18
7
10
-----------------
Original file line number Diff line number Diff line change 86
86
87
87
(* * Debian rules *)
88
88
module Apt = struct
89
+ (* https://docs.docker.com/reference/dockerfile/#example-cache-apt-packages *)
90
+ let cache_mounts =
91
+ [
92
+ mount_cache ~target: " /var/cache/apt" ~sharing: `Locked () ;
93
+ mount_cache ~target: " /var/lib/apt" ~sharing: `Locked () ;
94
+ ]
95
+
89
96
let update =
90
- run " apt-get -y update"
91
- @@ run " DEBIAN_FRONTEND=noninteractive apt-get -y upgrade"
97
+ run
98
+ {| mv / etc/ apt/ apt.conf.d/ docker- clean / tmp/ ; echo 'Binary ::apt ::APT ::Keep - Downloaded - Packages "true" ; ' > / etc/ apt/ apt.conf.d/ keep- cache| }
99
+ @@ run ~mounts: cache_mounts
100
+ " apt update && DEBIAN_FRONTEND=noninteractive apt-get -y upgrade"
101
+ @@ run
102
+ " mv /tmp/docker-clean /etc/apt/apt.conf.d/ && rm -f \
103
+ /etc/apt/apt.conf.d/keep-cache"
92
104
93
105
let install fmt =
94
106
ksprintf
95
107
(fun s ->
96
- update @@ run " DEBIAN_FRONTEND=noninteractive apt-get -y install %s" s)
108
+ update
109
+ @@ run ~mounts: cache_mounts
110
+ " DEBIAN_FRONTEND=noninteractive apt-get --no-install-recommends \
111
+ install -y %s"
112
+ s)
97
113
fmt
98
114
99
115
let dev_packages ?extra () =
@@ -242,11 +258,13 @@ end
242
258
243
259
(* * Pacman rules *)
244
260
module Pacman = struct
245
- let update = run " pacman -Syu --noconfirm && yes | pacman -Scc"
261
+ let cache_mount = mount_cache ~target: " /var/cache/pacman" ~sharing: `Locked ()
262
+ let update = run ~mounts: [ cache_mount ] " pacman -Syu --noconfirm --needed"
246
263
247
264
let install fmt =
248
265
ksprintf
249
- (fun s -> run " pacman -Syu --noconfirm %s && yes | pacman -Scc" s)
266
+ (fun s ->
267
+ run ~mounts: [ cache_mount ] " pacman -Syu --noconfirm --needed %s" s)
250
268
fmt
251
269
252
270
let dev_packages ?extra () =
Original file line number Diff line number Diff line change 62
62
module Apt : sig
63
63
val update : t
64
64
(* * [update] will run [apt-get update && apt-get upgrade] non-interactively.
65
- *)
65
+ Requires [syntax=docker/dockerfile:1]. *)
66
66
67
67
val install : ('a , unit , string , t ) format4 -> 'a
68
68
(* * [install fmt] will [apt-get update && apt-get install] the packages
69
- specified by the [fmt] format string. *)
69
+ specified by the [fmt] format string. Requires
70
+ [syntax=docker/dockerfile:1]. *)
70
71
71
72
val add_user : ?uid : int -> ?gid : int -> ?sudo : bool -> string -> t
72
73
(* * [add_user username] will install a new user with name [username] and a
@@ -150,11 +151,12 @@ end
150
151
(* * Rules for Pacman-based distributions such as Archlinux *)
151
152
module Pacman : sig
152
153
val update : t
153
- (* * [update] will run [pacman -Syu] non-interactively. *)
154
+ (* * [update] will run [pacman -Syu] non-interactively. Requires
155
+ [syntax=docker/dockerfile:1]. *)
154
156
155
157
val install : ('a , unit , string , t ) format4 -> 'a
156
158
(* * [install fmt] will [pacman -Syu] the packages specified by the [fmt]
157
- format string. *)
159
+ format string. Requires [syntax=docker/dockerfile:1]. *)
158
160
159
161
val add_user : ?uid : int -> ?gid : int -> ?sudo : bool -> string -> t
160
162
(* * [add_user username] will install a new user with name [username] and a
You can’t perform that action at this time.
0 commit comments