From 26994d45362647b4cadd4c0d86f9ff13f4ed8cc8 Mon Sep 17 00:00:00 2001 From: David Rodenkirchen Date: Sun, 23 Mar 2025 17:20:14 +0100 Subject: [PATCH] dockerize --- Dockerfile | 12 ++++++++++++ README.md | 14 ++++++++++++++ docker-compose.yml | 36 ++++++++++++++++++++++++++++++++++++ requirements.txt | Bin 186 -> 186 bytes src/EzLanManager.py | 5 ++++- 5 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..312db80 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM python:3.12-bookworm + +RUN apt-get update +RUN apt install dumb-init + +COPY requirements.txt . +RUN pip install -r requirements.txt + +EXPOSE 8000 +EXPOSE 8001 + +ENTRYPOINT ["/usr/bin/dumb-init", "--"] diff --git a/README.md b/README.md index dceccb6..3d89b00 100644 --- a/README.md +++ b/README.md @@ -29,3 +29,17 @@ Use `pip install -r requirements.txt` to install the requirements. The usage of ### Step 4: Running the application Run the application by executing the file `EzLanManager.py` found at `src/ez_lan_manager`. Check the STDOUT for information regarding the port on which the application is now served. + +## Docker Deployment + +To get the docker compose setup running, you need to manually complete the following steps: + +1. Create a valid `config.toml` in the project root, so it gets copied over into the container. +2. Create the database user: +```sql +CREATE USER 'ez_lan_manager'@'%' IDENTIFIED BY 'PASSWORD'; +GRANT ALL PRIVILEGES ON ez_lan_manager.* TO 'ez_lan_manager'@'%'; +FLUSH PRIVILEGES; +``` +3. Make sure to **NOT** use the default passwords! +4. Apply the `create_database.sql` when starting the MariaDB container for the first time. diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..229e059 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,36 @@ +services: + lan_manager: + build: . + depends_on: + db: + condition: service_healthy + environment: + PYTHONPATH: /opt/ez-lan-manager + ports: + - "8000:8000" + - "8001:8001" + volumes: + - ./:/opt/ez-lan-manager + entrypoint: ["/bin/sh", "-c", "cd /opt/ez-lan-manager/src && python3 /opt/ez-lan-manager/src/EzLanManager.py"] + + db: + image: mariadb:latest + environment: + MARIADB_ROOT_PASSWORD: Alkohol1 + MARIADB_DATABASE: ez_lan_manager + MARIADB_USER: ez_lan_manager + MARIADB_PASSWORD: Alkohol1 + healthcheck: + test: ["CMD", "mariadb-admin", "ping", "-h", "localhost"] + interval: 5s + timeout: 3s + retries: 5 + ports: + - "127.0.0.1:3306:3306" + volumes: + - database:/var/lib/mysql + - ./sql/create_database.sql:/docker-entrypoint-initdb.d/init.sql + + +volumes: + database: diff --git a/requirements.txt b/requirements.txt index 08c2369265a31b272fe3805856d2566ec4f2f140..9cc8d0beec75091810f7e0ad17633d9b3996ab16 100644 GIT binary patch delta 15 WcmdnRxQlT@9IGLN9)sb;