feat: divided by 5 the size of the emulator image thanks to docker multi-stage

This commit is contained in:
Laureηt 2022-03-05 00:42:43 +01:00
parent 7d73a1b99f
commit 14aa100ab2
No known key found for this signature in database
GPG key ID: D88C6B294FD40994

View file

@ -9,14 +9,13 @@ RUN apk update
RUN apk add --no-cache build-base cmake git RUN apk add --no-cache build-base cmake git
# mgba dependencies # mgba dependencies
RUN apk add --no-cache libffi-dev ffmpeg ffmpeg-dev libpng-dev jpeg-dev RUN apk add --no-cache libffi-dev ffmpeg ffmpeg-dev libpng-dev jpeg-dev
RUN pip install cffi RUN pip install --user cffi
# clone mgba # clone mgba
RUN git clone https://github.com/mgba-emu/mgba.git RUN git clone https://github.com/mgba-emu/mgba.git
# create build directory # create build directory
WORKDIR /src/mgba/build/ WORKDIR /src/mgba/build/
# configure the build # configure the build
RUN cmake \ RUN cmake \
-DBUILD_PYTHON=ON \ -DBUILD_PYTHON=ON \
-DBUILD_QT=OFF \ -DBUILD_QT=OFF \
@ -42,7 +41,7 @@ RUN cmake \
.. ..
# build mGBA # build mGBA
RUN make RUN make
# install mGBA, TODO: is install needed ? # install mGBA
RUN make install RUN make install
WORKDIR /src WORKDIR /src
@ -51,13 +50,20 @@ RUN pip install --upgrade pip
# copy requirements.txt for installation # copy requirements.txt for installation
COPY requirements.txt /src/ COPY requirements.txt /src/
# install python dependencies # install python dependencies
RUN pip install -r /src/requirements.txt RUN pip install --user -r /src/requirements.txt
# remove requirements.txt
RUN rm /src/requirements.txt
# install mGBA bindings, TODO: can delete everything else ? # install mGBA bindings
WORKDIR /src/mgba/src/platform/python WORKDIR /src/mgba/src/platform/python
RUN BINDIR=/src/mgba/build/include LIBDIR=/src/mgba/build/include python setup.py install RUN BINDIR=/src/mgba/build/include LIBDIR=/src/mgba/build/include python setup.py install --user
FROM python:alpine
# install required libraries
RUN apk add --no-cache ffmpeg
# copy necessary mgba files
COPY --from=base /root/.local /root/.local
COPY --from=base /usr/local/lib/libmgba.so* /usr/local/lib/
# copy the src files # copy the src files
WORKDIR /src WORKDIR /src