From 924383ccc8106a3c3a1614c249d4b1ce8e9f8513 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Fri, 16 Aug 2019 19:42:39 +0200 Subject: [PATCH] Updated docker image build so that it sets shlink's version --- .dockerignore | 1 + .gitignore | 1 + Dockerfile | 3 +++ hooks/build | 10 ++++++++++ 4 files changed, 15 insertions(+) create mode 100755 hooks/build diff --git a/.dockerignore b/.dockerignore index 56849556..7c730c69 100644 --- a/.dockerignore +++ b/.dockerignore @@ -21,3 +21,4 @@ phpstan.neon **/test* build* .github +hooks diff --git a/.gitignore b/.gitignore index f01b1741..7b14364c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .idea build +!hooks/build composer.lock composer.phar vendor/ diff --git a/Dockerfile b/Dockerfile index 0d3cc037..829be575 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,8 @@ FROM php:7.3.8-cli-alpine3.10 LABEL maintainer="Alejandro Celaya " +ARG SHLINK_VERSION=1.18.1 +ENV SHLINK_VERSION ${SHLINK_VERSION} ENV SWOOLE_VERSION 4.3.3 ENV COMPOSER_VERSION 1.9.0 @@ -39,6 +41,7 @@ RUN rm -rf ./docker && \ # Add shlink to the path to ease running it after container is created RUN ln -s /etc/shlink/bin/cli /usr/local/bin/shlink +RUN sed -i "s/%SHLINK_VERSION%/${SHLINK_VERSION}/g" config/autoload/app_options.global.php # Expose swoole port EXPOSE 8080 diff --git a/hooks/build b/hooks/build new file mode 100755 index 00000000..efabd3d7 --- /dev/null +++ b/hooks/build @@ -0,0 +1,10 @@ +#!/bin/bash +set -ex + +if [[ ${SOURCE_BRANCH} == 'master' ]]; then + SHLINK_RELEASE='latest' +else + SHLINK_RELEASE=${SOURCE_BRANCH} +fi + +docker build --build-arg SHLINK_VERSION=${SHLINK_RELEASE#?} -t ${IMAGE_NAME} .