Skip to content

Instantly share code, notes, and snippets.

@djfdyuruiry
Last active October 5, 2022 22:52
Show Gist options
  • Save djfdyuruiry/f488289572494c01531e954a999be827 to your computer and use it in GitHub Desktop.
Save djfdyuruiry/f488289572494c01531e954a999be827 to your computer and use it in GitHub Desktop.
Pokered Docker Build

Pokered Docker Build

This gist contains a Dockerfile for building Pokered and other similar game boy disassemblies. It uses Ubuntu LTS and installs all required build tools into a docker image.

The two scripts included allow you build and copy the ROM from Docker:

  • *nix (Linux/OSX etc.): build-docker.sh
  • windows: build-docker.bat

How to use

  • Ensure Docker is installed and running
  • Have a version of Pokered checked out that you want to build
  • Download the Dockerfile and the build script for your OS (see above) to the Pokered directory
    • If on Linux/OSX etc. make the script executable by running: chmod +x build-docker.sh
  • Run the build script from a terminal
  • If all went well a Pokered.gbc file should have been created
set srcDir=%~dp0
set imgName=pokered-builder
set romFilename=pokered/pokered.gbc
@REM build rom inside docker
docker build ^
--target build ^
-t %imgName% ^
%srcDir%
@REM copy rom from docker image to source directory
docker run ^
--name %imgName%-instance ^
%imgName% ^
true
docker cp %imgName%-instance:/build/%romFilename% %srcDir%
docker rm %imgName%-instance
#!/bin/sh
set -ex
srcDir="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
imgName="pokered-builder"
# build rom inside docker
docker build \
--target build \
-t "${imgName}" \
"${srcDir}"
# copy rom from docker image to source directory
docker build \
--target output \
-t "${imgName}" \
--output \
"${srcDir}" \
"${srcDir}"
FROM ubuntu:jammy AS tools
ENV BUILD_DIR /build
ENV RGBDS_DIR ${BUILD_DIR}/rgbds
ENV RGBDS_VER v0.5.2
ENV POKE_DIR ${BUILD_DIR}/pokered
ENV ROM_FILENAME=pokered.gbc
# get required build tools
RUN apt-get update && \
apt-get install -y \
build-essential \
git \
libpng-tools \
libpng-dev \
# rgbds tools
bison \
libbison-dev \
cmake
# build & install rgbds from src
RUN mkdir -p ${RGBDS_DIR} && \
cd ${RGBDS_DIR} && \
git clone https://github.com/gbdev/rgbds . && \
git checkout ${RGBDS_VER} && \
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release && \
cmake --build build && \
cmake --install build
RUN rm -rf ${RGBDS_DIR}
# build the gb rom from current src
FROM tools AS build
RUN mkdir -p ${POKE_DIR}
COPY . ${POKE_DIR}
RUN cd ${POKE_DIR} && make
# copy the gb rom (so buildx can output it)
# example command: docker build --target output --output . .
FROM build AS output
COPY --from=build ${POKE_DIR}/${ROM_FILENAME} ${BUILD_DIR}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment