Browse Source

Rename variables for clarity and consistency. Show more output.

master
poikilos 3 years ago
parent
commit
99edab6456
  1. 17
      docker/lmk.devuan-chimaera.rc
  2. 107
      docker/lmk.devuan-chimaera.sh
  3. 6
      docker/server-finetest-devuan-chimaera/Dockerfile
  4. 16
      docker/server-finetest-devuan-chimaera/build-and-check.sh

17
docker/lmk.devuan-chimaera.rc

@ -1,12 +1,13 @@
container_name="finetest-devuan-chimaera-lmk" container_name="finetest-devuan-chimaera-lmk"
library_image="linux-minetest-kit/libraries-devuan-chimaera" libraries_image="linux-minetest-kit/libraries-devuan-chimaera"
docker_finetest_server_image_name="linux-minetest-kit/server-finetest-devuan-chimaera" server_image_dir="server-finetest-devuan-chimaera"
# ^ This must match the one used in the "FROM" statement in server-finetest-devuan-chimaera/Dockerfile server_image="linux-minetest-kit/server-finetest-devuan-chimaera"
# ^ formerly server_finetest_image
# ^ This must match the one used in the "FROM" statement in $server_image_dir/Dockerfile
# client_classic_image=linux-minetest-kit/client-classic # client_classic_image=linux-minetest-kit/client-classic
server_finetest_image="linux-minetest-kit/server-finetest-devuan-chimaera"
# client_classic_container="minetest-client-classic" # client_classic_container="minetest-client-classic"
server_container="minetestserver-finetest" # server_container="minetestserver-finetest"
docker_libraries_image_dir="libraries-devuan-chimaera" # ^ deprecated since: Only container_name is necessary since there is no container based on libraries_image--a libraries container is not necessary since Dockerfile builds the libraries now.
docker_finetest_server_image_dir="server-finetest-devuan-chimaera" libraries_image_dir="libraries-devuan-chimaera"
container_build_blob=$docker_libraries_image_dir/linux-minetest-kit.zip libraries_image_build_blob=$libraries_image_dir/linux-minetest-kit.zip
prerelease_path=~/Downloads/minetest.org/insider-prerelease/linux-minetest-kit-220509.zip prerelease_path=~/Downloads/minetest.org/insider-prerelease/linux-minetest-kit-220509.zip

107
docker/lmk.devuan-chimaera.sh

