diff --git a/cicd/dockerfiles/build.dockerfile b/cicd/dockerfiles/webserver/build.dockerfile similarity index 100% rename from cicd/dockerfiles/build.dockerfile rename to cicd/dockerfiles/webserver/build.dockerfile diff --git a/cicd/dockerfiles/debug.dockerfile b/cicd/dockerfiles/webserver/debug.dockerfile similarity index 100% rename from cicd/dockerfiles/debug.dockerfile rename to cicd/dockerfiles/webserver/debug.dockerfile diff --git a/cicd/dockerfiles/test.dockerfile b/cicd/dockerfiles/webserver/test.dockerfile similarity index 100% rename from cicd/dockerfiles/test.dockerfile rename to cicd/dockerfiles/webserver/test.dockerfile diff --git a/cicd/dockerfiles/worker/build.dockerfile b/cicd/dockerfiles/worker/build.dockerfile new file mode 100644 index 0000000..8e6611e --- /dev/null +++ b/cicd/dockerfiles/worker/build.dockerfile @@ -0,0 +1,37 @@ +# Use a PHP runtime as a parent image +FROM §FRAMEWORK_REPOSITORY§/§FRAMEWORK_IMAGE§:§FRAMEWORK_VERSION§-§FRAMEWORK_TYPE§ + +# Set the working directory to /app +WORKDIR /§PROJECT_BUILDNAME§ + +# Install GD (required by mpdf) +RUN apt-get update && \ + apt-get install -yq --no-install-recommends libpng-dev zlib1g-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* +RUN docker-php-ext-install gd + +# Install Memcached +RUN apt-get update && apt-get install -y libmemcached-dev \ + && pecl install memcached-3.1.5 \ + && docker-php-ext-enable memcached + +# Copy the current directory contents into the container at /app +COPY ./app /§PROJECT_BUILDNAME§ + +COPY ./version /§PROJECT_BUILDNAME§ + +COPY ./config /§PROJECT_BUILDNAME§ + +COPY ./install /§PROJECT_BUILDNAME§ + +RUN chmod 744 /§PROJECT_BUILDNAME§/install + +RUN /§PROJECT_BUILDNAME§/install + + +ENTRYPOINT ["§PROJECT_BUILDNAME§-entrypoint"] + +# Make port 80 available to the world outside this container +EXPOSE 80 + diff --git a/cicd/dockerfiles/worker/debug.dockerfile b/cicd/dockerfiles/worker/debug.dockerfile new file mode 100644 index 0000000..aecc05d --- /dev/null +++ b/cicd/dockerfiles/worker/debug.dockerfile @@ -0,0 +1,35 @@ +# Use a PHP runtime as a parent image +FROM §FRAMEWORK_REPOSITORY§/§FRAMEWORK_IMAGE§:§FRAMEWORK_VERSION§-§FRAMEWORK_TYPE§ + +# Set the working directory to /app +WORKDIR /§PROJECT_BUILDNAME§ + +# Install XDebug +RUN pecl install xdebug | tail -n 1 | awk -F"\"" '{print $2}' > /usr/local/etc/php/conf.d/xdebug.ini +RUN echo "\n\n[XDebug]\nxdebug.mode=debug\nxdebug.start_with_request=yes\nxdebug.client_host = §DEBUG_REMOTE_IP§\nxdebug.client_port = §DEBUG_REMOTE_PORT§\n" >> /usr/local/etc/php/conf.d/xdebug.ini + +# Install Memcached +RUN apt-get update && apt-get install -y libmemcached-dev zlib1g-dev \ + && pecl install memcached-3.1.5 \ + && docker-php-ext-enable memcached + +# Install SOAP +RUN docker-php-ext-install soap + +# Copy the current directory contents into the container at /app +COPY ./app /§PROJECT_BUILDNAME§ + +COPY ./version /§PROJECT_BUILDNAME§ + +COPY ./config /§PROJECT_BUILDNAME§ + +COPY ./install /§PROJECT_BUILDNAME§ + +RUN chmod 744 /§PROJECT_BUILDNAME§/install + +RUN /§PROJECT_BUILDNAME§/install + +ENTRYPOINT ["§PROJECT_BUILDNAME§-entrypoint"] + +# Make port 80 available to the world outside this container +EXPOSE 80 diff --git a/cicd/dockerfiles/worker/test.dockerfile b/cicd/dockerfiles/worker/test.dockerfile new file mode 100644 index 0000000..994734f --- /dev/null +++ b/cicd/dockerfiles/worker/test.dockerfile @@ -0,0 +1,15 @@ +FROM §FRAMEWORK_REPOSITORY§/§FRAMEWORK_IMAGE§:§FRAMEWORK_VERSION§-§FRAMEWORK_TYPE§-unit + +WORKDIR /§PROJECT_BUILDNAME§ +COPY ./app /§PROJECT_BUILDNAME§ +COPY ./test /test§PROJECT_BUILDNAME§ +COPY ./version /§PROJECT_BUILDNAME§ +COPY ./config /§PROJECT_BUILDNAME§ +COPY ./test/install /§PROJECT_BUILDNAME§ + +RUN chmod 744 /§PROJECT_BUILDNAME§/install + +RUN /§PROJECT_BUILDNAME§/install + +ENTRYPOINT ["/usr/local/bin/phpunit"] +CMD ["--help"] diff --git a/scripts/build.sh b/scripts/build.sh index e392855..0341b5a 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -15,9 +15,10 @@ source "$DIR/../config" source "$DIR/libs.sh" usage() { - echo "Usage: $0 [-h] [-v] [-t: version] [image type, see below] " 1>&2; + echo "Usage: $0 [-h] [-v] [-t: version] -I [image type, see below] " 1>&2; echo "This script builds framework docker images, the following options are available:" 1>&2; echo " -h: This message" 1>&2; + echo " -I: Image (webserver or worker)" 1>&2; echo " Image types (at least one, otherwise the script does nothing)" 1>&2; echo " -a: All, same as ub" 1>&2; echo " -u: Unit" 1>&2; @@ -33,9 +34,13 @@ UNIT_MODE=0 DEBUG_MODE=0 TAG="local" +TYPE="webserver" -while getopts "t:hvaubd" o; do +while getopts "I:t:hvaubd" o; do case "${o}" in + I) + TYPE="${OPTARG}" + ;; b) BASE_MODE=1 ;; @@ -66,7 +71,6 @@ while getopts "t:hvaubd" o; do done - cd ".." # STANDARD MODE @@ -78,7 +82,7 @@ if [[ $BASE_MODE -gt 0 ]]; then OPTS+="v" fi - $DIR/generateDockerfile.sh -$OPTS -o $DOCKERFILE + $DIR/generateDockerfile.sh -I "${TYPE}" -$OPTS -o $DOCKERFILE msg "Building project image $TAG" docker build -t $PROJECT_REPOSITORY/$PROJECT_GROUP/$PROJECT_BUILDNAME:$TAG -f $DOCKERFILE . diff --git a/scripts/core.sh b/scripts/core.sh index 38827b4..3ce74f4 100755 --- a/scripts/core.sh +++ b/scripts/core.sh @@ -142,12 +142,16 @@ if [[ $PUBLISH_MODE -eq 1 ]]; then BUILDOPT+="v" VERBOPT="-v" fi - msg "running ./build.sh -$BUILDOPT -t $TAG" - ./build.sh -$BUILDOPT -t $TAG - ./run-unit.sh $VERBOPT -t $TAG + # WEBSERVER + msg "running ./build.sh -I webserver -$BUILDOPT -t $TAG-webserver" + ./build.sh -I webserver -$BUILDOPT -t "$TAG-webserver" - ./publish.sh $VERBOPT -t $TAG + ./run-unit.sh $VERBOPT -t "$TAG-webserver" + + ./publish.sh $VERBOPT -t "$TAG-webserver" + + if [[ $TAG_IMPLICIT -ne 1 ]]; then git tag $TAG diff --git a/scripts/generateDockerfile.sh b/scripts/generateDockerfile.sh index f1b20bc..3db1bc8 100755 --- a/scripts/generateDockerfile.sh +++ b/scripts/generateDockerfile.sh @@ -22,6 +22,7 @@ usage() { echo " -d: Debug" 1>&2; echo " -u: Unit" 1>&2; echo " -b: Base" 1>&2; + echo " -I: Image (webserver or worker)" 1>&2; echo " -i: Config Input File" 1>&2; echo " -o: Output file" 1>&2; echo " -v: Verbose" 1>&2; @@ -36,8 +37,13 @@ DEBUG_MODE=0 UNIT_MODE=0 BASE_MODE=0 -while getopts "i:o:hvdub" o; do +TYPE="webserver" + +while getopts "i:o:I:hvdub" o; do case "${o}" in + I) + TYPE="${OPTARG}" + ;; d) DEBUG_MODE=1 SELECTED_MODES+=1 @@ -88,12 +94,12 @@ if [[ $OUTFILE == "" ]]; then usage fi -STARTING_FILE="../cicd/dockerfiles/build.dockerfile" +STARTING_FILE="../cicd/dockerfiles/${TYPE}/build.dockerfile" if [[ $DEBUG_MODE -eq 1 ]]; then - STARTING_FILE="../cicd/dockerfiles/debug.dockerfile" + STARTING_FILE="../cicd/dockerfiles/${TYPE}/debug.dockerfile" fi if [[ $UNIT_MODE -eq 1 ]]; then - STARTING_FILE="../cicd/dockerfiles/test.dockerfile" + STARTING_FILE="../cicd/dockerfiles/${TYPE}/test.dockerfile" fi msg "Using source file $STARTING_FILE" diff --git a/scripts/latest-ver.sh b/scripts/latest-ver.sh index adb1052..cb0bbbc 100755 --- a/scripts/latest-ver.sh +++ b/scripts/latest-ver.sh @@ -1,3 +1,4 @@ #!/bin/bash +git pull git tag -l --sort=-version:refname | head -n 1 \ No newline at end of file