diff --git a/Dockerfile b/Dockerfile index 49039a5..2cb3201 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ FROM alpine:latest +ARG VERSION="" RUN apk update && apk upgrade @@ -12,7 +13,7 @@ ADD . /service WORKDIR /service/utility -RUN ./install-oatpp-modules.sh Release +RUN ./install-oatpp-modules.sh Release $VERSION WORKDIR /service/build diff --git a/README.md b/README.md index 3cd69c2..cee04ac 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,13 @@ $ docker build -t example-crud . $ docker run -p 8000:8000 -t example-crud ``` +**Note**: If you build an earlier release, you must specify the release version as an +build argument, as shown below. +``` +$ docker build -t example-crud --build-arg VERSION=1.3.0-latest . +$ docker run -p 8000:8000 -t example-crud +``` + --- ### Endpoints diff --git a/utility/install-oatpp-modules.sh b/utility/install-oatpp-modules.sh index ef0ba96..3c2f3de 100755 --- a/utility/install-oatpp-modules.sh +++ b/utility/install-oatpp-modules.sh @@ -1,6 +1,7 @@ #!/bin/sh BUILD_TYPE=$1 +VERSION=$2 if [ -z "$BUILD_TYPE" ]; then BUILD_TYPE="Debug" @@ -18,15 +19,22 @@ function install_module () { BUILD_TYPE=$1 MODULE_NAME=$2 +VERSION=$3 NPROC=$(nproc) if [ -z "$NPROC" ]; then NPROC=1 fi -echo "\n\nINSTALLING MODULE '$MODULE_NAME' ($BUILD_TYPE) using $NPROC threads ...\n\n" -git clone --depth=1 https://github.com/oatpp/$MODULE_NAME +if [ -z "$3" ]; then + echo "\n\nINSTALLING MODULE '$MODULE_NAME' ($BUILD_TYPE) using $NPROC threads ...\n\n" + git clone --depth=1 https://github.com/oatpp/$MODULE_NAME +else + echo "\n\nINSTALLING MODULE '$MODULE_NAME $VERSION' ($BUILD_TYPE) using $NPROC threads ...\n\n" + git clone --depth=1 https://github.com/oatpp/$MODULE_NAME --branch $VERSION +fi + cd $MODULE_NAME mkdir build @@ -44,9 +52,9 @@ cd ../../ ########################################################## -install_module $BUILD_TYPE oatpp -install_module $BUILD_TYPE oatpp-swagger -install_module $BUILD_TYPE oatpp-sqlite +install_module $BUILD_TYPE oatpp $VERSION +install_module $BUILD_TYPE oatpp-swagger $VERSION +install_module $BUILD_TYPE oatpp-sqlite $VERSION cd ../ rm -rf tmp