Skip to content

Commit 8f241c7

Browse files
committed
Pulling SOURCE_VERSION in Dockerfile
1 parent 652119f commit 8f241c7

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
VERSION export-subst

Dockerfile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@ COPY .npmrc ./
55
COPY package.json package-lock.json ./
66
RUN npm install && npm cache clean --force
77
COPY . .
8-
RUN npm run build
8+
RUN \
9+
if [ -d .git ]; then \
10+
export SOURCE_VERSION=$(git rev-parse --short HEAD); \
11+
else \
12+
export SOURCE_VERSION=$(head -n 1 VERSION); \
13+
fi && \
14+
echo "SOURCE_VERSION: $SOURCE_VERSION" && \
15+
npm run build
916

1017

1118
FROM node:18-alpine AS runtime

VERSION

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
$Format:%h$
2+
commit: $Format:%H$
3+
date: $Format:%cI$
4+
refs: $Format:%d$

0 commit comments

Comments
 (0)