Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Build Alpine libvips/sharp if not pre-installed
If the pre-compiled version of sharp (an optional dependency) doesn't
install, then build it ourselves. This requires a recent version of
libvips, so install the Alpine 3.15 version.

(This commit upgrades us from Alpine 3.14 to 3.15.)
  • Loading branch information
calroth committed Mar 6, 2022
commit 7fed33bcf9fc23ec8828b7caa19c4d6a5000c9a5
11 changes: 8 additions & 3 deletions 4/alpine/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# https://docs.ghost.org/faq/node-versions/
# https://github.com/nodejs/Release (looking for "LTS")
# https://github.com/TryGhost/Ghost/blob/v4.1.2/package.json#L38
FROM node:14-alpine3.14
FROM node:14-alpine3.15

# grab su-exec for easy step-down from root
RUN apk add --no-cache 'su-exec>=0.2'
Expand Down Expand Up @@ -49,11 +49,16 @@ RUN set -eux; \
cd "$GHOST_INSTALL/current"; \
# scrape the expected version of sqlite3 directly from Ghost itself
sqlite3Version="$(node -p 'require("./package.json").optionalDependencies.sqlite3')"; \
if ! su-exec node yarn add "sqlite3@$sqlite3Version" --force; then \
sharpVersion="$(node -p 'require("./node_modules/@tryghost/image-transform/package.json").optionalDependencies.sharp')"; \
su-exec node yarn add "sqlite3@$sqlite3Version" --force && sqlite3Installed=Y || sqlite3Installed=N; \
su-exec node yarn add "sharp@$sharpVersion" --force && sharpInstalled=Y || sharpInstalled=N; \
if [ "$sqlite3Installed" = "N" ] || [ "$sharpInstalled" = "N" ]; then \
# must be some non-amd64 architecture pre-built binaries aren't published for, so let's install some build deps and do-it-all-over-again
[ "$sharpInstalled" = "N" ] && apk add --no-cache vips; \
apk add --no-cache --virtual .build-deps g++ gcc libc-dev make python2 vips-dev; \
\
npm_config_python='python2' su-exec node yarn add "sqlite3@$sqlite3Version" --force --build-from-source; \
[ "$sqlite3Installed" = "N" ] && npm_config_python='python2' su-exec node yarn add "sqlite3@$sqlite3Version" --force --build-from-source --ignore-optional; \
[ "$sharpInstalled" = "N" ] && ( npm_config_python='python2' npm_config_build_from_source=true su-exec node yarn add "sharp@$sharpVersion" || echo "sharp@$sharpVersion: build failed, continuing..." ); \
\
apk del --no-network .build-deps; \
fi; \
Expand Down