VuePress Build and Git
Problem
VuePress default theme is full of great features: Navbar, Sidebar, a built-in search box, etc. One other neat feature is Last Updated.
From VuePress Last Updated docs:
The
themeConfig.lastUpdated
option allows you to get the UNIX timestamp(ms) of each file's last git commit, and it will also display at the bottom of each page in an appropriate format.
This feature is really useful to see if the page content has been updated recently.
I decided lately to add this option to my website. However, there was an error in Bitbucket Pipelines when I pushed that option to master.
After some reflexion and some research, I realized that the build couldn't succeed, because the docker image doesn't have Git installed. Thus, VuePress couldn't get the last Git commit timestamp.
Solution
The solution was simply to update the Dockerfile for my build image to install Git.
My Docker image is based from Alpine Linux. The command to add Git on this environment is pretty straigforward: apk add git
. It results in the following Dockerfile.
FROM node:8.12-alpine
RUN apk add git
RUN npm install -g vuepress@0.14.4
RUN npm install -g firebase-tools@5.0.1
You can find the image on DockerHub: dspringuel/vuepress-firebase-git.
