From 7b7d9ac83ebe77efb176b7a20a98b2baf3dfa852 Mon Sep 17 00:00:00 2001 From: Dsaster <78389441+dsastr@users.noreply.github.com> Date: Sat, 6 Feb 2021 22:07:15 +0100 Subject: Use existing scripts in contrib/docker --- INSTALL.md | 6 +++--- contrib/docker/Dockerfile.ubuntu | 13 +++++++++++++ contrib/docker/build_docker.sh | 30 ++++++++++++++++++++++++------ docker/Dockerfile | 11 ----------- docker/build.sh | 20 -------------------- 5 files changed, 40 insertions(+), 40 deletions(-) create mode 100644 contrib/docker/Dockerfile.ubuntu delete mode 100644 docker/Dockerfile delete mode 100755 docker/build.sh diff --git a/INSTALL.md b/INSTALL.md index 6cbe5111..f932b238 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -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/contrib/docker/Dockerfile.ubuntu b/contrib/docker/Dockerfile.ubuntu new file mode 100644 index 00000000..d06b15f2 --- /dev/null +++ b/contrib/docker/Dockerfile.ubuntu @@ -0,0 +1,13 @@ +FROM ubuntu:20.04 + +RUN dpkg --add-architecture i386 && \ +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 +CMD /usr/lib/wine/wineserver32 -f -p 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/Dockerfile b/docker/Dockerfile deleted file mode 100644 index 3bc11235..00000000 --- a/docker/Dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -FROM ubuntu:20.04 - -RUN dpkg --add-architecture i386 && \ -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 - -# 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 -CMD /usr/lib/wine/wineserver32 -f -p 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 -- cgit v1.2.3