Skip to content
Snippets Groups Projects
Verified Commit e6e42ba0 authored by Armin Co's avatar Armin Co
Browse files

Use multistage Dockerfile

for building the mumble-web application
to ./dist
parent 9d62f10d
No related branches found
No related tags found
1 merge request!1Feature nginx.
......@@ -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
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
\ No newline at end of file
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment