Ç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 # build tools dependencies
&& apk add build-base cmake git \ && apk add build-base cmake git \
# mgba dependencies # 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 # install poetry and cffi deps for mgba
&& pip install poetry cffi && pip install poetry cffi
# copy poetry config files
COPY ./pyproject.toml /code/
RUN \ RUN \
cd /code \ cd /code \
# clone mgba # clone mgba
@ -22,12 +25,17 @@ RUN \
# go to the build directory # go to the build directory
&& cd mgba/build \ && cd mgba/build \
# configure the 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 # 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 \ RUN \
# go to the workdir # go to the workdir
@ -52,11 +60,11 @@ RUN \
# copy the src files # copy the src files
COPY ./src /code/ COPY ./src /code/
COPY ./roms/pokemon.gba /code/roms/pokemon.gba
# create server image # create server image
FROM base as server FROM base as server
CMD [ "python", "/code/server.py" ] CMD [ "poetry","run","python", "/code/server.py" ]
# create emulator image # create emulator image
FROM base as emulator 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 target: server
ports: ports:
- 6789:6789 - 6789:6789
depends_on:
- "redis"
emulator: emulator:
build: build:
context: . context: .
target: emulator target: emulator
depends_on:
- "rtmp"
- "redis"
redis: redis:
image: "redis:alpine" image: "redis:alpine"
ports:
- 6379:6379
rtmp: rtmp:
image: "tiangolo/nginx-rtmp" image: "tiangolo/nginx-rtmp"
ports: ports:

View file

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

View file

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