diff options
author | Dsaster <78389441+dsastr@users.noreply.github.com> | 2021-02-06 22:07:15 +0100 |
---|---|---|
committer | Dsaster <78389441+dsastr@users.noreply.github.com> | 2021-02-06 22:07:15 +0100 |
commit | 7b7d9ac83ebe77efb176b7a20a98b2baf3dfa852 (patch) | |
tree | be4762b325d9f62c4cd6c97db5b4fd7586218e7e | |
parent | 563b14a97f6208e790843931afc54981f8e8f4b3 (diff) |
Use existing scripts in contrib/docker
-rw-r--r-- | INSTALL.md | 6 | ||||
-rw-r--r-- | contrib/docker/Dockerfile.ubuntu (renamed from docker/Dockerfile) | 2 | ||||
-rwxr-xr-x | contrib/docker/build_docker.sh | 30 | ||||
-rwxr-xr-x | docker/build.sh | 20 |
4 files changed, 29 insertions, 29 deletions
@@ -60,12 +60,12 @@ If you get an error in saving configuration settings when specifying the license #### Docker -If you find issues building the ROMs with the above methods, you can try the Docker-specific build script. It will build a Docker image with the system requirements above, and run the `make` scripts (any specified parameter will be passed to the `make` command): +If you find issues building the ROMs with the above methods, you can try the Docker-specific build script. It will build an Alpine-based Docker image with the system requirements above, and run the `make` scripts (any specified parameter will be passed to the `make` command): ```console $ make clean -$ ./docker/build.sh # build pokediamond -$ ./docker/build.sh pearl # build pokepearl +$ ./contrib/docker/build_docker.sh # build pokediamond +$ ./contrib/docker/build_docker.sh pearl # build pokepearl ``` Note: Docker may not run at a full performance if its underlying Linux kernel is being virtualized (mainly Windows and macOS hosts). diff --git a/docker/Dockerfile b/contrib/docker/Dockerfile.ubuntu index 3bc11235..d06b15f2 100644 --- a/docker/Dockerfile +++ b/contrib/docker/Dockerfile.ubuntu @@ -5,6 +5,8 @@ apt update && \ DEBIAN_FRONTEND=noninteractive apt install -y --no-install-recommends binutils-arm-none-eabi build-essential git libpng-dev wine wine32 && \ rm -r /var/cache/apt/archives /var/lib/apt/lists +WORKDIR /app + # Run a persistent wineserver to avoid errors like # wine: a wine server seems to be running, but I cannot connect to it. RUN mkdir -p /root/.wine diff --git a/contrib/docker/build_docker.sh b/contrib/docker/build_docker.sh index b59e2158..dafacbe7 100755 --- a/contrib/docker/build_docker.sh +++ b/contrib/docker/build_docker.sh @@ -1,11 +1,29 @@ #!/bin/sh -ver="0.1" +PROJECT_PATH="$(git rev-parse --show-toplevel)" +PROJECT_NAME="pokediamond" +PROJECT_VER="0.1" -docker inspect pokediamond:$ver > /dev/null -if [ $? = 0 ]; then - echo "Not rebuilding image since image exists"; +# Build container image +IMAGE_NAME="$PROJECT_NAME:$PROJECT_VER" +IMAGE_PATH="$PROJECT_PATH/contrib/docker" +if docker inspect $IMAGE_NAME > /dev/null; then + echo "Not rebuilding image since it already exists"; +elif [ "x$USE_UBUNTU" != "x" ]; then + docker build -t $IMAGE_NAME -f $IMAGE_PATH/Dockerfile.ubuntu $IMAGE_PATH else - docker build -t pokediamond:$ver $(git rev-parse --show-toplevel)/contrib/docker + docker build -t $IMAGE_NAME $IMAGE_PATH fi -docker run --network=none -it -v $(git rev-parse --show-toplevel):/app pokediamond:$ver + +# Start container and wine server +CONTAINER_NAME="$PROJECT_NAME-build" +docker run -d --name $CONTAINER_NAME --network=none -it --rm -v $PROJECT_PATH:/app $IMAGE_NAME + +# Build selected project, always exit successfully to ensure container stops +EXIT_CODE="0" +docker exec -i -t $CONTAINER_NAME make $@ || EXIT_CODE="$?" + +# Exit and remove the container +docker stop $CONTAINER_NAME + +exit $EXIT_CODE diff --git a/docker/build.sh b/docker/build.sh deleted file mode 100755 index 1ce28543..00000000 --- a/docker/build.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -set -eou pipefail - -PROJECT_NAME=${PROJECT_NAME:-pokediamond} -PROJECT_PATH=${PROJECT_PATH:-$(dirname $(pwd))} - -# Build container image -IMAGE_NAME=${IMAGE_NAME:-$PROJECT_NAME-image} -docker build -t $IMAGE_NAME . - -# Start container and wine server -CONTAINER_NAME=${CONTAINER_NAME:-$PROJECT_NAME} -docker run -d -i --name $CONTAINER_NAME --rm -t -v $PROJECT_PATH:/$PROJECT_NAME -w /$PROJECT_NAME $IMAGE_NAME - -# Build selected project, always exit successfully to ensure container stops -docker exec -i -t $CONTAINER_NAME make $@ || true - -# Exit the container and remove -docker stop $CONTAINER_NAME |