@ -20,23 +20,28 @@ END
fi fi
# container_name="linux-minetest-kit-build-libraries-devuan-chimaera" # container_name="linux-minetest-kit-build-libraries-devuan-chimaera"
# ^ This is no longer necessary since the IMAGE does the building (build was moved to Dockerfile) # ^ This is no longer necessary since the IMAGE does the building (build was moved to Dockerfile)
source lmk.devuan-chimaera.rc this_rc="lmk.devuan-chimaera.rc"
if [ ! -f "$this_rc" ]; then
echo "Error: $0 must run in the directory containing $this_rc."
exit 1
fi
source $this_rc
if [ $? -ne 0 ]; then exit 1; fi if [ $? -ne 0 ]; then exit 1; fi
if [ ! -d "$docker_libraries_image_dir" ]; then if [ ! -d "$libraries_image_dir" ]; then
echo "* $0 must run from the directory containing the container image directory: $docker_libraries_image_dir" echo "Error: $0 must run from the directory containing the container image directory: $libraries_image_dir"
exit 1 exit 1
fi fi
# ^ docker_libraries_image_dir has to be in the same directory as Dockerfile or # ^ libraries_image_dir has to be in the same directory as Dockerfile or
# the COPY command in the Dockerfile won't work. # the COPY command in the Dockerfile won't work.
source $docker_libraries_image_dir/lmk.rc source $libraries_image_dir/lmk.rc
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
exit 1 exit 1
fi fi
if [ "@$DL_SRC_PATH" = "@" ]; then if [ "@$DL_SRC_PATH" = "@" ]; then
# DL_SRC_PATH="$HOME/Downloads/$DL_SRC_NAME" # DL_SRC_PATH="$HOME/Downloads/$DL_SRC_NAME"
DL_SRC_PATH="$docker_libraries_image_dir" DL_SRC_PATH="$libraries_image_dir"
# ^ $DL_SRC_PATH has to be in the same directory as Dockerfile or # ^ $DL_SRC_PATH has to be in the same directory as Dockerfile or
# the COPY command in the Dockerfile won't work. # the COPY command in the Dockerfile won't work.
# The file should be added to .gitignore for the reason that it # The file should be added to .gitignore for the reason that it
@ -44,54 +49,55 @@ if [ "@$DL_SRC_PATH" = "@" ]; then
fi fi
# sudo docker image inspect $library_image > /dev/null # sudo docker image inspect $libraries_image > /dev/null
sudo docker image inspect $library_image --format "* docker is looking for the image..." sudo docker image inspect $libraries_image --format "* docker is looking for the image..."
# ^ appending ":latest" to the name also works. # ^ appending ":latest" to the name also works.
# ^ Get matching images as a JSON list (where each has "Id" and other # ^ Get matching images as a JSON list (where each has "Id" and other
# metadata). # metadata).
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
if [ ! -d "$docker_libraries_image_dir" ]; then if [ ! -d "$libraries_image_dir" ]; then
echo "Error: \"$docker_libraries_image_dir\" (docker_libraries_image_dir for storing $SRC_URL) doesn't exist in \"`pwd`\"." echo "Error: \"$libraries_image_dir\" (libraries_image_dir for storing $SRC_URL) doesn't exist in \"`pwd`\"."
exit 1 exit 1
fi fi
echo "* building image $library_image..." echo "* building image $libraries_image..."
if [ ! -f "$container_build_blob" ]; then if [ ! -f "$libraries_image_build_blob" ]; then
echo "* downloading $SRC_URL to $DL_SRC_PATH..." echo "* downloading $SRC_URL to $DL_SRC_PATH..."
curl "$SRC_URL" --progress-bar --output "$DL_SRC_PATH" curl "$SRC_URL" --progress-bar --output "$DL_SRC_PATH"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
exit 1 exit 1
fi fi
if [ ! -f "$container_build_blob" ]; then if [ ! -f "$libraries_image_build_blob" ]; then
echo "Error: This script requires \"$container_build_blob\"." echo "Error: This script requires \"$libraries_image_build_blob\"."
exit 1 exit 1
fi fi
else else
echo "* using existing \"$container_build_blob\" to build the container image" echo "* using existing \"$libraries_image_build_blob\" to build the container image"
fi fi
cp ../install-minetest-build-deps.sh $docker_libraries_image_dir/ cp ../install-minetest-build-deps.sh $libraries_image_dir/
# ^ This copy of it is in .gitignore. # ^ This copy of it is in .gitignore.
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Error: 'cp ../install-minetest-build-deps.sh $docker_libraries_image_dir/' failed." echo "Error: 'cp ../install-minetest-build-deps.sh $libraries_image_dir/' failed."
exit 1 exit 1
fi fi
move_back="false" move_back="false"
if [ ! -f $container_build_blob ]; then if [ ! -f $libraries_image_build_blob ]; then
if [ -f "$prerelease_path" ]; then if [ -f "$prerelease_path" ]; then
move_back="true" move_back="true"
echo "mv $prerelease_path $container_build_blob" echo "mv $prerelease_path $libraries_image_build_blob"
mv $prerelease_path $container_build_blob mv $prerelease_path $libraries_image_build_blob
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "* Error: the mv command failed." echo "* Error: the mv command failed."
exit 1 exit 1
fi fi
fi fi
fi fi
sudo docker build -t $library_image $docker_libraries_image_dir sudo docker build -t $libraries_image $libraries_image_dir
# -t: Name and optionally a tag in the 'name:tag' format
code=$? code=$?
if [ "@move_back" = "@true" ]; then if [ "@move_back" = "@true" ]; then
echo "mv \"$prerelease_path\" \"$container_build_blob\"" echo "mv \"$prerelease_path\" \"$libraries_image_build_blob\""
mv "$container_build_blob" "$prerelease_path" mv "$libraries_image_build_blob" "$prerelease_path"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "* Warning: the mv command failed." echo "* Warning: the mv command failed."
fi fi
@ -100,17 +106,17 @@ if [ $? -ne 0 ]; then
exit 1 exit 1
fi fi
else else
echo "* The container will be built using the existing docker image $library_image" echo "* The container will be built using the existing docker image $libraries_image"
fi fi
# sudo docker container run -d --name $library_image unzip xvf $contained_arc -C $contained_repos # sudo docker container run -d --name $libraries_image unzip xvf $contained_arc -C $contained_repos
container_Id=`sudo docker ps -aqf "name=$container_name"` container_Id=`sudo docker ps -aqf "name=$container_name"`
# ^ ONLY works with container_name not library_image # ^ ONLY works with container_name not libraries_image
cat > /dev/null <<END cat > /dev/null <<END
if [ "@$container_Id" = "@" ]; then if [ "@$container_Id" = "@" ]; then
echo "* creating a container named $container_name" echo "* creating a container named $container_name"
sudo docker create --name=$container_name $library_image sudo docker create --name=$container_name $libraries_image
# ^ output is the Id # ^ output is the Id
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "FAILED" echo "FAILED"
@ -137,24 +143,29 @@ if [ "@$container_Id" != "@" ]; then
exit 0 exit 0
fi fi
echo "There is no container_Id for container_name=$container_name, so checking for image:" echo "There is no container_Id for container_name=$container_name, so checking for image:"
sudo docker image inspect $docker_finetest_server_image_name --format "* docker is looking for the image..." sudo docker image inspect $server_image --format "* docker is looking for the image..."
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "NOT FOUND, so:" echo "NOT FOUND, so:"
echo "* building $docker_finetest_server_image_name ($docker_finetest_server_image_dir inherits $library_image, so using built libraries from that should work)..." echo "* building $server_image ($server_image_dir inherits $libraries_image, so using built libraries from that should work)..."
sudo docker build -t $docker_finetest_server_image_name $docker_finetest_server_image_dir if [ ! -d "$server_image_dir" ]; then
# ^ always returns 1 for some reason echo "Error: \"$server_image_dir\" doesn't exist in `pwd`."
# if [ $? -ne 0 ]; then exit 1
# exit 1 fi
# fi sudo docker build -t $server_image $server_image_dir
# ^ ./mtcompile-program.pl --build --finetest --server returns 1 for some reason, so there is a custom build script used in the Dockerfile
# -t: Name and optionally a tag in the 'name:tag' format
if [ $? -ne 0 ]; then
exit 1
fi
else else
echo "* using existing $docker_finetest_server_image_name" echo "* using existing $server_image"
fi fi
if [ "@$container_Id" = "@" ]; then if [ "@$container_Id" = "@" ]; then
# sudo docker run --name $container_name $library_image $run_all_build_commands_script # sudo docker run --name $container_name $libraries_image $run_all_build_commands_script
# ^ build was moved to the Dockerfile # ^ build was moved to the Dockerfile
echo "* creating container $container_name from image $docker_finetest_server_image_name" echo "* creating container $container_name from image $server_image"
sudo docker run --name $container_name $docker_finetest_server_image_name /opt/linux-minetest-kit/minetest/minetestserver sudo docker run --name $container_name $server_image /opt/linux-minetest-kit/minetest/minetestserver
code=$? code=$?
if [ $code -ne 0 ]; then if [ $code -ne 0 ]; then
cat <<END cat <<END
@ -164,7 +175,7 @@ if [ "@$container_Id" = "@" ]; then
sudo docker rm --force $container_name sudo docker rm --force $container_name
- Update the image as follows: - Update the image as follows:
sudo docker rm --force $container_name sudo docker rm --force $container_name
sudo docker rmi $docker_finetest_server_image_name sudo docker rmi $server_image
sudo docker image prune --force sudo docker image prune --force
# --force: Don't prompt for confirmation. # --force: Don't prompt for confirmation.
@ -202,15 +213,15 @@ echo
# as expected. See <https://www.howtogeek.com/devops/how-to-run-gui-applications-in-a-docker-container/>. # as expected. See <https://www.howtogeek.com/devops/how-to-run-gui-applications-in-a-docker-container/>.
# Therefore: # Therefore:
# echo "* Creating image \"$server_finetest_image\"..." # echo "* Creating image \"$server_image\"..."
# sudo docker commit $container_Id $server_finetest_image # sudo docker commit $container_Id $server_image
# if [ $? -ne 0 ]; then # if [ $? -ne 0 ]; then
# echo "FAILED (sudo docker commit $container_Id $server_finetest_image)" # echo "FAILED (sudo docker commit $container_Id $server_image)"
# fi # fi
# echo "* Running $server_bin_path in container \"$server_container\"" # echo "* Running $server_bin_path in container \"$server_container\""
# sudo docker container run --name $server_container $server_finetest_image $server_bin_path # sudo docker container run --name $server_container $server_image $server_bin_path
# if [ $? -ne 0 ]; then # if [ $? -ne 0 ]; then
# echo "FAILED (sudo docker container run --name $server_container $server_finetest_image $server_bin_path)" # echo "FAILED (sudo docker container run --name $server_container $server_image $server_bin_path)"
# fi # fi
# ^ Build the server as a separate step instead (see further up) # ^ Build the server as a separate step instead (see further up)
@ -224,7 +235,7 @@ How to use the image:
sudo docker image ls sudo docker image ls
# ^ See what images are installed (one image can be used for many containers). # ^ See what images are installed (one image can be used for many containers).
sudo docker rmi $library_image sudo docker rmi $libraries_image
# ^ Remove a docker image (This is necessary after updating the unversioned Docker image to avoid cached RUN commands from doing nothing when the script after RUN changes). # ^ Remove a docker image (This is necessary after updating the unversioned Docker image to avoid cached RUN commands from doing nothing when the script after RUN changes).
sudo docker image prune --force sudo docker image prune --force
@ -254,12 +265,12 @@ How to use the image:
# ^ Stop a container by name (See <https://www.tecmint.com/name-docker-containers/>) # ^ Stop a container by name (See <https://www.tecmint.com/name-docker-containers/>)
# You must use the container name (as determined using the "ps" subcommand), not the image name. # You must use the container name (as determined using the "ps" subcommand), not the image name.
sudo docker container run -it $library_image /bin/bash sudo docker container run -it $libraries_image /bin/bash
# ^ Run an interactive terminal (Type 'exit' to exit) # ^ Run an interactive terminal (Type 'exit' to exit)
# (based on <https://phoenixnap.com/kb/docker-run-command-with-examples>) # (based on <https://phoenixnap.com/kb/docker-run-command-with-examples>)
sudo docker commit $container_Id $server_finetest_image sudo docker commit $container_Id $server_image
sudo docker container run --name tmp_test_im -it $server_finetest_image /bin/bash sudo docker container run --name tmp_test_im -it $server_image /bin/bash
# ^ Transform the container into an image and inspect the internals manually # ^ Transform the container into an image and inspect the internals manually
# (based on <https://www.thorsten-hans.com/how-to-run-commands-in-stopped-docker-containers/>). # (based on <https://www.thorsten-hans.com/how-to-run-commands-in-stopped-docker-containers/>).
# Then: sudo docker rm --force tmp_test_im # Then: sudo docker rm --force tmp_test_im

