ÇA MARCHE À LA ZEUB MAIS ÇA MARCHE

This commit is contained in:
Clément RIVOLA 2021-11-09 20:56:57 +01:00
parent b3872eff89
commit a17b80c731
4 changed files with 27 additions and 12 deletions

View file

@ -9,10 +9,13 @@ RUN \
# build tools dependencies
&& apk add build-base cmake git \
# mgba dependencies
&& apk add libffi-dev elfutils-dev libzip-tools minizip-dev libedit-dev sqlite-dev libepoxy-dev ffmpeg-dev libpng-dev \
&& apk add libffi-dev elfutils-dev libzip-tools minizip-dev libedit-dev sqlite-dev libepoxy-dev ffmpeg ffmpeg-dev libpng-dev jpeg-dev \
# install poetry and cffi deps for mgba
&& pip install poetry cffi
# copy poetry config files
COPY ./pyproject.toml /code/
RUN \
cd /code \
# clone mgba
@ -22,12 +25,17 @@ RUN \
# go to the build directory
&& cd mgba/build \
# configure the build
&& cmake -DBUILD_PYTHON=ON -DBUILD_QT=OFF -DBUILD_SDL=OFF -DUSE_DISCORD_RPC=OFF .. \
&& cmake -DBUILD_PYTHON=ON -DBUILD_QT=OFF -DBUILD_SDL=OFF -DUSE_DISCORD_RPC=OFF -DCMAKE_INSTALL_PREFIX:PATH=/usr/local .. \
# build mGBA
&& make
&& make \
&& make install \
&& cd /code/mgba/src/platform/python/ \
&& BINDIR=/code/mgba/build/include/ LIBDIR=/code/mgba/build/include/ python setup.py install \
&& cd /code/ \
&& poetry install
# copy poetry config files
COPY ./poetry.lock ./pyproject.toml /code/
RUN \
# go to the workdir
@ -52,11 +60,11 @@ RUN \
# copy the src files
COPY ./src /code/
COPY ./roms/pokemon.gba /code/roms/pokemon.gba
# create server image
FROM base as server
CMD [ "python", "/code/server.py" ]
CMD [ "poetry","run","python", "/code/server.py" ]
# create emulator image
FROM base as emulator
CMD [ "python", "/code/emulator.py" ]
CMD [ "poetry","run","python", "/code/emulator.py" ]

View file

@ -6,12 +6,19 @@ services:
target: server
ports:
- 6789:6789
depends_on:
- "redis"
emulator:
build:
context: .
target: emulator
depends_on:
- "rtmp"
- "redis"
redis:
image: "redis:alpine"
ports:
- 6379:6379
rtmp:
image: "tiangolo/nginx-rtmp"
ports:

View file

@ -17,7 +17,7 @@ core.reset()
logging.basicConfig(level=logging.DEBUG)
mgba.log.silence()
r = redis.Redis(host="localhost", port=6379, db=0)
r = redis.Redis(host="redis", port=6379, db=0)
# r = redis.Redis(host="redis", port=6379, db=0)
@ -63,7 +63,7 @@ stream = Popen(
"low_delay",
"-strict",
"experimental",
"rtmp://localhost:1935/live/test",
"rtmp://rtmp:1935/live/test",
],
stdin=PIPE,
)

View file

@ -11,7 +11,7 @@ from utils import User, Users
logging.basicConfig(level=logging.DEBUG)
r = redis.Redis(host="localhost", port=6379, db=0)
r = redis.Redis(host="redis", port=6379, db=0)
# r = redis.Redis(host="redis", port=6379, db=0)
r.mset(REDIS_INIT)
@ -68,7 +68,7 @@ async def handler(websocket, path: str):
async def main():
"""Start the websocket server."""
async with websockets.serve(handler, "localhost", 6789):
async with websockets.serve(handler, "0.0.0.0", 6789):
# async with websockets.serve(handler, "0.0.0.0", 6789):
await asyncio.Future() # run forever