diff --git a/Dockerfile b/Dockerfile index 1615718..c19ff37 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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" ] diff --git a/docker-compose.yml b/docker-compose.yml index 65cc934..0c19326 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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: diff --git a/src/emulator.py b/src/emulator.py index 24f5b3c..75784cf 100644 --- a/src/emulator.py +++ b/src/emulator.py @@ -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, ) diff --git a/src/server.py b/src/server.py index e1ad1d7..d22dbd9 100644 --- a/src/server.py +++ b/src/server.py @@ -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