Skip to content

Commit

Permalink
Swapping version to git hash for cachbusting (#22)
Browse files Browse the repository at this point in the history
Co-authored-by: Aurora Walker <[email protected]>
  • Loading branch information
aurorawalker and Aurora Walker authored Mar 8, 2021
1 parent 2a47418 commit 9f27362
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ jobs:
ECR_REPOSITORY: ${{ steps.get-repository.outputs.repository }}
IMAGE_TAG: ${{ steps.get-version.outputs.version }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker build --build-arg APP_VERSION=$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
FROM node:10.19-alpine AS build

ARG APP_VERSION
ENV APP_VERSION=$APP_VERSION

COPY . .
RUN npm ci
RUN npm run build
Expand Down
1 change: 1 addition & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/sh

# This APP_VERSION is set dyanamically at run time, and is not the same as in release.yaml which sets it on the build
APP_VERSION=${APP_VERSION:-undefined}

cat > /etc/nginx/nginx.conf <<EOF
Expand Down
6 changes: 3 additions & 3 deletions src/utils/engine-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { streamAll } from "../io/websocket";
import { makeQueryString, httpToWsProtocol, join } from "./url";
import { loadSvgs, getSvg, svgExists } from "./inline-svg";
import { isLastFrameOfGame } from "./game-state";
import { version } from "../../package.json";

const DEFAULT_SNAKE_HEAD = "default";
const DEFAULT_SNAKE_TAIL = "default";
const APP_VERSION = process.env.APP_VERSION;

async function get(url, query) {
const response = await fetch(url + makeQueryString(query));
Expand Down Expand Up @@ -92,8 +92,8 @@ function isIllegalSvgPath(nameOrPath) {
}

function svgUrlFromName(base, relative) {
//appending the app version allows for cache busting on deploy
const extension = ".svg?board_version=" + version;
//appending the image tag of this version allows for cache busting on deploy
const extension = ".svg?boardVersion=" + APP_VERSION;
return join("https://media.battlesnake.com", base, relative) + extension;
}

Expand Down

0 comments on commit 9f27362

Please sign in to comment.