Skip to content

Commit 4b6b501

Browse files
jezzeWDrijver
andauthored
Update docker build (#144)
This commit rewrites the ApolloOS build image. If you have a machine with docker installed, running ./docker.sh is now all you need to build ApolloOS. Dockerfile: * New base image is ubuntu 22.04 * Dependencies changed to match dependencies.sh * Removed PS1 manipulations to clean things up docker.sh: * Changed tag name to apollo-os-build:latest * Changed the check if the image already was built. * Container is now run as your own user instead of root. * Now uses ./mkapollo.sh all to build. mkapollo.sh: * Add flag to override ports. This was necesserry in my case because the downloads did not work and since the source was already part of the git source I just pointed it to that directory instead. Co-authored-by: Willem Drijver <60568860+WDrijver@users.noreply.github.com>
1 parent 633f402 commit 4b6b501

3 files changed

Lines changed: 43 additions & 137 deletions

File tree

Dockerfile

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,33 @@
11
FROM ubuntu:22.04
2+
WORKDIR /usr/src
23

3-
LABEL maintainer="Georgios Sokianos <walkero@gmail.com>"
4-
5-
ENV DEBIAN_FRONTEND=noninteractive
6-
7-
RUN dpkg --add-architecture i386 && \
8-
apt-get update && apt-get -y install \
9-
autoconf ccache make mmake automake cmake \
10-
gcc g++ gcc-multilib \
11-
wget \
12-
lhasa \
13-
git subversion mercurial \
14-
gawk bison flex netpbm genisoimage sshpass \
15-
python3-mako libswitch-perl gperf \
16-
patch bzip2 ca-certificates xz-utils \
17-
libpng-dev zlib1g-dev libxcursor-dev libgl1-mesa-dev libasound2-dev \
18-
libx11-dev libxext-dev libc6-dev liblzo2-dev libxxf86vm-dev libsdl2-dev \
19-
byacc libxxf86vm1:i386 \
20-
&& [ -e /usr/bin/mkisofs ] || ln -s /usr/bin/genisoimage /usr/bin/mkisofs \
21-
&& apt-get clean \
22-
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
4+
RUN apt-get -y update
5+
RUN apt-get -y install \
6+
autoconf \
7+
automake \
8+
bison \
9+
byacc \
10+
bzip2 \
11+
cmake \
12+
flex \
13+
gawk \
14+
gcc \
15+
genisoimage \
16+
git \
17+
g++ \
18+
libc6-dev \
19+
liblzo2-dev \
20+
libpng-dev \
21+
libsdl1.2-dev \
22+
libx11-dev \
23+
libxcursor-dev \
24+
libxext-dev \
25+
libxxf86vm-dev \
26+
make \
27+
mmake \
28+
netpbm \
29+
wget
30+
RUN apt-get clean
31+
RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
2332

24-
WORKDIR /usr/src
2533
CMD ["/bin/bash"]

docker.sh

Lines changed: 5 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -1,120 +1,10 @@
11
#!/bin/bash
22

3-
IMAGE_NAME="apolloos/builder"
4-
DOCKERFILE="Dockerfile"
3+
IMAGE_NAME=apollo-os-build:latest
54

6-
# Colors
7-
GREEN="\033[1;32m"
8-
RED="\033[1;31m"
9-
YELLOW="\033[1;33m"
10-
RESET="\033[0m"
11-
12-
show_help() {
13-
echo -e "${GREEN}ApolloOS Docker Build Script${RESET}"
14-
echo ""
15-
echo -e "${YELLOW}Usage:${RESET}"
16-
echo " ./docker.sh Build ApolloOS (default)"
17-
echo " ./docker.sh build Build ApolloOS (no clean)"
18-
echo " ./docker.sh clean Clean only (make clean)"
19-
echo " ./docker.sh rebuild Clean + build"
20-
echo " ./docker.sh shell Open a shell inside the Docker build environment"
21-
echo " ./docker.sh --clean-image Delete the Docker image"
22-
echo " ./docker.sh help Show this help"
23-
echo ""
24-
exit 0
25-
}
26-
27-
# -----------------------------
28-
# Determine action
29-
# -----------------------------
30-
if [ -z "$1" ]; then
31-
ACTION="build"
32-
else
33-
ACTION="$1"
34-
fi
35-
36-
# -----------------------------
37-
# Help
38-
# -----------------------------
39-
if [[ "$ACTION" == "help" || "$ACTION" == "-h" || "$ACTION" == "--help" ]]; then
40-
show_help
41-
fi
42-
43-
# -----------------------------
44-
# OPTION: clean → only make clean
45-
# -----------------------------
46-
if [ "$ACTION" == "clean" ]; then
47-
echo -e "${YELLOW}Running make clean inside Docker...${RESET}"
48-
docker run -it --rm \
49-
-v "$PWD":/usr/src \
50-
"$IMAGE_NAME" \
51-
bash -c "cd /usr/src && make clean"
52-
exit 0
53-
fi
54-
55-
# -----------------------------
56-
# OPTION: rebuild → clean + build
57-
# -----------------------------
58-
if [ "$ACTION" == "rebuild" ]; then
59-
echo -e "${YELLOW}Running make clean inside Docker...${RESET}"
60-
docker run -it --rm \
61-
-v "$PWD":/usr/src \
62-
"$IMAGE_NAME" \
63-
bash -c "cd /usr/src && make clean"
64-
65-
echo -e "${GREEN}Rebuilding ApolloOS...${RESET}"
66-
docker run -it --rm \
67-
-v "$PWD":/usr/src \
68-
"$IMAGE_NAME" \
69-
bash -c "cd /usr/src && ./rebuild_all.sh"
70-
exit 0
71-
fi
72-
73-
# -----------------------------
74-
# OPTION: build → build without clean
75-
# -----------------------------
76-
if [ "$ACTION" == "build" ]; then
77-
# Build image if missing
78-
if ! docker image inspect "$IMAGE_NAME" > /dev/null 2>&1; then
79-
echo -e "${YELLOW}Docker image '$IMAGE_NAME' not found. Building it now...${RESET}"
80-
docker build -t "$IMAGE_NAME" .
81-
if [ $? -ne 0 ]; then
82-
echo -e "${RED}❌ Failed to build Docker image. Aborting.${RESET}"
83-
exit 1
84-
fi
85-
fi
86-
87-
echo -e "${GREEN}Building ApolloOS (no clean)...${RESET}"
88-
docker run -it --rm \
89-
-v "$PWD":/usr/src \
90-
"$IMAGE_NAME" \
91-
bash -c "cd /usr/src && ./rebuild_all.sh"
92-
exit 0
93-
fi
94-
95-
# -----------------------------
96-
# OPTION: shell → open interactive shell
97-
# -----------------------------
98-
if [ "$ACTION" == "shell" ]; then
99-
echo -e "${GREEN}Opening shell inside Docker environment...${RESET}"
100-
docker run -it --rm \
101-
-v "$PWD":/usr/src \
102-
"$IMAGE_NAME" \
103-
bash
104-
exit 0
105-
fi
106-
107-
# -----------------------------
108-
# OPTION: --clean-image → delete Docker image
109-
# -----------------------------
110-
if [ "$ACTION" == "--clean-image" ]; then
111-
echo -e "${YELLOW}Removing Docker image '$IMAGE_NAME'...${RESET}"
112-
docker rmi "$IMAGE_NAME"
113-
exit 0
5+
if [ -z "$(docker images -q "${IMAGE_NAME}")" ]
6+
then
7+
docker build -t "${IMAGE_NAME}" .
1148
fi
1159

116-
# -----------------------------
117-
# Unknown option
118-
# -----------------------------
119-
echo -e "${RED}Unknown option: $ACTION${RESET}"
120-
show_help
10+
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"

mkapollo.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ DEBUG=0
2727
CONFO=""
2828
MAKEO=""
2929
EXCLUDE=0
30+
PORTS=""
3031
## END Configuration ##
3132

3233
## BEGIN Beauty Variables ##
@@ -48,7 +49,9 @@ setvars () {
4849
SRC="${DIR}/${WORK}/src"
4950
fi
5051
TEST_CFLAGS="" #-I${DIR}/${WORK}"
51-
PORTS="${DIR}/${WORK}/prt"
52+
if [ -z "${PORTS}" ]; then
53+
PORTS="${DIR}/${WORK}/prt"
54+
fi
5255
BIN="${DIR}/${WORK}/bin"
5356
source ${SRC}/make_dist_config.sh
5457
DISTOPTNAME="--enable-dist-name=${DISTRONAME}"
@@ -210,6 +213,10 @@ for i in "$@"; do
210213
REZ="640x256x4"
211214
shift
212215
;;
216+
--ports=*)
217+
PORTS="${i#*=}"
218+
shift
219+
;;
213220
-v|-v1|--vamp)
214221
VAMP=1
215222
shift
@@ -290,6 +297,7 @@ ${BOLD}mkapollo.sh -- Roll your own ApolloOS image and ROM${NC}
290297
-n,--ntsc Select NTSC build
291298
-o,--opt=# Select optimization level
292299
-p,--pal Select PAL build
300+
--ports Select ports directory
293301
-v,--vamp Compile for True Vampires
294302
-w,--work=<dir> Work directory (will be created if not present)
295303
-x,--exclude When wiping, do not save cross compile tools

0 commit comments

Comments
 (0)