Use multi-stage building for docker

This commit is contained in:
Lorenzo Carletti 2021-12-30 14:04:07 +01:00
parent 71b13445b6
commit ff47b3076d
7 changed files with 25 additions and 23 deletions

View File

@ -73,7 +73,7 @@ The output will be inside the newly created `out` folder.
# Testing
## Testing with Docker
Docker allows easily building without having to install the dependencies.
Docker allows easily testing without having to install the dependencies.
1. Put a MOTHER 1+2 ROM in `bin/m12fresh.gba`
2. While in the root of the project, run: `docker run --rm -it -v $PWD:/home/m2gba/src lorenzooone/m2gba_translation:tester`

View File

@ -1,3 +0,0 @@
#!/bin/bash
docker rm image mother2gba:build
docker build . -t mother2gba:build

View File

@ -1,4 +1,4 @@
FROM mcr.microsoft.com/powershell:ubuntu-20.04
FROM mcr.microsoft.com/powershell:ubuntu-20.04 AS builder
RUN echo "------------------Updating System------------------"
RUN apt update
RUN apt upgrade
@ -27,3 +27,20 @@ RUN chown -R m2gba:m2gba /home/m2gba && chown -R m2gba:m2gba /opt/src
WORKDIR /opt/src
USER m2gba
CMD /home/m2gba/src/docker-scripts/docker-build-rom-script
#------------------- Building the Tester ---------------------
FROM builder AS tester
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 && \
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
WORKDIR /opt/src
CMD /home/m2gba/src/docker-scripts/docker-test-rom-script

View File

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

View File

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

View File

@ -1,15 +0,0 @@
FROM lorenzooone/m2gba_translation: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 && \
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
WORKDIR /opt/src
CMD /home/m2gba/src/docker-scripts/docker-test-rom-script

View File

@ -1,3 +0,0 @@
#!/bin/bash
docker rm image mother2gba:test
docker build . -t mother2gba:test