Migrating website build infra
• Mark Eschbach
Welp, after an update to the device Jenkins runs on, this website build process finally broke. Time to duct tape it back together on the new infra. I am interested in experimenting with some other tech and possibly better segmenting the site in the future. For today I want to get this back online since it broke in September.
This website has its origins back in the late 90s. It has seen a lot of technology, including being subject to some not so great experiments of mine over the years (XSLT!). As of right now I know I am using the following tech to generate the sites static content:
- PHP is a long time hold over from my third iteration mainly used for templating
- Jekyll since it really made life easier to keep a blog in a reasonable format.
- Node for generating things like the most recent entries on the right.
Tekton runs things in containers, so I will need to role my own since I doubt I will find one with all of these on the correct version. Would be scared if I did! Let us see what a basic Dockerfile sketch will do for us.
FROM ubuntu:23.04
RUN apt-get update && apt-get -y install php nodejs ruby
RUN php --version
RUN node --version
RUN ruby --version
Ran into a problem with interactive prompts being waited upon for configuring timezones. To resolve that issue add the
following two lines. TZ
sets the preferred timezone for the applications. DEBIAN_FRONTEND=noninteractive
tells
apt
do not prompt for user input.
ENV TZ="UTC"
ENV DEBIAN_FRONTEND=noninteractive
Alright, this gives us a container with reasonable versioning info. Next up what does a build look like when scripted for development?
#!/bin/bash
(cd .cd/builder && docker build --tag website-meschbach-builder:dev .cd/builder)
docker build --tag website-meschbach:dev .
With a docker file like so:
FROM website-meschbach-builder:dev as builder
COPY . /source
WORKDIR /source
RUN ./generate.sh
FROM nginx:latest as final
COPY --from=builder target /usr/share/nginx/html
Turns out I needed the following software installed too:
make
– Allowed for rapid development since a single command would only build new things.npm
– Not installed withnodejs
throughapt
I guess.bundle
– Not installed withruby
:-/. Fixed by installruby-full
I guess I use bower
somewhere in there. I should really review that at some point :-D Ah, it’s used with revealjs
.
At least it has the decency to tell me to not run it as root >.< . To work around this issue I changed the builder
image to add the following:
RUN mkdir -p /nobody-home && chown -R nobody /nobody-home
ENV HOME /nobody-home
ENV GEM_HOME /nobody-home/.gem
USER nobody
Then in the actual build:
COPY --chown=nobody:nobody . /source
Gems were out of date. So I spun up a container like docker run -v $PWD:/source -it website-meschbach-builder:dev /bin/bash
and ran the following:
bundle update
bundle install
This needed to happen in both my tools directory which installs jekyll
and within the jekyll
directory itself.