Skip to content
Merged
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
50 changes: 29 additions & 21 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
FROM ubuntu:22.04
WORKDIR /usr/src

LABEL maintainer="Georgios Sokianos <walkero@gmail.com>"

ENV DEBIAN_FRONTEND=noninteractive

RUN dpkg --add-architecture i386 && \
apt-get update && apt-get -y install \
autoconf ccache make mmake automake cmake \
gcc g++ gcc-multilib \
wget \
lhasa \
git subversion mercurial \
gawk bison flex netpbm genisoimage sshpass \
python3-mako libswitch-perl gperf \
patch bzip2 ca-certificates xz-utils \
libpng-dev zlib1g-dev libxcursor-dev libgl1-mesa-dev libasound2-dev \
libx11-dev libxext-dev libc6-dev liblzo2-dev libxxf86vm-dev libsdl2-dev \
byacc libxxf86vm1:i386 \
&& [ -e /usr/bin/mkisofs ] || ln -s /usr/bin/genisoimage /usr/bin/mkisofs \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN apt-get -y update
RUN apt-get -y install \
autoconf \
automake \
bison \
byacc \
bzip2 \
cmake \
flex \
gawk \
gcc \
genisoimage \
git \
g++ \
libc6-dev \
liblzo2-dev \
libpng-dev \
libsdl1.2-dev \
libx11-dev \
libxcursor-dev \
libxext-dev \
libxxf86vm-dev \
make \
mmake \
netpbm \
wget
RUN apt-get clean
RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

WORKDIR /usr/src
CMD ["/bin/bash"]
120 changes: 5 additions & 115 deletions docker.sh
Original file line number Diff line number Diff line change
@@ -1,120 +1,10 @@
#!/bin/bash

IMAGE_NAME="apolloos/builder"
DOCKERFILE="Dockerfile"
IMAGE_NAME=apollo-os-build:latest

# Colors
GREEN="\033[1;32m"
RED="\033[1;31m"
YELLOW="\033[1;33m"
RESET="\033[0m"

show_help() {
echo -e "${GREEN}ApolloOS Docker Build Script${RESET}"
echo ""
echo -e "${YELLOW}Usage:${RESET}"
echo " ./docker.sh Build ApolloOS (default)"
echo " ./docker.sh build Build ApolloOS (no clean)"
echo " ./docker.sh clean Clean only (make clean)"
echo " ./docker.sh rebuild Clean + build"
echo " ./docker.sh shell Open a shell inside the Docker build environment"
echo " ./docker.sh --clean-image Delete the Docker image"
echo " ./docker.sh help Show this help"
echo ""
exit 0
}

# -----------------------------
# Determine action
# -----------------------------
if [ -z "$1" ]; then
ACTION="build"
else
ACTION="$1"
fi

# -----------------------------
# Help
# -----------------------------
if [[ "$ACTION" == "help" || "$ACTION" == "-h" || "$ACTION" == "--help" ]]; then
show_help
fi

# -----------------------------
# OPTION: clean → only make clean
# -----------------------------
if [ "$ACTION" == "clean" ]; then
echo -e "${YELLOW}Running make clean inside Docker...${RESET}"
docker run -it --rm \
-v "$PWD":/usr/src \
"$IMAGE_NAME" \
bash -c "cd /usr/src && make clean"
exit 0
fi

# -----------------------------
# OPTION: rebuild → clean + build
# -----------------------------
if [ "$ACTION" == "rebuild" ]; then
echo -e "${YELLOW}Running make clean inside Docker...${RESET}"
docker run -it --rm \
-v "$PWD":/usr/src \
"$IMAGE_NAME" \
bash -c "cd /usr/src && make clean"

echo -e "${GREEN}Rebuilding ApolloOS...${RESET}"
docker run -it --rm \
-v "$PWD":/usr/src \
"$IMAGE_NAME" \
bash -c "cd /usr/src && ./rebuild_all.sh"
exit 0
fi

# -----------------------------
# OPTION: build → build without clean
# -----------------------------
if [ "$ACTION" == "build" ]; then
# Build image if missing
if ! docker image inspect "$IMAGE_NAME" > /dev/null 2>&1; then
echo -e "${YELLOW}Docker image '$IMAGE_NAME' not found. Building it now...${RESET}"
docker build -t "$IMAGE_NAME" .
if [ $? -ne 0 ]; then
echo -e "${RED}❌ Failed to build Docker image. Aborting.${RESET}"
exit 1
fi
fi

echo -e "${GREEN}Building ApolloOS (no clean)...${RESET}"
docker run -it --rm \
-v "$PWD":/usr/src \
"$IMAGE_NAME" \
bash -c "cd /usr/src && ./rebuild_all.sh"
exit 0
fi

# -----------------------------
# OPTION: shell → open interactive shell
# -----------------------------
if [ "$ACTION" == "shell" ]; then
echo -e "${GREEN}Opening shell inside Docker environment...${RESET}"
docker run -it --rm \
-v "$PWD":/usr/src \
"$IMAGE_NAME" \
bash
exit 0
fi

# -----------------------------
# OPTION: --clean-image → delete Docker image
# -----------------------------
if [ "$ACTION" == "--clean-image" ]; then
echo -e "${YELLOW}Removing Docker image '$IMAGE_NAME'...${RESET}"
docker rmi "$IMAGE_NAME"
exit 0
if [ -z "$(docker images -q "${IMAGE_NAME}")" ]
then
docker build -t "${IMAGE_NAME}" .
fi

# -----------------------------
# Unknown option
# -----------------------------
echo -e "${RED}Unknown option: $ACTION${RESET}"
show_help
docker run -it --rm -v /etc/passwd:/etc/passwd:ro -v /etc/group:/etc/group:ro -v "${PWD}":/usr/src -u "$(id -u):$(id -g)" "${IMAGE_NAME}" /bin/bash -c "./mkapollo.sh --ports=/usr/src/bin/Sources all"
10 changes: 9 additions & 1 deletion mkapollo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ DEBUG=0
CONFO=""
MAKEO=""
EXCLUDE=0
PORTS=""
## END Configuration ##

## BEGIN Beauty Variables ##
Expand All @@ -48,7 +49,9 @@ setvars () {
SRC="${DIR}/${WORK}/src"
fi
TEST_CFLAGS="" #-I${DIR}/${WORK}"
PORTS="${DIR}/${WORK}/prt"
if [ -z "${PORTS}" ]; then
PORTS="${DIR}/${WORK}/prt"
fi
BIN="${DIR}/${WORK}/bin"
source ${SRC}/make_dist_config.sh
DISTOPTNAME="--enable-dist-name=${DISTRONAME}"
Expand Down Expand Up @@ -210,6 +213,10 @@ for i in "$@"; do
REZ="640x256x4"
shift
;;
--ports=*)
PORTS="${i#*=}"
shift
;;
-v|-v1|--vamp)
VAMP=1
shift
Expand Down Expand Up @@ -290,6 +297,7 @@ ${BOLD}mkapollo.sh -- Roll your own ApolloOS image and ROM${NC}
-n,--ntsc Select NTSC build
-o,--opt=# Select optimization level
-p,--pal Select PAL build
--ports Select ports directory
-v,--vamp Compile for True Vampires
-w,--work=<dir> Work directory (will be created if not present)
-x,--exclude When wiping, do not save cross compile tools
Expand Down