Skip to content

Commit

Permalink
Fix upgrade scripts when using docker
Browse files Browse the repository at this point in the history
  • Loading branch information
henriksommerfeld committed Mar 2, 2024
1 parent 873717d commit abc8993
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 20 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
FROM mcr.microsoft.com/playwright:v1.41.2 as playwright

FROM playwright as playwright-hugo
RUN wget -O /tmp/hugo.tar.gz https://github.com/gohugoio/hugo/releases/download/v0.123.3/hugo_extended_0.123.3_Linux-64bit.tar.gz
ARG HUGO_VERSION="0.123.7"
RUN wget --max-redirect=1 -O /tmp/hugo.tar.gz "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_Linux-64bit.tar.gz"
RUN tar zxvf /tmp/hugo.tar.gz -C /tmp/
RUN mv /tmp/hugo /usr/bin/

Expand Down
4 changes: 2 additions & 2 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[build.environment]
HUGO_VERSION = "0.123.3"
NODE_ENV = "production"
HUGO_VERSION="0.123.7"
NODE_ENV="production"
7 changes: 4 additions & 3 deletions scripts/compose-hugo.dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
FROM node:20.11.0-alpine as base
RUN apk add --update tzdata rsync openssh gcompat libc6-compat libstdc++
FROM node:20.11.1-alpine as base
RUN apk add --update tzdata rsync openssh gcompat libc6-compat libstdc++ wget

FROM base as hugo
RUN wget -O /tmp/hugo.tar.gz https://github.com/gohugoio/hugo/releases/download/v0.122.0/hugo_extended_0.122.0_Linux-64bit.tar.gz
ARG HUGO_VERSION="0.123.7"
RUN wget --max-redirect=1 -O /tmp/hugo.tar.gz "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_Linux-64bit.tar.gz"
RUN tar zxvf /tmp/hugo.tar.gz -C /tmp/
RUN mv /tmp/hugo /usr/bin/
RUN hugo version
Expand Down
2 changes: 1 addition & 1 deletion scripts/compose-hugo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
uid=$(stat -c '%u' /app/package.json)

if [[ "$uid" != "0" ]]; then
chown -R "$uid:$uid" /home /app/node_modules /app/dist
chown -R "$uid:$uid" /home /app/node_modules /app/resources
if ! getent passwd "$uid"; then
adduser -D -u "$uid" app
su - app
Expand Down
18 changes: 5 additions & 13 deletions scripts/upgrade-hugo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ else
exit 1
fi

netlify_regex="s/HUGO_VERSION = \"[0-9]+\.[0-9]+\.[0-9]+\"/HUGO_VERSION = \"$version\"/g"
dockerfile_regex1="s/hugo\/releases\/download\/v[0-9]+\.[0-9]+\.[0-9]+/hugo\/releases\/download\/v$version/g"
dockerfile_regex2="s/hugo_extended_[0-9]+\.[0-9]+\.[0-9]+/hugo_extended_$version/g"
regex="s/HUGO_VERSION=\"[0-9]+\.[0-9]+\.[0-9]+\"/HUGO_VERSION=\"$version\"/g"

files=(
netlify.toml
Dockerfile
./scripts/compose-hugo.dockerfile
)

cleanup() {
Expand All @@ -32,16 +31,9 @@ cleanup() {
trap cleanup EXIT

for x in "${files[@]}"; do
sed -E "$netlify_regex" "$x" >"$x.upg"
sed -E "$regex" "$x" >"$x.upg"
mv "$x.upg" "$x"
done

for x in "${files[@]}"; do
sed -E "$dockerfile_regex1" "$x" >"$x.upg"
mv "$x.upg" "$x"
done

for x in "${files[@]}"; do
sed -E "$dockerfile_regex2" "$x" >"$x.upg"
mv "$x.upg" "$x"
done
echo "Rebuilding docker image for docker-compose"
docker compose build
3 changes: 3 additions & 0 deletions scripts/upgrade-node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ sed -E "$regex" "$file" >"$file.upg"
mv "$file.upg" "$file"

printf "v$version" >.nvmrc

echo "Rebuilding docker image for docker-compose"
docker compose build

0 comments on commit abc8993

Please sign in to comment.