Skip to content

Conversation

ahouts
Copy link
Contributor

@ahouts ahouts commented Apr 1, 2020

This PR blatantly rips off builds upon the groundwork of #24 with the added benefit of having close to normal build times!

Clean build

time docker run --rm --mount type=bind,source=(pwd),destination=/sm64 --user (id -u):(id -g) sm64 make VERSION=us -j12
...
________________________________________________________
Executed in   21.93 secs   fish           external
   usr time   93.08 millis  878.00 micros   92.20 millis
   sys time  188.38 millis    0.00 micros  188.38 millis

❯ sha1sum build/us/sm64.us.z64                                                                                  20:42:13
9bef1128717f958171a4afac3ed78ee2bb4e86ce  build/us/sm64.us.z64

Cached build

time docker run --rm --mount type=bind,source=(pwd),destination=/sm64 --user (id -u):(id -g) sm64 make VERSION=us -j4
build/us/sm64.us.z64: OK
________________________________________________________
Executed in    3.11 secs   fish           external
   usr time   33.35 millis  1293.00 micros   32.05 millis
   sys time   28.02 millis    0.00 micros   28.02 millis

This is accomplished by setting up the environment in the docker build, but only compiling during a run. As a result it only takes about a second to set up the environment and start compiling, meaning this could be used for development if one really wanted to.

Also the compiled files/rom are already in the host file system, no need to pull them out of the container.

@mkst
Copy link

mkst commented Apr 1, 2020

Took your Dockerfile and made some changes:

  1. purely aesthetic spacing/newline changes
  2. pin ubuntu 18.04 as base image (incase things break when latest is no longer 18.04)
  3. dont appear to need git to build, so dont install it
  4. use apt-get over apt
  5. sanity check sha256 sum of qemu-irix
  6. delete deb after we've installed it
  7. add uid:gid to the run command so files are created as running user rather than as root
  8. default VERSION to 'us' if not explicitly set

Feel free to use / ignore, shaves ~ 10% off the overall image size (mostly due to not installing git)

FROM ubuntu:18.04 as build

RUN apt-get update && \
    apt-get install -y \
        binutils-mips-linux-gnu \
        bsdmainutils \
        build-essential \
        libaudiofile-dev \
        pkg-config \
        python3 \
        wget \
        zlib1g-dev

RUN wget \
        https://github.com/n64decomp/qemu-irix/releases/download/v2.11-deb/qemu-irix-2.11.0-2169-g32ab296eef_amd64.deb \
        -O qemu.deb && \
    echo 8170f37cf03a08cc2d7c1c58f10d650ea0d158f711f6916da9364f6d8c85f741 qemu.deb | sha256sum --check && \
    dpkg -i qemu.deb && \
    rm qemu.deb

RUN mkdir /sm64
WORKDIR /sm64
ENV PATH="/sm64/tools:${PATH}"

CMD echo 'usage: docker run --rm --user $UID:$UID --mount type=bind,source="$(pwd)",destination=/sm64 sm64 make VERSION=${VERSION:-us} -j4'

@ahouts
Copy link
Contributor Author

ahouts commented Apr 2, 2020

@streetster nice, much cleaner and safer with these changes. I incorporated your suggestions but left out the platform specific user ID changes. Those would not work on windows and don't make sense on mac, so I instead left a note about advanced usage & put it in the readme.

@mkst
Copy link

mkst commented Apr 2, 2020

Ah good point about UID on other platforms! Hope this PR gets merged as being able to build without polluting your local machine with a bunch of packages is always nice!

@psfree
Copy link

psfree commented Apr 13, 2020

I approve, I just hope I get some credit somehow. Good work guys.

@matt-kempster
Copy link
Member

Thanks for your contribution!

@matt-kempster matt-kempster merged commit 9a40d86 into n64decomp:master Apr 19, 2020
fengjixuchui added a commit to fengjixuchui/sm64 that referenced this pull request May 6, 2020
Merge pull request n64decomp#36 from ahouts/master
VDavid003 referenced this pull request in VDavid003/sm64-port-android Aug 13, 2020
Merge camera-rebase into master. Good work :)
MaikelChan pushed a commit to MaikelChan/sm64 that referenced this pull request Oct 19, 2020
nim-ka pushed a commit to nim-ka/sm64 that referenced this pull request Nov 29, 2020
Add Docker config and update README
DbpGaming pushed a commit to DbpGaming/sm64 that referenced this pull request Nov 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants