add rake docker for consistent build with Docker

This commit is contained in:
Suraj N. Kurapati 2022-10-06 07:12:29 -07:00
parent 3a767955f8
commit 2201fc4a9e
3 changed files with 56 additions and 6 deletions

View File

@ -22,7 +22,3 @@ WORKDIR /opt
COPY Gemfile .
COPY Gemfile.lock .
RUN bundler install
# RUN vncserver -SecurityTypes None \
# && export DISPLAY=$(ls -t ~/.vnc/*.pid | grep -oPm1 ':\d+') \
# && bundler exec rake clobber default
# COPY /opt .

View File

@ -250,20 +250,28 @@ fonts when run inside a shell that is attached to [the URxvt terminal][4].
Building
--------
### Docker method
If you have Docker available, use the convenient `rake docker` command:
rake docker
### Manual method
You can build the Tamzen fonts for yourself by running these commands:
bundle exec rake # build things only when necessary
bundle exec rake clobber # destroy everything that we built
bundle exec rake clobber default # rebuild everything from scratch
### Requirements
But first, you'll need to install these dependencies (assuming Debian):
# NOTE: the "xfonts-utils" package provides both bdftopcf(1) and fonttosfnt(1)
sudo apt-get install ruby git imagemagick xfonts-utils bdf2psf default-jre gbdfed
gem install bundler
bundle install
Requirements for [bitmap-font-patcher][6]:
Similarly, if you've opted to use [bitmap-font-patcher][6] integration:
sudo apt-get install python python-fontforge python-pip python-dev libfreetype6-dev
pip install --user bdflib

View File

@ -1,4 +1,5 @@
require 'tempfile'
require 'shellwords'
require 'rake/clean'
task 'default' => %w[
@ -10,6 +11,51 @@ task 'default' => %w[
.screenshots
]
#-----------------------------------------------------------------------------
# docker
#-----------------------------------------------------------------------------
DOCKER_IMAGE = 'tamzen-font'
task :docker => 'docker:container'
task 'docker:image' => %w[ Dockerfile Gemfile Gemfile.lock ] do |t|
sh "tar -cf- #{t.prerequisites.shelljoin} | docker build -t #{DOCKER_IMAGE} -"
end
task 'docker:container' => 'docker:image' do
container = `
docker create \
-v #{Dir.pwd.shellescape}:/run/input #{DOCKER_IMAGE} \
sleep infinity
`.chomp
raise unless $?.success?
begin
sh "docker start #{container}"
sh "docker exec #{container} rake -f /run/input/Rakefile docker:exec"
sh "docker cp #{container}:/opt _build"
ensure
sh "docker rm -f #{container}"
end
sh "rsync -auv _build/ ./ --exclude=_build"
end
CLOBBER.include %w[ _build ]
task 'docker:exec' do
raise unless Dir.pwd == '/opt'
sh "cp -pRT /run/input ."
ENV['DISPLAY'] = ':1'
sh "vncserver -SecurityTypes None $DISPLAY"
begin
sh "bundle exec rake clobber default"
ensure
system "vncserver -kill $DISPLAY" # exits nonzero
end
end
#-----------------------------------------------------------------------------
# bitmap
#-----------------------------------------------------------------------------