Use multi-stage to save space on tester docker

This commit is contained in:
Lorenzooone 2021-12-30 19:45:42 +01:00
parent ff47b3076d
commit fca0331def
3 changed files with 19 additions and 6 deletions

View File

@ -12,6 +12,8 @@ RUN ./dotnet-install.sh -c 2.1
RUN echo "-------------------Installing armips------------------"
RUN git clone --recursive https://github.com/Kingcom/armips.git
WORKDIR /opt/dep/armips
# Need a buildable commit...
RUN git checkout d481fe7a48b3ef02ce5358291a240819ff5742f1
RUN mkdir -p bld
WORKDIR /opt/dep/armips/bld
RUN cmake ../
@ -28,19 +30,30 @@ WORKDIR /opt/src
USER m2gba
CMD /home/m2gba/src/docker-scripts/docker-build-rom-script
#------------------- Building the Tester ---------------------
FROM builder AS tester
#---------------------- Building mgba ------------------------
FROM builder AS mgba_builder
USER root
RUN apt-get update && \
apt-get install -y --no-install-recommends build-essential ccache cmake \
git libavcodec-dev libavfilter-dev libavformat-dev libavresample-dev \
libavutil-dev libcmocka-dev libedit-dev libelf-dev libpng-dev \
libqt5opengl5-dev libsdl2-dev libsqlite3-dev libswscale-dev \
libzip-dev qtmultimedia5-dev qttools5-dev qttools5-dev-tools xvfb pulseaudio alsa-utils && \
libzip-dev qtmultimedia5-dev qttools5-dev qttools5-dev-tools && \
apt-get autoremove -y && apt-get clean
WORKDIR /home/m2gba
USER m2gba
RUN git clone https://github.com/mgba-emu/mgba.git
RUN cd mgba && mkdir build && cd build && cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr .. && make && cp sdl/mgba /opt/src/bin/mgba-sdl
RUN cd mgba && mkdir build && cd build && cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr .. && make
#------------------- Building the Tester ---------------------
FROM builder AS tester
USER root
RUN apt-get update && \
apt-get install -y --no-install-recommends xvfb pulseaudio alsa-utils libsdl2-dev \
libzip-dev libavcodec-dev libavfilter-dev && \
apt-get autoremove -y && apt-get clean
WORKDIR /opt/src
USER m2gba
COPY --from=mgba_builder /home/m2gba/mgba/build/sdl/mgba ./bin/mgba-sdl
COPY --from=mgba_builder /home/m2gba/mgba/build/libmgba* ./
CMD /home/m2gba/src/docker-scripts/docker-test-rom-script

2
docker-scripts/build-dockers/build-builder.sh Normal file → Executable file
View File

@ -1,3 +1,3 @@
#!/bin/bash
docker rm image lorenzooone/m2gba_translation:builder
docker image rm lorenzooone/m2gba_translation:builder
docker build --target builder . -t lorenzooone/m2gba_translation:builder

2
docker-scripts/build-dockers/build-tester.sh Normal file → Executable file
View File

@ -1,3 +1,3 @@
#!/bin/bash
docker rm image lorenzooone/m2gba_translation:tester
docker image rm lorenzooone/m2gba_translation:tester
docker build --target tester . -t lorenzooone/m2gba_translation:tester