Skip to content

Commit 726bf35

Browse files
committed
Fix Docker build for develop and publish a /version file
Fixes element-hq#10426
1 parent b4829fd commit 726bf35

4 files changed

Lines changed: 34 additions & 1 deletion

File tree

‎.dockerignore‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Exclude a bunch of stuff which can make the build context a larger than it needs to be
2-
.git/
32
test/
43
webapp/
54
lib/

‎Dockerfile‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ RUN yarn build
2121
# Copy the config now so that we don't create another layer in the app image
2222
RUN cp /src/config.sample.json /src/webapp/config.json
2323

24+
# Ensure we populate the version file
25+
RUN dos2unix /src/scripts/docker-write-version.sh && sh /src/scripts/docker-write-version.sh
26+
2427

2528
# App
2629
FROM nginx:alpine

‎scripts/docker-link-repos.sh‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
set -ex
44

5+
# Automatically link to develop if we're building develop, but only if the caller
6+
# hasn't asked us to build something else
7+
BRANCH=$(git rev-parse --abbrev-ref HEAD)
8+
if [ $USE_CUSTOM_SDKS == false ] && [ $BRANCH == 'develop' ]
9+
then
10+
echo "using develop dependencies for react-sdk and js-sdk"
11+
USE_CUSTOM_SDKS=true
12+
JS_SDK_BRANCH='develop'
13+
REACT_SDK_BRANCH='develop'
14+
fi
15+
516
if [ $USE_CUSTOM_SDKS == false ]
617
then
718
echo "skipping react-sdk and js-sdk installs: USE_CUSTOM_SDKS is false"

‎scripts/docker-write-version.sh‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
3+
set -ex
4+
5+
TAG=$(git describe --dirty --tags)
6+
BRANCH=$(git rev-parse --abbrev-ref HEAD)
7+
DIST_VERSION=$TAG
8+
9+
# If the branch comes out as HEAD then we're probably checked out to a tag, so if the thing is *not*
10+
# coming out as HEAD then we're on a branch. When we're on a branch, we want to resolve ourselves to
11+
# a few SHAs rather than a version.
12+
if [ $BRANCH != 'HEAD' ]
13+
then
14+
REACT_SHA=$(cd node_modules/matrix-react-sdk; git rev-parse --short=12 HEAD)
15+
JSSDK_SHA=$(cd node_modules/matrix-js-sdk; git rev-parse --short=12 HEAD)
16+
VECTOR_SHA=$(git rev-parse --short=12 HEAD) # use the ACTUAL SHA rather than assume develop
17+
DIST_VERSION=$VECTOR_SHA-react-$REACT_SHA-js-$JSSDK_SHA
18+
fi
19+
20+
echo $DIST_VERSION > /src/webapp/version

0 commit comments

Comments
 (0)