diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e34dfec --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +FROM python:3.9.15-slim-bullseye + +RUN apt update && apt install default-libmysqlclient-dev build-essential libtk nodejs npm -y + +WORKDIR /app +COPY requirements.txt requirements.txt +RUN pip3 install -r requirements.txt +RUN npm i -g nodemon + +COPY entrypoint.sh entrypoint.sh +RUN chmod +x entrypoint.sh + +COPY index.py index.py +COPY dbutils.py dbutils.py +ADD core core +ADD titles titles +ADD config config +ADD log log +ADD cert cert + +ENTRYPOINT [ "/app/entrypoint.sh" ] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..c43b6e5 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,57 @@ +version: "3.9" +services: + app: + hostname: ma.app + build: . + volumes: + - ./aime:/app/aime + + environment: + CFG_DEV: 1 + CFG_CORE_SERVER_HOSTNAME: 0.0.0.0 + CFG_CORE_DATABASE_HOST: ma.db + CFG_CORE_MEMCACHED_HOSTNAME: ma.memcached + CFG_CORE_AIMEDB_KEY: keyhere + CFG_CHUNI_SERVER_LOGLEVEL: debug + + ports: + - "80:80" + - "8443:8443" + - "22345:22345" + + - "8080:8080" + - "8090:8090" + + depends_on: + db: + condition: service_healthy + + db: + hostname: ma.db + image: mysql:8.0.31-debian + environment: + MYSQL_DATABASE: aime + MYSQL_USER: aime + MYSQL_PASSWORD: aime + MYSQL_ROOT_PASSWORD: AimeRootPassword + healthcheck: + test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"] + timeout: 5s + retries: 5 + + + memcached: + hostname: ma.memcached + image: memcached:1.6.17-bullseye + + phpmyadmin: + hostname: ma.phpmyadmin + image: phpmyadmin:latest + environment: + PMA_HOSTS: ma.db + PMA_USER: root + PMA_PASSWORD: AimeRootPassword + APACHE_PORT: 8080 + ports: + - "8080:8080" + diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..aa95ca8 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +if [[ -z "${CFG_DEV}" ]]; then + echo Production mode + python3 index.py +else + echo Development mode + python3 dbutils.py create + nodemon -w aime --legacy-watch index.py +fi + diff --git a/titles/mai2/base.py b/titles/mai2/base.py index efa30a0..dcb3bcc9 100644 --- a/titles/mai2/base.py +++ b/titles/mai2/base.py @@ -15,8 +15,15 @@ class Mai2Base: self.version = Mai2Constants.VER_MAIMAI self.data = Mai2Data(cfg) self.logger = logging.getLogger("mai2") + + if self.core_config.server.is_develop and self.core_config.title.port > 0: + self.old_server = f"http://{self.core_config.title.hostname}:{self.core_config.title.port}/SDEY/100/" + + else: + self.old_server = f"http://{self.core_config.title.hostname}/SDEY/100/" def handle_get_game_setting_api_request(self, data: Dict): + # TODO: See if making this epoch 0 breaks things reboot_start = date.strftime( datetime.now() + timedelta(hours=3), Mai2Constants.DATE_TIME_FORMAT ) @@ -33,7 +40,7 @@ class Mai2Base: "movieStatus": 0, "movieServerUri": "", "deliverServerUri": "", - "oldServerUri": "", + "oldServerUri": self.old_server, "usbDlServerUri": "", "rebootInterval": 0, }, diff --git a/titles/mai2/index.py b/titles/mai2/index.py index 60a618f..249b3af 100644 --- a/titles/mai2/index.py +++ b/titles/mai2/index.py @@ -102,7 +102,7 @@ class Mai2Servlet: return ( True, f"http://{core_cfg.title.hostname}:{core_cfg.title.port}/{game_code}/$v/", - f"{core_cfg.title.hostname}", + f"{core_cfg.title.hostname}:{core_cfg.title.port}", ) return (