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
Branches
No related tags found
1 merge request!1Feature nginx.
...@@ -29,10 +29,6 @@ CONTAINER_NAME="build_mumble_web_container" ...@@ -29,10 +29,6 @@ CONTAINER_NAME="build_mumble_web_container"
DIST_DIR="/home/node/dist" DIST_DIR="/home/node/dist"
# path on the host where to copy the files # path on the host where to copy the files
DESTINATION_HOST="./dist" DESTINATION_HOST="./dist"
# select if create image should be removed
DELETE_IMAGE="false"
# Run test with container
RUN_TEST="true"
function verify_commit_HEAD() { function verify_commit_HEAD() {
cd $REPOSITORY cd $REPOSITORY
...@@ -40,14 +36,19 @@ function verify_commit_HEAD() { ...@@ -40,14 +36,19 @@ function verify_commit_HEAD() {
cd ../ cd ../
} }
echo "buildung mumble-web"
echo "files will be stored at: ${DESTINATION_HOST}"
# check if git repository is already cloned # check if git repository is already cloned
# then pull updates # then pull updates
# if not clone repository # if not clone repository
if cd $REPOSITORY if cd $REPOSITORY
then then
echo "updating mumble-web repository"
git pull git pull
cd ../ cd ../
else else
echo "cloning mumble-web repository"
git clone $URL_GITHUB git clone $URL_GITHUB
fi fi
...@@ -55,25 +56,15 @@ fi ...@@ -55,25 +56,15 @@ fi
verify_commit_HEAD verify_commit_HEAD
# build docker image # build docker image
printf "\nBuilding image\n" echo "building mumble-web image"
docker build -t $IMAGE_NAME -f Dockerfile.mumble-web . > build.log echo "logs will be stored in: build.log"
time docker build --target mumble-web -t "${IMAGE_NAME}" . > build.log
# create temporary container # create temporary container
docker create --name $CONTAINER_NAME "${IMAGE_NAME}" docker create --name $CONTAINER_NAME "${IMAGE_NAME}"
# remove previously copied files # remove previously copied files
rm -rf dist/ rm -rf dist
# # copy files from container to host # # copy files from container to host
docker cp $CONTAINER_NAME:"${DIST_DIR}" $DESTINATION_HOST docker cp $CONTAINER_NAME:"${DIST_DIR}" $DESTINATION_HOST
# remove created container # remove created container
docker rm -f $CONTAINER_NAME docker rm -f $CONTAINER_NAME
if [ $DELETE_IMAGE == "true" ]
then
# remove the created image
docker rmi $IMAGE_NAME 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