Skip to content

Commit 848edd5

Browse files
committed
cachebust-apps
1 parent 1cb5219 commit 848edd5

File tree

6 files changed

+23
-7
lines changed

6 files changed

+23
-7
lines changed

.github/workflows/build-from-dotfiles.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ jobs:
2727
uses: docker/build-push-action@v4
2828
with:
2929
build-args: |
30+
CACHEBUST_DOTFILES=${{ github.sha }}
3031
DESKTOP_ENVIRONMENT_USER=${{ env.REPOSITORY_OWNER }}
3132
DESKTOP_ENVIRONMENT_GITHUB_USER=${{ env.REPOSITORY_OWNER }}
32-
DOTFILES_CACHEBUST=${{ github.sha }}
3333
cache-from: type=gha
3434
cache-to: type=gha,mode=max
3535
file: docker/Dockerfile

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.build-exit-code
22
.build-exit-time
3-
.dotfiles-cachebust
3+
.cachebust-apps
4+
.cachebust-dotfiles

docker/Dockerfile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ RUN apt-get update -qq && \
152152
zsh && \
153153
apt-file update
154154

155+
# If the CACHEBUST_APPS build arg is supplied, rebuild from apps onwards
156+
ARG CACHEBUST_APPS
157+
RUN echo 'Building from apps onwards...'
158+
155159
# Install rust
156160
RUN apt-get update -qq && \
157161
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain nightly --no-modify-path --profile minimal && \
@@ -581,9 +585,9 @@ WORKDIR $HOME
581585
# Clone the desktop environment
582586
RUN git clone https://github.com/sabrehagen/desktop-environment /opt/desktop-environment
583587

584-
# If the DOTFILES_CACHEBUST build arg is supplied, rebuild from static dotfiles onwards
585-
ARG DOTFILES_CACHEBUST
586-
RUN DOTFILES_CACHEBUST=$DOTFILES_CACHEBUST echo 'Building from dotfiles...'
588+
# If the CACHEBUST_DOTFILES build arg is supplied, rebuild from static dotfiles onwards
589+
ARG CACHEBUST_DOTFILES
590+
RUN echo 'Building from dotfiles...'
587591

588592
# Clone user dotfiles or fallback to sabrehagen dotfiles
589593
RUN vcsh clone https://github.com/sabrehagen/dotfiles

docker/scripts/build-apps.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
REPO_ROOT=$(dirname $(readlink -f $0))/../..
2+
3+
# Export desktop environment shell configuration
4+
eval "$($REPO_ROOT/docker/scripts/environment.sh)"
5+
6+
# Set the cachebust file to rebuild from apps onwards
7+
CACHEBUST_APPS=$(date +%s > $REPO_ROOT/.cachebust-apps)
8+
9+
# Rebuild the desktop environment
10+
$REPO_ROOT/docker/scripts/build.sh

docker/scripts/build-dotfiles.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ REPO_ROOT=$(dirname $(readlink -f $0))/../..
44
eval "$($REPO_ROOT/docker/scripts/environment.sh)"
55

66
# Set the cachebust file to rebuild from dotfiles onwards
7-
DOTFILES_CACHEBUST=$(date +%s > $REPO_ROOT/.dotfiles-cachebust)
7+
CACHEBUST_DOTFILES=$(date +%s > $REPO_ROOT/.cachebust-dotfiles)
88

99
# Rebuild the desktop environment
1010
$REPO_ROOT/docker/scripts/build.sh

docker/scripts/build.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ eval "$($REPO_ROOT/docker/scripts/environment.sh)"
77
DESKTOP_ENVIRONMENT_HOST_USER_PASSWORD=$(sudo cat /etc/shadow | grep $DESKTOP_ENVIRONMENT_USER | cut -d: -f2)
88

99
docker build \
10+
--build-arg CACHEBUST_APPS=$(cat $REPO_ROOT/.cachebust-apps 2>/dev/null) \
11+
--build-arg CACHEBUST_DOTFILES=$(cat $REPO_ROOT/.cachebust-dotfiles 2>/dev/null) \
1012
--build-arg DESKTOP_ENVIRONMENT_CONTAINER_GIT_SHA=$(git --git-dir $REPO_ROOT/.git rev-parse HEAD | cut -b 1-7) \
1113
--build-arg DESKTOP_ENVIRONMENT_CONTAINER_BUILD_DATE=$(date +%s) \
1214
--build-arg DESKTOP_ENVIRONMENT_CONTAINER_IMAGE_NAME="$DESKTOP_ENVIRONMENT_REGISTRY/$DESKTOP_ENVIRONMENT_CONTAINER_IMAGE" \
1315
--build-arg DESKTOP_ENVIRONMENT_HOST_USER_PASSWORD="$DESKTOP_ENVIRONMENT_HOST_USER_PASSWORD" \
1416
--build-arg DESKTOP_ENVIRONMENT_USER="$DESKTOP_ENVIRONMENT_USER" \
1517
--build-arg DESKTOP_ENVIRONMENT_GITHUB_USER="$DESKTOP_ENVIRONMENT_GITHUB_USER" \
16-
--build-arg DOTFILES_CACHEBUST=$(cat $REPO_ROOT/.dotfiles-cachebust 2>/dev/null) \
1718
--file $REPO_ROOT/docker/Dockerfile \
1819
--tag $DESKTOP_ENVIRONMENT_REGISTRY/$DESKTOP_ENVIRONMENT_CONTAINER_IMAGE:$DESKTOP_ENVIRONMENT_CONTAINER_TAG \
1920
--tag $DESKTOP_ENVIRONMENT_REGISTRY/$DESKTOP_ENVIRONMENT_CONTAINER_IMAGE:latest \

0 commit comments

Comments
 (0)