2022-02-08 16:35:48 +00:00
|
|
|
FROM python:alpine AS base
|
2021-11-09 17:19:55 +00:00
|
|
|
|
2021-11-09 23:20:00 +00:00
|
|
|
# set /code as the work directory
|
2021-11-09 17:19:55 +00:00
|
|
|
WORKDIR /code
|
|
|
|
|
|
|
|
RUN \
|
|
|
|
# update alpine repositories
|
|
|
|
apk update \
|
|
|
|
# build tools dependencies
|
2022-02-08 16:35:48 +00:00
|
|
|
&& apk add --no-cache build-base cmake git \
|
2021-11-09 17:19:55 +00:00
|
|
|
# mgba dependencies
|
2022-02-08 16:35:48 +00:00
|
|
|
&& apk add --no-cache libffi-dev elfutils-dev libzip-tools minizip-dev libedit-dev sqlite-dev libepoxy-dev ffmpeg ffmpeg-dev libpng-dev jpeg-dev \
|
|
|
|
&& pip install cffi
|
2021-11-09 19:56:57 +00:00
|
|
|
|
2021-11-09 17:19:55 +00:00
|
|
|
RUN \
|
|
|
|
cd /code \
|
|
|
|
# clone mgba
|
2022-02-08 16:35:48 +00:00
|
|
|
&& git clone https://github.com/mgba-emu/mgba.git --branch 0.9 mgba \
|
2021-11-09 17:19:55 +00:00
|
|
|
# create build directory
|
|
|
|
&& mkdir mgba/build \
|
|
|
|
# go to the build directory
|
|
|
|
&& cd mgba/build \
|
|
|
|
# configure the build
|
2021-11-09 19:56:57 +00:00
|
|
|
&& cmake -DBUILD_PYTHON=ON -DBUILD_QT=OFF -DBUILD_SDL=OFF -DUSE_DISCORD_RPC=OFF -DCMAKE_INSTALL_PREFIX:PATH=/usr/local .. \
|
2021-11-09 17:19:55 +00:00
|
|
|
# build mGBA
|
2021-11-09 19:56:57 +00:00
|
|
|
&& make \
|
2022-02-08 16:35:48 +00:00
|
|
|
# install mGBA, TODO: is install needed ?
|
2021-11-09 23:20:00 +00:00
|
|
|
&& make install
|
2021-11-09 17:19:55 +00:00
|
|
|
|
2022-02-08 16:35:48 +00:00
|
|
|
# copy poetry config file
|
|
|
|
COPY ./pyproject.toml /code
|
2021-11-09 17:19:55 +00:00
|
|
|
|
|
|
|
RUN \
|
2022-02-08 16:35:48 +00:00
|
|
|
cd /code \
|
2021-11-09 17:19:55 +00:00
|
|
|
# install poetry
|
2022-02-08 16:35:48 +00:00
|
|
|
&& pip install poetry \
|
|
|
|
# config poetry to not create a .venv
|
|
|
|
&& poetry config virtualenvs.create false \
|
|
|
|
# upgrade pip
|
|
|
|
&& poetry run pip install --upgrade pip
|
|
|
|
|
|
|
|
RUN \
|
|
|
|
cd /code/mgba/src/platform/python \
|
|
|
|
# install mGBA bindings, TODO: can delete everything else ?
|
|
|
|
&& BINDIR=/code/mgba/build/include LIBDIR=/code/mgba/build/include python setup.py install
|
2021-11-09 17:19:55 +00:00
|
|
|
|
|
|
|
# copy the src files
|
2021-11-09 23:20:00 +00:00
|
|
|
COPY ./src /code/src
|
2022-02-08 16:35:48 +00:00
|
|
|
|
|
|
|
FROM base AS prod
|
|
|
|
RUN poetry install --no-interaction --no-ansi --no-dev
|
|
|
|
|
|
|
|
FROM prod as dev
|
|
|
|
RUN poetry install --no-interaction --no-ansi
|
|
|
|
|
|
|
|
FROM prod AS server
|
|
|
|
CMD [ "poetry", "run", "python", "src/server.py" ]
|
|
|
|
|
|
|
|
FROM prod AS emulator
|
|
|
|
CMD [ "poetry", "run", "python", "src/emulator.py" ]
|