Skip to content

Commit 840200b

Browse files
committed
Added debian-bookworm image
1 parent 6a0f6d3 commit 840200b

File tree

4 files changed

+107
-0
lines changed

4 files changed

+107
-0
lines changed

Rakefile

+9
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ namespace :minimum2scp do
1717
sh "cd debian && rake clobber mkimage README.md #{tag} #{env}"
1818
end
1919

20+
desc 'build minimum2scp/debian-bookworm image'
21+
task :debian_bookworm do
22+
tag = ->(env, default){
23+
env ? (!env.empty? ? "TAG=#{env}" : "") : "TAG=#{default}"
24+
}[ENV['TAG_DEBIAN'], 'minimum2scp/debian-bookworm:latest']
25+
env = ENV.select{|k,v| %w[http_proxy].include?(k)}.map{|k,v| "#{k}=#{v}"}.join(" ")
26+
sh "cd debian-bookworm && rake clobber mkimage README.md #{tag} #{env}"
27+
end
28+
2029
desc 'build minimum2scp/debian-bullseye image'
2130
task :debian_bullseye do
2231
tag = ->(env, default){

debian-bookworm/README.md.erb

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# about minimum2scp/debian-bookworm image
2+
3+
* Debian bookworm (12.x) amd64
4+
* Almost same as debian:bookworm image ([semi official debian image](https://registry.hub.docker.com/_/debian/))
5+
6+
## build minimum2scp/debian image
7+
8+
Run following commands on your Debian (requires debootstrap)
9+
10+
```
11+
$ git clone https://github.com/minimum2scp/dockerfiles.git
12+
$ cd dockerfiles/debian-bookworm
13+
$ rake mkimage TAG=minimum2scp/debian-bookworm:latest
14+
```
15+
16+
## packages
17+
18+
installed packages:
19+
20+
```
21+
<% fields = %w[db:Status-Abbrev Package Version Architecture binary:Summary] -%>
22+
<% width = Hash[fields[0..-2].map{|k| [k, packages.map{|pkg| pkg[k].size}.max] }] -%>
23+
<% packages.each do |package| -%>
24+
<%= fields.map{|k| "%<#{k}>-#{width[k]}s" }.join(" " * 2) % Hash[fields.map{|k| [k.to_sym, package[k]] }] %>
25+
<% end -%>
26+
```

debian-bookworm/Rakefile

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
##
2+
## mkimage.sh wrapper.
3+
## usage:
4+
##
5+
## git clone --branch v19.03.15 --depth 1 https://github.com/docker/docker-ce.git ~/go/src/github.com/docker/docker-ce
6+
## rake mkimage TAG=minimum2scp/debian:latest
7+
##
8+
9+
require 'erb'
10+
require 'json'
11+
require 'rake/clean'
12+
require 'tmpdir'
13+
require 'tempfile'
14+
15+
CLOBBER.include 'build.log', 'debian-packages.json', 'README.md'
16+
17+
task :default => ['README.md']
18+
19+
desc 'create mkimage.sh log file'
20+
file 'build.log' do
21+
Rake::Task[:mkimage].invoke
22+
end
23+
24+
desc 'run mkimage.sh'
25+
task :mkimage do
26+
tag_option = ENV['TAG'] ? "-t #{ENV['TAG']}" : ''
27+
debootstrap_options = %w[
28+
--arch=amd64 --variant=minbase --components=main --no-merged-usr
29+
]
30+
debootstrap_options << "--cache-dir=#{ENV['DEBOOTSTRAP_CACHE_DIR']}" if ENV['DEBOOTSTRAP_CACHE_DIR']
31+
debootstrap_options << 'bookworm' << 'http://deb.debian.org/debian'
32+
debootstrap_options = debootstrap_options.join(' ')
33+
env = ENV.select{|k,v| ['TMPDIR', 'http_proxy'].include?(k) }.map{|k,v| "#{k}=#{v}"}.join(' ')
34+
mkimage_sh = [
35+
"#{ENV.fetch('GOPATH', "#{ENV['HOME']}/go")}/src/github.com/moby/moby/contrib/mkimage.sh",
36+
"#{ENV.fetch('GOPATH', "#{ENV['HOME']}/go")}/src/github.com/docker/docker-ce/components/engine/contrib/mkimage.sh",
37+
# '/usr/share/docker-ce/contrib/mkimage.sh',
38+
].find{|f| File.executable?(f) }
39+
unless mkimage_sh
40+
raise "mkimage.sh not found"
41+
end
42+
sh "sudo #{env} #{mkimage_sh} #{tag_option} debootstrap #{debootstrap_options} | tee build.log"
43+
end
44+
45+
desc 'update debian-packages.json'
46+
file 'debian-packages.json' => ['build.log'] do |t|
47+
tag = ENV['TAG'] || 'minimum2scp/debian:latest'
48+
tmpfile = Tempfile.new('packages')
49+
tmpfile.close
50+
fields = %w[
51+
Architecture Conflicts Breaks Depends Enhances Essential Installed-Size Origin Package
52+
Pre-Depends Priority Provides Recommends Replace Section Status Suggests Version
53+
binary:Package binary:Summary db:Status-Abbrev db:Status-Want db:Status-Status db:Status-Eflag
54+
source:Package source:Version
55+
]
56+
field_fmt = fields.map{|f| "${#{f}}"}.join("\\t") + "\\n"
57+
sh %Q[docker run --rm #{tag} dpkg-query -f '#{field_fmt}' -W > #{tmpfile.path}], :verbose => false
58+
packages = File.readlines(tmpfile.path).map(&:chomp).map{|row| Hash[fields.zip(row.split("\t"))]}
59+
File.open(t.name, "w") do |fh|
60+
fh << JSON.pretty_generate(packages)
61+
end
62+
end
63+
64+
desc 'update README.md'
65+
file 'README.md' => ['README.md.erb', 'debian-packages.json'] do |t|
66+
packages = JSON.parse(File.read('debian-packages.json'))
67+
File.open(t.name, "w") do |fh|
68+
fh << ERB.new(File.read('README.md.erb'), trim_mode: '-').result(binding)
69+
end
70+
end
71+

deps.dot

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ digraph deps {
1414
baseimage_buster [label = "minimum2scp/baseimage-buster"];
1515
baseimage_stretch [label = "minimum2scp/baseimage-stretch"];
1616
debian [label = "minimum2scp/debian"];
17+
debian_bookworm [label = "minimum2scp/debian-bookworm"];
1718
debian_bullseye [label = "minimum2scp/debian-bullseye"];
1819
debian_buster [label = "minimum2scp/debian-buster"];
1920
debian_stretch [label = "minimum2scp/debian-stretch"];

0 commit comments

Comments
 (0)