Skip to content

Commit 45e77d4

Browse files
committed
Version-stamp frontend
1 parent 5b54e1e commit 45e77d4

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

.github/workflows/build-and-trigger-deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
- name: Build Docker image
4848
run: >
4949
VERSION=$(cat version/version);
50-
DOCKER_BUILDKIT=1 docker build . --tag "${IMAGEID}:${VERSION}-amd64" &&
50+
DOCKER_BUILDKIT=1 docker build . --tag "${IMAGEID}:${VERSION}-amd64" --build-arg "VERSION=${VERSION}" &&
5151
docker save "${IMAGEID}:${VERSION}-amd64" | gzip > image.tar.gz
5252
- uses: actions/[email protected]
5353
with: { name: docker-image-amd64, path: image.tar.gz }

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#
77
#######################################################################
88
FROM node:10-alpine AS luajit.me.builder
9+
ARG VERSION
910

1011
# As of Docker 19.03.5, DOCKER_BUILDKIT=1 and userns_remap enabled,
1112
# if a directory was created during COPY, it won't be writable in RUN.
@@ -21,7 +22,7 @@ COPY webpack.config.js /root/luajit.me
2122
COPY client /root/luajit.me/client
2223
COPY server/targets.js /root/luajit.me/server/
2324
RUN cd /root/luajit.me && npm config set unsafe-perm true \
24-
&& npm install
25+
&& VERSION=$VERSION npm install
2526

2627
COPY server /root/luajit.me/server
2728

client/entry.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
window.version = __VERSION__;
2+
13
import {debounce} from "./debounce";
24

35
import React from "react";

webpack.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ module.exports = {
7575
]
7676
},
7777
plugins: [
78+
new webpack.DefinePlugin({
79+
__VERSION__: JSON.stringify(process.env.VERSION || 'VERSIONUNKNOWN')
80+
}),
7881
// contenthash presumably depends on the module id, hence stable
7982
// module ids are paramount
8083
new webpack.HashedModuleIdsPlugin({

0 commit comments

Comments
 (0)