diff --git a/containers/lmk.devuan-chimaera.sh b/containers/lmk.devuan-chimaera.sh index 016727b..e9d311b 100755 --- a/containers/lmk.devuan-chimaera.sh +++ b/containers/lmk.devuan-chimaera.sh @@ -1,7 +1,17 @@ #!/bin/bash # See https://nextbreakpoint.com/posts/article-compile-code-with-docker.html # sudo docker build -t lmk-devuan-chimaera-img dyne/devuan:chimaera +echo "* This container is only for the server, not the client." +sleep 10 docker_path="`sudo bash -c 'command -v docker'`" +ENABLE_RUN_CLIENT=false +for var in "$@" +do + if [ "@$var" = "@--run-client" ]; then + ENABLE_RUN_CLIENT=true + fi +done + if [ ! -f "$docker_path" ]; then cat <) + sudo docker commit $container_Id $server_finetest_image + sudo docker container run --name tmp_test_im -it $server_finetest_image /bin/bash + # ^ Transform the container into an image and inspect the internals manually + # (based on ). + # Then: sudo docker rm --force tmp_test_im + sudo docker attach $container_name # ^ Attach your current terminal to a running container (See # ). - sudo docker rm --force $container_name # ^ Delete a container by its name. # --force: kill and delete running containers as well. @@ -165,21 +187,24 @@ if [ "@$container_Id" = "@" ]; then exit 1 fi fi -echo "container_Id=$container_Id" -END -echo "building within the container..." +END +echo "container_Id=$container_Id" +# echo "building within the container..." # sudo docker start $container_name # ^ NOTE: start is useless here since it won't stay open unless the # command is set to "bash" or something, which isn't desirable. # Therefore, use run instead of exec below. # ^ output is $container_name -sudo docker run --name $container_name $image_name $run_all_build_commands_script -if [ $? -ne 0 ]; then - cat <. +# Therefore: + +echo "* Creating server image..." +sudo docker commit $container_Id $server_finetest_image +if [ $? -ne 0 ]; then + echo "FAILED (sudo docker commit $container_Id $server_finetest_image)" +fi +echo "* Running $server_bin_path in container \"$server_container\"" +sudo docker container run --name $server_container $server_finetest_image $server_bin_path +if [ $? -ne 0 ]; then + echo "FAILED (sudo docker container run --name $server_container $server_finetest_image $server_bin_path)" +fi # How to use docker-compose (See ): # "1. Define your app’s environment with a Dockerfile so it can be reproduced anywhere." diff --git a/containers/lmk.devuan-chimaera/Dockerfile b/containers/lmk.devuan-chimaera/Dockerfile index 7bc9065..1349521 100644 --- a/containers/lmk.devuan-chimaera/Dockerfile +++ b/containers/lmk.devuan-chimaera/Dockerfile @@ -8,7 +8,10 @@ RUN apt-get update RUN apt-get install -y unzip RUN apt-get install -y perl RUN unzip /opt/linux-minetest-kit.zip -d /opt +# RUN adduser --disabled-password --gecos "" minebest # RUN apt-get install -y sudo # RUN curl https://raw.githubusercontent.com/poikilos/EnlivenMinetest/master/install-minetest-build-deps.sh --output /opt/install-minetest-build-deps.sh # RUN chmod +x /opt/install-minetest-build-deps.sh RUN /opt/install-minetest-build-deps.sh +WORKDIR /opt/linux-minetest-kit +RUN bash -e ./mtcompile-libraries.sh build diff --git a/containers/lmk.devuan-chimaera/build-lmk.sh b/containers/lmk.devuan-chimaera/build-lmk.sh index ffcee08..852ddf9 100755 --- a/containers/lmk.devuan-chimaera/build-lmk.sh +++ b/containers/lmk.devuan-chimaera/build-lmk.sh @@ -19,33 +19,7 @@ echo "* checking for $contained_good_repo_flag_path on the destination..." ls $contained_good_repo_flag_path > /dev/null if [ $? -ne 0 ]; then echo "NOT FOUND" - printf "Warning: the Docker image isn't up to date. Unzipping manually..." - printf "checking for unzip..." - container_unzip="`which unzip`" - if [ "@$container_unzip" = "@" ]; then - echo "NOT FOUND. Installing..." - # This should never happen if the Dockerfile was used. - apt-get update - if [ $? -ne 0 ]; then exit 1; fi - apt-get install -y unzip - if [ $? -ne 0 ]; then exit 1; fi - container_unzip="`which unzip`" - if [ "@$container_unzip" = "@" ]; then - echo "Error: Installing unzip in the container did not succeed. Install unzip inside the container manually then try again, or extract linux-minetest-kit such that $contained_good_repo_flag_path exists." - exit 1 - fi - else - echo "FOUND" - fi - # sudo docker container run $image_name unzip xvf $contained_arc -d $contained_repos - echo "* extracting $contained_arc" - unzip $contained_arc -d $contained_repos - # -d: is destination, like -C or --directory for tar. - # -v: verbose (prevents extraction) - if [ $? -ne 0 ]; then - echo "Error: unzip failed within the container. Install unzip inside the container manually then try again, or extract linux-minetest-kit such that $contained_good_repo_flag_path exists." - exit 1 - fi + exit 1 else echo "FOUND (already extracted)" fi @@ -59,38 +33,6 @@ else echo "* detected $contained_good_repo_flag_path (So the source directory is assumed to be ok)" fi - - -if [ "@$contained_user" = "@" ]; then - echo "Error: contained_user can't be blank, or checking for the user within the container will not work." - exit 1 -fi - -id -u $contained_user -if [ $? -ne 0 ]; then - printf "* creating $contained_user in container $container_name..." - adduser --disabled-password --gecos "" $contained_user --home $contained_home - if [ $? -ne 0 ]; then - echo "FAILED" - exit 1 - else - echo "OK" - fi -else - echo "* using the $container_name container's existing contained_user: $contained_user" -fi - -# sudo docker container run --name $container_name $image_name ls $contained_repos - -# chown -R $contained_user $contained_repos -# ^ Usually you could do this, but run as root since this script is used to test the safety of linux-minetest-kit: - -# curl https://raw.githubusercontent.com/poikilos/EnlivenMinetest/master/install-minetest-build-deps.sh --output /opt/install-minetest-build-deps.sh -# chmod +x $repo_build_assumptions_cmd -# $repo_build_assumptions_cmd - -# ^ moved to Dockerfile - if [ ! -d "$contained_repo" ]; then echo "Error: \"$contained_repo\" doesn't exist." exit 1 @@ -98,13 +40,8 @@ fi echo "* building libraries using $repo_build_libs_cmd..." cd "$contained_repo" if [ $? -ne 0 ]; then exit 1; fi -$repo_build_libs_cmd -if [ $? -ne 0 ]; then exit 1; fi -echo -echo -echo -echo -echo +# $repo_build_libs_cmd +# if [ $? -ne 0 ]; then exit 1; fi echo echo "* building program using $repo_build_cmd..." $repo_build_cmd @@ -112,4 +49,10 @@ code=$? if [ $code -ne 0 ]; then echo "$repo_build_cmd FAILED (code $code)" exit $code +else + echo "SUCCESS" + echo "Note that if you run this again, it will just compile again." + echo + echo "To run Minetest, follow the instructions that appear below (if you ran $docker_image_build_script_name)" + echo fi diff --git a/containers/lmk.devuan-chimaera/lmk.rc b/containers/lmk.devuan-chimaera/lmk.rc index b13755d..1133b40 100644 --- a/containers/lmk.devuan-chimaera/lmk.rc +++ b/containers/lmk.devuan-chimaera/lmk.rc @@ -1,10 +1,14 @@ #!/bin/bash contained_repos=/opt +docker_image_build_script_name="lmk.devuan-chimaera.sh" contained_arc="$contained_repos/linux-minetest-kit.zip" # ^ This must always be in sync with "COPY linux-minetest-kit.zip /opt" in Dockerfile contained_repo=$contained_repos/linux-minetest-kit contained_user=minebest +# ^ must match the useradd command in Dockerfile contained_home=/home/$contained_user +# client_bin_path=/opt/linux-minetest-kit/minetest/bin/minetest +server_bin_path=/opt/linux-minetest-kit/finetest/bin/minetestserver if [ "@$SRC_URL" = "@" ]; then SRC_URL="https://downloads.minetest.org/linux-minetest-kit.zip" fi @@ -14,8 +18,10 @@ DL_SRC_NAME=linux-minetest-kit.zip good_repo_flag_name="mtcompile-program.pl" repo_build_assumptions_cmd="/opt/install-minetest-build-deps.sh" -repo_build_libs_cmd="bash -e ./mtcompile-libraries.sh build" -repo_build_cmd="./mtcompile-program.pl --build --classic --client" +# repo_build_libs_cmd="bash -e ./mtcompile-libraries.sh build" +# ^ moved to the Dockerfile for the libraries image +# repo_build_cmd="./mtcompile-program.pl --build --classic --client" +repo_build_cmd="./mtcompile-program.pl --build --finetest --server" contained_good_repo_flag_path="$contained_repo/$good_repo_flag_name" run_all_build_commands_script=/opt/build-lmk.sh