Skip to content

Add Docker support #186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM ubuntu:20.04 as build
ENV TZ=Etc/UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

# Install dependencies
## apt install python & libraries
RUN apt-get update && \
apt-get install -y \
python3 \
python3-pip \
libjpeg-dev \
zlib1g-dev \
libsdl2-dev \
git \
wget

## install python dependencies
COPY requirements.txt /tmp/
RUN pip3 install -r /tmp/requirements.txt

## Windows build dependencies
#RUN apt-get install -y \
# binutils-mingw-w64
#RUN apt-get install -y \
# tcc \
# unzip

## Switch build dependencies

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not break out to separate Dockerfiles per target?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not a bad idea. My original thought was to specify targets using arguments. But different Dockerfiles per target would be clearer and split out the process to be maintained separately.

When I have some free cycles, I'll redo this PR. Unless someone else beats me to it 😉😂

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a docker expert, but I think duplicating information into multiple Dockerfiles is not very DRY.

Is there a way to have a common dockerfile for the others to reference?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is better to keep it in one Dockerfile, that way you can call both jobs, reusing code and decreasing build time.

### Install devkitpro for switch build
#RUN wget https://apt.devkitpro.org/install-devkitpro-pacman && \
# chmod +x ./install-devkitpro-pacman && \
# sed -i 's/apt-get/apt-get -y /g' ./install-devkitpro-pacman && \
# ./install-devkitpro-pacman
### Install switch development tools
#RUN ln -s /proc/self/mounts /etc/mtab
#RUN dkp-pacman --noconfirm -S switch-dev switch-sdl2 switch-tools

RUN mkdir /zelda3
WORKDIR /zelda3

CMD echo 'usage: docker run --rm --mount type=bind,source="$(pwd)",destination=/zelda3 zelda3 make'
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,28 @@ make # Add -j$(nproc) to build using all cores ( Optional )
nxlink -s zelda3.nro
```

## Building using Docker
In case you have Docker/Podman intalled you can build a docker image using the `Dockerfile` instead of using the above methods.

### Build the Docker Image

This only needs to be done one time unless the `Dockerfile` has been updated/changed

Clone this repo first

Make sure you are in the root path of this repo
```sh
docker build . -t zelda3
```

### Build the game
Ensure the rom named zelda3.sfc is in the `tables` directory

#### Build for Linux
```sh
docker run --rm --mount type=bind,source="$(pwd)",destination=/zelda3 zelda3 make
```

## More Compilation Help

Look at the wiki at https://github.com/snesrev/zelda3/wiki for more help.
Expand Down