From 66c4d743b32b56820c2dc5c2e057caa418e06b4b Mon Sep 17 00:00:00 2001 From: Parker Burnett Date: Mon, 11 Jul 2022 20:54:17 -0700 Subject: [PATCH] Adding Docker Support (#914) * Adding dockerfile and instructions for building * fixing readme and updating Dockerfile * Adding packages and practicerom support --- Dockerfile | 42 ++++++++++++++++++++++++++++++++++++ README.md | 12 +++++++---- docs/BUILDING_DOCKER.md | 47 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 97 insertions(+), 4 deletions(-) create mode 100644 Dockerfile create mode 100644 docs/BUILDING_DOCKER.md diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..94b8cdfa2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,42 @@ +FROM ubuntu:22.04 as build +ENV TZ=UTC + +# Install Required Dependencies +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone && \ + apt-get update && apt-get install -y \ + curl \ + build-essential \ + binutils-mips-linux-gnu \ + pkg-config \ + python3 \ + python3-pip \ + git \ + wget \ + unzip \ + vbindiff \ + vim \ + clang-tidy-11 \ + clang-format-11 \ + libpng-dev && \ + apt clean && \ + rm -rf /var/lib/apt/lists/* + +# Install practicerom +RUN curl https://practicerom.com/public/packages/debian/pgp.pub | \ + apt-key add - && echo deb http://practicerom.com/public/packages/debian staging main >/etc/apt/sources.list.d/practicerom.list && apt update + +RUN apt-get install -y practicerom-dev + +COPY requirements.txt requirements.txt + +RUN python3 -m pip install --no-cache-dir -r requirements.txt + +ENV LANG C.UTF-8 + +RUN mkdir /mm + +WORKDIR /mm + +RUN git config --global --add safe.directory /mm + +ENTRYPOINT ["/bin/bash", "-c"] diff --git a/README.md b/README.md index 3b8218596..24b94be99 100644 --- a/README.md +++ b/README.md @@ -28,15 +28,16 @@ This is a WIP **decompilation** of ***The Legend of Zelda: Majora's Mask***. The The only version currently supported is N64 US, but we intend to eventually support every retail version of the original game (i.e. not versions of MM3D, which is a totally different game). It currently builds the following ROM: + * mm.us.rev1.rom.z64 `md5: 2a0a8acb61538235bc1094d297fb6556` **This repo does not include any assets or assembly code necessary for compiling the ROM. A prior copy of the game is required to extract the required assets.** Please refer to the following for more information: -* [Website](https://zelda64.dev/) -* [Discord](https://discord.zelda64.dev/) -* [How to Contribute](docs/CONTRIBUTING.md) +- [Website](https://zelda64.dev/) +- [Discord](https://discord.zelda64.dev/) +- [How to Contribute](CONTRIBUTING.md) ## Installation @@ -50,6 +51,10 @@ We recommend using Debian or Ubuntu 20.04 Linux distributions. Preparation is covered in a [separate document](docs/BUILDING_MACOS.md). +### Docker + +Preparation is covered in [Building Docker](docs/BUILDING_DOCKER.md). + ### Linux (Native or under WSL / VM) #### 1. Install build dependencies @@ -130,7 +135,6 @@ Running `make init` will also make the `./expected` directory and copy all of th The disadvantage that the ordering of the terminal output is scrambled, so for debugging it is best to stick to one thread (i.e. not pass `-jN`). (`-j` also exists, which uses unlimited jobs, but is generally slower.) - ## Contributing All contributions are welcome. This is a group effort, and even small contributions can make a difference. diff --git a/docs/BUILDING_DOCKER.md b/docs/BUILDING_DOCKER.md new file mode 100644 index 000000000..5fa7b4865 --- /dev/null +++ b/docs/BUILDING_DOCKER.md @@ -0,0 +1,47 @@ +# Building using Docker + +## Dependencies + +You will need [Docker](https://docs.docker.com/get-docker/) Follow the instructions for your operating system. + +## 1. Clone the Repository + +You will need to prepare a local version of the project with a copied base ROM (see steps [2](../README.md#2-clone-the-repository) and [4](../README.md#4-prepare-a-base-rom) of the Linux instructions). + +## 2. Create the Docker image + +From inside your local project, run the following command: + +```bash +docker build . -t mm +``` + +This will build a docker image with the name of `mm`, to verify the image was made you can run the command + +```bash +docker image ls +``` + +and look for `mm` under the "REPOSITORY" column. + +## 3. Start the container + +To start the container, you can mount your local filesystem into the Docker container and run an interactive bash session. + +```bash +docker run -it --rm --mount type=bind,source="$(pwd)",destination=/mm mm /bin/bash +``` + +- The `-it` flags Keep STDIN open even if not attached to the container and allocates a pseudo-tty terminal. +- The `--rm` flags causes Docker to automatically remove the container when it exits. +- The `--mount` flag allows you to mount volumes and host-directories in a container. By specifying the type to be a bind, we are saying there are files to be mounted from the host machine (the one that runs your docker daemon) onto the container. Source is specifying where we are mounting the files from in this case, we want the `mm` folder created earlier. The $(pwd) sub-command expands to the current working directory. The destination takes as its value the path where the file or directory is mounted in the container. This makes it so that the image should rarely change and will reduce the need to rebuild with any change to the codebase. + +## 4. Setup and Build the ROM + +Once inside the container, you will need to set the repository as a trusted repository with the following command: + +```bash +git config --global --add safe.directory /mm +``` + +After that continue with step [5. Make and Build the ROM](../README.md#5-make-and-build-the-rom) of the Linux instructions to setup and build the ROM, or run any other command you need.