Added scripts to pass version when building docker image

This commit is contained in:
Alejandro Celaya 2020-03-05 13:37:07 +01:00
parent 8e1c6908c6
commit 4a6dd66ecd
3 changed files with 15 additions and 2 deletions

View file

@ -1,6 +1,8 @@
FROM node:12.14.1-alpine as node FROM node:12.14.1-alpine as node
COPY . /shlink-web-client COPY . /shlink-web-client
RUN cd /shlink-web-client && npm install && npm run build ARG VERSION="latest"
ENV VERSION ${VERSION}
RUN cd /shlink-web-client && npm install && npm run build -- ${VERSION} --no-dist
FROM nginx:1.17.7-alpine FROM nginx:1.17.7-alpine
LABEL maintainer="Alejandro Celaya <alejandro@alejandrocelaya.com>" LABEL maintainer="Alejandro Celaya <alejandro@alejandrocelaya.com>"

10
hooks/build Executable file
View file

@ -0,0 +1,10 @@
#!/bin/bash
set -ex
if [[ ${SOURCE_BRANCH} == 'master' ]]; then
SHLINK_WEB_CLIENT_RELEASE='latest'
else
SHLINK_WEB_CLIENT_RELEASE=${SOURCE_BRANCH#?}
fi
docker build --build-arg VERSION=${SHLINK_WEB_CLIENT_RELEASE} -t ${IMAGE_NAME} .

View file

@ -44,6 +44,7 @@ if (!checkRequiredFiles([ paths.appHtml, paths.appIndexJs ])) {
const argvSliceStart = 2; const argvSliceStart = 2;
const argv = process.argv.slice(argvSliceStart); const argv = process.argv.slice(argvSliceStart);
const writeStatsJson = argv.indexOf('--stats') !== -1; const writeStatsJson = argv.indexOf('--stats') !== -1;
const withoutDist = argv.indexOf('--no-dist') !== -1;
const { version, hasVersion } = getVersionFromArgs(argv); const { version, hasVersion } = getVersionFromArgs(argv);
// Generate configuration // Generate configuration
@ -102,7 +103,7 @@ checkBrowsers(paths.appPath, isInteractive)
process.exit(1); process.exit(1);
} }
) )
.then(() => hasVersion && zipDist(version)) .then(() => hasVersion && !withoutDist && zipDist(version))
.catch((err) => { .catch((err) => {
if (err && err.message) { if (err && err.message) {
console.log(err.message); console.log(err.message);