peter
4 years ago
7 changed files with 185 additions and 29 deletions
@ -1,36 +1,152 @@
|
||||
FROM docker.ceres.area51.dev/area51/ubuntu:dev-20.04 AS base |
||||
# ========================================================================================== |
||||
# Base image for both compilation & the final image |
||||
FROM docker.ceres.area51.dev/area51/ubuntu:dev-20.04 AS dev |
||||
|
||||
WORKDIR /work |
||||
|
||||
# ========================================================================================== |
||||
# Container containing X11 |
||||
FROM dev AS base |
||||
# Install dependencies. First set are for X11, the rest are for emulators: |
||||
# x11 xvfb libgl1-mesa-dri |
||||
# beebjit libasound2-dev libpulse-dev libx11-dev libxext-dev |
||||
# z88dk dos2unix libboost-all-dev texinfo texi2html libxml2-dev subversion bison flex zlib1g-dev m4 |
||||
RUN area51-apt-get install -y \ |
||||
xvfb libgl1-mesa-dri \ |
||||
libasound2-dev libpulse-dev libx11-dev libxext-dev \ |
||||
dos2unix libboost-all-dev texinfo texi2html libxml2-dev subversion bison flex zlib1g-dev m4 |
||||
|
||||
# xvfb settings |
||||
COPY xvfb-startup.sh /usr/local/bin/xvfb-startup |
||||
RUN sed -i 's/\r$//' /usr/local/bin/xvfb-startup |
||||
ARG RESOLUTION="1920x1080x24" |
||||
ENV XVFB_RES="${RESOLUTION}" |
||||
ARG XARGS="" |
||||
ENV XVFB_ARGS="${XARGS}" |
||||
|
||||
# ========================================================================================== |
||||
# Retrieve all sources |
||||
FROM base AS src |
||||
RUN curl -s https://nexus.ceres.area51.dev/repository/archives/8bit/assemblers/asmx-2.0b5.zip --output /usr/local/src/asmx-2.0b5.zip |
||||
RUN git clone https://github.com/stardot/beebasm.git &&\ |
||||
git clone https://github.com/dasm-assembler/dasm.git |
||||
RUN git clone https://github.com/stardot/beebasm.git |
||||
RUN git clone https://github.com/dasm-assembler/dasm.git |
||||
RUN git clone https://github.com/scarybeasts/beebjit.git |
||||
|
||||
# Generate tar balls so we have a src option to correctly comply with GPL etc |
||||
RUN mkdir -p /usr/local/src &&\ |
||||
(for i in $(ls -d *); do echo "Archiving $i"; tar czpf /usr/local/src/${i}.tgz ${i};done) |
||||
# Z88dk needs subprojects & sdcc checked out, patch applied then we then comment out those steps from the Makefile |
||||
RUN git clone --recursive https://github.com/z88dk/z88dk |
||||
RUN export Z88DK_PATH=$(pwd)/z88dk &&\ |
||||
export SDCC_VERSION=$(grep -Po 'SDCC_VERSION\W+=\W+\K(.+)' ${Z88DK_PATH}/Makefile) &&\ |
||||
export SDCC_PATH=${Z88DK_PATH}/$(grep -Po 'SDCC_PATH\W+=\W+\$\(Z88DK_PATH\)\/\K(.+)' ${Z88DK_PATH}/Makefile) &&\ |
||||
svn checkout \ |
||||
-r ${SDCC_VERSION} \ |
||||
https://svn.code.sf.net/p/sdcc/code/trunk/sdcc \ |
||||
-q ${SDCC_PATH} &&\ |
||||
patch -d ${SDCC_PATH} -p0 < ${Z88DK_PATH}/src/zsdcc/sdcc-z88dk.patch &&\ |
||||
sed -r \ |
||||
-e '/^\W+svn checkout/ s/^#*/#/g' \ |
||||
-e '/^\W+patch -d/ s/^#*/#/g' \ |
||||
-i ${Z88DK_PATH}/Makefile |
||||
|
||||
|
||||
# Destination directories for installation |
||||
RUN mkdir -p /dest/usr/local/bin /dest/usr/local/share /dest/usr/local/src |
||||
|
||||
# Assemblers |
||||
FROM src AS assemblers |
||||
# Generate tar balls so we have a src option to correctly comply with GPL etc |
||||
RUN (for i in $(ls -d *); do echo "Archiving $i"; tar czpf /dest/usr/local/src/${i}.tgz ${i};done) |
||||
|
||||
# ========================================================================================== |
||||
# Assemblers & Compilers |
||||
# ========================================================================================== |
||||
# Asmx |
||||
# The sed removes the target arch setting which is for a mac |
||||
FROM src AS asmx |
||||
RUN mkdir asmx && cd asmx && unzip /usr/local/src/asmx-2.0b5.zip &&\ |
||||
sed -i -e "s/TARGET_ARCH/#TARGET_ARCH/g" src/Makefile &&\ |
||||
make && make install && mv -v ~/bin/* /usr/local/bin |
||||
make && make install && mv -v ~/bin/* /dest/usr/local/bin |
||||
|
||||
# ========================================================================================== |
||||
# BeebAsm |
||||
RUN cd beebasm/src && make all PLATFORM=linux && cp -p ../beebasm /usr/local/bin/ |
||||
FROM src AS beebasm |
||||
RUN cd beebasm/src && make all PLATFORM=linux && cp -p ../beebasm /dest/usr/local/bin/ |
||||
|
||||
# ========================================================================================== |
||||
# Dasm |
||||
RUN cd dasm/src && make && cp dasm /usr/local/bin/ |
||||
FROM src AS dasm |
||||
RUN cd dasm/src && make && cp dasm /dest/usr/local/bin/ |
||||
|
||||
# ========================================================================================== |
||||
# Z88dk |
||||
FROM src AS z88dk |
||||
RUN cd z88dk && chmod 777 build.sh &&\ |
||||
export BUILD_SDCC=1 &&\ |
||||
export DESTDIR=/dest/usr/local &&\ |
||||
make bin/z88dk-appmake bin/z88dk-copt bin/z88dk-zcpp \ |
||||
bin/z88dk-ucpp bin/sccz80 bin/z88dk-z80asm \ |
||||
bin/zcc bin/z88dk-zpragma bin/z88dk-zx7 \ |
||||
bin/z88dk-z80nm bin/z88dk-zobjcopy \ |
||||
bin/z88dk-ticks bin/z88dk-z80svg \ |
||||
bin/z88dk-font2pv1000 bin/z88dk-basck \ |
||||
bin/z88dk-lib bin/z88dk-zx0 &&\ |
||||
make install |
||||
|
||||
#./build.sh -i /dest/usr/local |
||||
|
||||
# ========================================================================================== |
||||
# Emulators |
||||
# ========================================================================================== |
||||
# beebjit |
||||
FROM src AS beebjit |
||||
RUN cd beebjit && xvfb-startup ./build.sh && cp -p beebjit /dest/usr/local/bin/ |
||||
RUN mkdir -p /dest/usr/local/share/beebjit/ &&\ |
||||
cp -rp beebjit/roms /dest/usr/local/share/beebjit/ |
||||
|
||||
# ========================================================================================== |
||||
# Our own tools built by GO |
||||
# |
||||
# Split into multiple stages: module downloads, src extraction, tests then compilation. |
||||
# Done this way so development doesn't cause a download for every minor change |
||||
FROM docker.ceres.area51.dev/mirror/library/golang:alpine AS goBuild |
||||
WORKDIR /work |
||||
COPY go.mod . |
||||
RUN go mod download |
||||
|
||||
FROM goBuild AS goSrc |
||||
ADD disktool/ disktool/ |
||||
|
||||
#FROM goSrc AS goTest |
||||
#RUN CGO_ENABLED=0 go test -v ./util |
||||
|
||||
FROM goSrc AS tools |
||||
ARG arch |
||||
ARG goos |
||||
ARG goarch |
||||
ARG goarm |
||||
WORKDIR /work |
||||
|
||||
RUN CGO_ENABLED=0 GOOS=${goos} GOARCH=${goarch} GOARM=${goarm} go build \ |
||||
-o /dest/usr/local/bin/disktool ./disktool/bin |
||||
|
||||
# ========================================================================================== |
||||
# This brings everything built into a single layer |
||||
FROM base AS merge |
||||
|
||||
# The src tar balls |
||||
COPY --from=src /dest/ /dest/ |
||||
|
||||
# Assembers & Compilers |
||||
COPY --from=asmx /dest/ /dest/ |
||||
COPY --from=beebasm /dest/ /dest/ |
||||
COPY --from=dasm /dest/ /dest/ |
||||
COPY --from=z88dk /dest/ /dest/ |
||||
|
||||
# Emulators |
||||
COPY --from=beebjit /dest/ /dest/ |
||||
|
||||
#RUN fail |
||||
# Go based tools provided by us |
||||
COPY --from=tools /dest/ /dest/ |
||||
|
||||
# The final d64 |
||||
# ========================================================================================== |
||||
# The final image |
||||
FROM base AS final |
||||
WORKDIR /work |
||||
COPY --from=src /usr/local/src/ /usr/local/src |
||||
COPY --from=assemblers /usr/local/bin/ /usr/local/bin |
||||
COPY --from=merge /dest/ / |
||||
|
Loading…
Reference in new issue