From e6e42ba0ee99ffa6cf5c2f881e83a5b0893e226e Mon Sep 17 00:00:00 2001 From: Armin <armin.co@hs-bochum.de> Date: Fri, 19 Jun 2020 12:33:03 +0200 Subject: [PATCH] Use multistage Dockerfile for building the mumble-web application to ./dist --- build_mumble_web.sh | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/build_mumble_web.sh b/build_mumble_web.sh index 7f2203a..2eaca85 100755 --- a/build_mumble_web.sh +++ b/build_mumble_web.sh @@ -29,10 +29,6 @@ CONTAINER_NAME="build_mumble_web_container" DIST_DIR="/home/node/dist" # path on the host where to copy the files DESTINATION_HOST="./dist" -# select if create image should be removed -DELETE_IMAGE="false" -# Run test with container -RUN_TEST="true" function verify_commit_HEAD() { cd $REPOSITORY @@ -40,14 +36,19 @@ function verify_commit_HEAD() { cd ../ } +echo "buildung mumble-web" +echo "files will be stored at: ${DESTINATION_HOST}" + # check if git repository is already cloned # then pull updates # if not clone repository if cd $REPOSITORY then - git pull - cd ../ + echo "updating mumble-web repository" + git pull + cd ../ else + echo "cloning mumble-web repository" git clone $URL_GITHUB fi @@ -55,25 +56,15 @@ fi verify_commit_HEAD # build docker image -printf "\nBuilding image\n" -docker build -t $IMAGE_NAME -f Dockerfile.mumble-web . > build.log +echo "building mumble-web image" +echo "logs will be stored in: build.log" +time docker build --target mumble-web -t "${IMAGE_NAME}" . > build.log # create temporary container docker create --name $CONTAINER_NAME "${IMAGE_NAME}" # remove previously copied files -rm -rf dist/ +rm -rf dist # # copy files from container to host docker cp $CONTAINER_NAME:"${DIST_DIR}" $DESTINATION_HOST # remove created container docker rm -f $CONTAINER_NAME - -if [ $DELETE_IMAGE == "true" ] -then - # remove the created image - docker rmi $IMAGE_NAME -fi - -if [ $RUN_TEST == "true" ] -then - docker build -t "${IMAGE_NAME}_nginx" -f webserver/Dockerfile.nginx . - docker run --rm -d -p 443:443 --name "${CONTAINER_NAME}_nginx" "${IMAGE_NAME}_nginx" -fi \ No newline at end of file +docker rmi $IMAGE_NAME \ No newline at end of file -- GitLab