feat(docker): now working properly

This commit is contained in:
Laureηt 2021-11-10 00:20:00 +01:00
parent 711951cb32
commit 8d85f8b33c
No known key found for this signature in database
GPG key ID: D88C6B294FD40994
7 changed files with 84 additions and 35 deletions

View file

@ -1,6 +1,6 @@
FROM python:alpine AS base
# set /code as the workdirectory
# set /code as the work directory
WORKDIR /code
RUN \
@ -14,7 +14,7 @@ RUN \
&& pip install poetry cffi
# copy poetry config files
COPY ./pyproject.toml /code/
COPY ./pyproject.toml /code
RUN \
cd /code \
@ -28,43 +28,32 @@ RUN \
&& cmake -DBUILD_PYTHON=ON -DBUILD_QT=OFF -DBUILD_SDL=OFF -DUSE_DISCORD_RPC=OFF -DCMAKE_INSTALL_PREFIX:PATH=/usr/local .. \
# build mGBA
&& 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
# install mGBA
&& make install
RUN \
cd /code/mgba/src/platform/python \
# install mGBA bindings
&& BINDIR=/code/mgba/build/include LIBDIR=/code/mgba/build/include python setup.py install
RUN \
# go to the workdir
cd /code/ \
# config poetry to not create a .venv
# # config poetry to not create a .venv
&& poetry config virtualenvs.create false \
# upgrade pip
# # upgrade pip
&& poetry run pip install --upgrade pip \
# install poetry
&& BINDIR=/code/mgba/build/ LIBDIR=/code/mgba/build/ poetry install --no-interaction --no-ansi --no-dev
# stuck at poetry install !
# elfutils-dev for libelf
# libzip-tools || libzip-dev for libzip
# minizip-dev for minizip
# libedit-dev for libedit
# sqlite-dev for sqlite3
# libepoxy-dev for expoxy
# ffmpeg-dev for libavcodec
# libpng-dev for png
# technique d'enlever le -b et de faire setup.py install fonctionne
&& poetry install --no-interaction --no-ansi --no-dev
# copy the src files
COPY ./src /code/
COPY ./src /code/src
COPY ./roms/pokemon.gba /code/roms/pokemon.gba
# create server image
FROM base as server
CMD [ "poetry","run","python", "/code/server.py" ]
CMD [ "poetry", "run", "python", "/code/src/server.py" ]
# create emulator image
FROM base as emulator
CMD [ "poetry","run","python", "/code/emulator.py" ]
CMD [ "poetry", "run", "python", "/code/src/emulator.py" ]

View file

@ -3,7 +3,7 @@ services:
server:
build:
context: .
target: server
entrypoint: poetry run python src/server.py
ports:
- 6789:6789
depends_on:
@ -11,7 +11,7 @@ services:
emulator:
build:
context: .
target: emulator
entrypoint: poetry run python src/emulator.py
depends_on:
- "rtmp"
- "redis"
@ -23,5 +23,3 @@ services:
image: "tiangolo/nginx-rtmp"
ports:
- 1935:1935
# build mgba dans le conteuneur car broken path sinon

48
memo.full.sh Normal file
View file

@ -0,0 +1,48 @@
0 apk update
1 apk add build-base cmake git
2 apk add libffi-dev elfutils-dev libzip-tools minizip-dev libedit-dev sqlite-dev libepoxy-dev ffmpeg-dev libpng-dev
3 pip install poetry cffi
4 mkdir /code
5 cd /code
6 git clone https://github.com/mgba-emu/mgba.git mgba
7 mkdir mgba/build
8 cd mgba/build
9 cmake -DBUILD_PYTHON=ON -DBUILD_QT=OFF -DBUILD_SDL=OFF -DUSE_DISCORD_RPC=OFF ..
10 make
11 apk add vim
12 vim
13 vim pyproject.tom
14 vim pyproject.toml
15 cd /code
16 poetry config virtualenvs.create false
17 poetry run pip install --upgrade pip
18 vim pyproject.toml
19 poetry run pip install --upgrade pip
20 BINDIR=/code/mgba/build/ LIBDIR=/code/mgba/build/ poetry install --no-interaction --no-ansi --no-dev
21 which python
22 ls /usr/local
23 cmake -DBUILD_PYTHON=ON -DBUILD_QT=OFF -DBUILD_SDL=OFF -DUSE_DISCORD_RPC=OFF -DCMAKE_INSTALL_PREFIX:PATH=/usr/local
24 cmake -DBUILD_PYTHON=ON -DBUILD_QT=OFF -DBUILD_SDL=OFF -DUSE_DISCORD_RPC=OFF -DCMAKE_INSTALL_PREFIX:PATH=/usr/local ..
25 cmake -DBUILD_PYTHON=ON -DBUILD_QT=OFF -DBUILD_SDL=OFF -DUSE_DISCORD_RPC=OFF -DCMAKE_INSTALL_PREFIX:PATH=/usr/local/ ..
26 cd mgba/build
27 cmake -DBUILD_PYTHON=ON -DBUILD_QT=OFF -DBUILD_SDL=OFF -DUSE_DISCORD_RPC=OFF -DCMAKE_INSTALL_PREFIX:PATH=/usr/local/ ..
28 make
29 cd /code/
30 BINDIR=/code/mgba/build/ LIBDIR=/code/mgba/build/ poetry install
31 poetry install
32 cd mgba/src/platform/python/
33 python setup.py install
34 BINDIR=/code/mgba/build/ LIBDIR=/code/mgba/build/ python setup.py install
35 BINDIR=/code/mgba/build/ LIBDIR=/code/mgba/build/ python setup.py installfind
36 find
37 find / | grep flags.h
38 BINDIR=/code/mgba/build/include/ LIBDIR=/code/mgba/build/include/ python setup.py installfind
39 BINDIR=/code/mgba/build/include/ LIBDIR=/code/mgba/build/include/ python setup.py install
40 cd ../../..
41 cd build
42 make install
43 mgba
44 cd ..
45 cd src/platform/python/
46 BINDIR=/code/mgba/build/include/ LIBDIR=/code/mgba/build/include/ python setup.py install
47 history

17
memo.sh Normal file
View file

@ -0,0 +1,17 @@
apk update
apk add build-base cmake git vim
apk add libffi-dev elfutils-dev libzip-tools minizip-dev libedit-dev sqlite-dev libepoxy-dev ffmpeg-dev libpng-dev jpeg-dev
pip install poetry cffi
mkdir /code
cd /code
vim pyproject.toml # copy le pyproject.tom manuel
git clone https://github.com/mgba-emu/mgba.git mgba
mkdir mgba/build
cd mgba/build
cmake -DBUILD_PYTHON=ON -DBUILD_QT=OFF -DBUILD_SDL=OFF -DUSE_DISCORD_RPC=OFF -DCMAKE_INSTALL_PREFIX:PATH=/usr/local/ ..
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

View file

@ -79,7 +79,7 @@
</table>
<script>
var websocket = new WebSocket("ws://127.0.0.1:6789/");
var websocket = new WebSocket("ws://147.127.160.190:6789/");
var a = document.getElementById('a'),
b = document.getElementById('b'),

View file

@ -18,7 +18,6 @@ core.reset()
logging.basicConfig(level=logging.DEBUG)
mgba.log.silence()
r = redis.Redis(host="redis", port=6379, db=0)
# r = redis.Redis(host="redis", port=6379, db=0)
def next_action():

View file

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