6
docker/server-finetest-devuan-chimaera/Dockerfile

@ -1,6 +1,6 @@
FROM linux-minetest-kit/libraries-devuan-chimaera FROM linux-minetest-kit/libraries-devuan-chimaera
COPY build-and-check.sh /opt/ COPY build-and-check.sh /opt
WORKDIR /opt/linux-minetest-kit WORKDIR /opt/linux-minetest-kit
RUN ./mtcompile-program.pl --build --finetest --server # RUN ./mtcompile-program.pl --build --finetest --server
# ^ Always returns 1, so: # ^ Always returns 1, so:
# RUN build-and-check.sh RUN /opt/build-and-check.sh

16
docker/server-finetest-devuan-chimaera/build-and-check.sh

@ -1,11 +1,17 @@
#!/bin/bash #!/bin/bash
./mtcompile-program.pl --build --finetest --server ./mtcompile-program.pl build --finetest --server
echo "Returned $1" echo "Done './mtcompile-program.pl build --finetest --server' (returned $?)"
good_flag_file=minetest/bin/multicraftserver good_flag_file_name=multicraftserver
good_flag_file=minetest/bin/$good_flag_file_name
if [ -f "$good_flag_file" ]; then if [ -f "$good_flag_file" ]; then
echo "* forcing OK return since found \"$good_flag_file\"" echo "* forcing OK return since found \"$good_flag_file\" in `pwd`"
exit 0 exit 0
else else
echo "* forcing OK return since \"$good_flag_file\" doesn't exist" echo "* forcing FAILED return since \"$good_flag_file\" doesn't exist in `pwd`"
echo "* searching..."
find /opt -name "minetest*" | grep -v "minetest\.mo" | grep -v "minetest\.po"
find /opt -name "multicraft*"
echo "* searching for $good_flag_file_name..."
find /opt -name $good_flag_file_name
exit 1 exit 1
fi fi

Loading…
Cancel
Save