From 1464767d4e29f80ca55030818cc8f7dc875d2e9e Mon Sep 17 00:00:00 2001 From: Cafray <165210113+cafrays@users.noreply.github.com> Date: Thu, 27 Mar 2025 14:36:59 -0400 Subject: [PATCH 1/9] Update install.md Adding missing steps --- install.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/install.md b/install.md index f5886da..7dce528 100644 --- a/install.md +++ b/install.md @@ -2,10 +2,12 @@ This documentation is very good, but needs a few changes to make it work (in our case) : https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-ubuntu-22-04
+Before starting the app ensure to intall pip packages in requirements.txt [Section](https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-ubuntu-22-04#step-4-configuring-gunicorn) +- `pip install Flask-Login Flask-SQLAlchemy Flask-WTF mysql-connector-python SQLAlchemy cryptography` - You don't need to create `wsgi.py`, when asked, replace : `wsgi:app` with `'app:create_app()'` . - EX : For starting APP with gunicorn : `gunicorn --bind 0.0.0.0:5000 'app:create_app()'` - In Service File, replace "ExecStart" line with :
-`ExecStart=/YOUR_ENV_LOCATION/bin/gunicorn --workers 1 --bind unix:fipam.sock -m 007 'app:create_app()'`
+`ExecStart=/YOUR_ENV_LOCATION/bin/gunicorn --workers 1 --bind 0.0.0.0:5000 -m 007 'app:create_app()'`
_(Adjust the number of workers to your needs)_ - you must first run setup.py to create the admin user.
_(it will create a second database in `./var/setup-instance`. It will have to be merged in the application database in `./var/app-instance`)_ From 1c8ec0c159a32078dc1ad789c6fcbb92e3e78000 Mon Sep 17 00:00:00 2001 From: Cafray <165210113+cafrays@users.noreply.github.com> Date: Thu, 27 Mar 2025 15:44:24 -0400 Subject: [PATCH 2/9] Update install.md Typo correction and added instructions to update app/_config.py --- install.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/install.md b/install.md index 7dce528..0d38692 100644 --- a/install.md +++ b/install.md @@ -2,10 +2,14 @@ This documentation is very good, but needs a few changes to make it work (in our case) : https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-ubuntu-22-04
-Before starting the app ensure to intall pip packages in requirements.txt [Section](https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-ubuntu-22-04#step-4-configuring-gunicorn) +Before starting the app ensure to install pip packages in requirements.txt Referrenced [Section](https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-ubuntu-22-04#step-4-configuring-gunicorn) - `pip install Flask-Login Flask-SQLAlchemy Flask-WTF mysql-connector-python SQLAlchemy cryptography` -- You don't need to create `wsgi.py`, when asked, replace : `wsgi:app` with `'app:create_app()'` . +- Update the configuration file under _app/\_config.py_. + - `app_ip = '127.0.0.1'` to `app_ip = '0.0.0.0'` for easy web access. + - Update **SECRET_KEY='CHANGE_ME'** variable, `openssl rand -hex 32` can be used to create a random key. +- You don't need to create or continue with the `wsgi.py` section. When asked, replace: `wsgi:app` with `'app:create_app()'` . - EX : For starting APP with gunicorn : `gunicorn --bind 0.0.0.0:5000 'app:create_app()'` + - For any troubleshooting, you can add `--preload` at the end of the command for verbose logging. - In Service File, replace "ExecStart" line with :
`ExecStart=/YOUR_ENV_LOCATION/bin/gunicorn --workers 1 --bind 0.0.0.0:5000 -m 007 'app:create_app()'`
_(Adjust the number of workers to your needs)_ From 55aaeae1da48f6e294b383486277f088258464ef Mon Sep 17 00:00:00 2001 From: fdrock Date: Sat, 29 Mar 2025 15:10:17 -0400 Subject: [PATCH 3/9] Working on a Docker Container --- Dockerfile | 12 ++++++++++++ app/_config.py | 6 +++--- requirements.txt | 4 +++- setup.py | 0 4 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 Dockerfile mode change 100644 => 100755 setup.py diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1045961 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM python:3.13.2-alpine3.21 +WORKDIR /fipam +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt +COPY app /fipam/app +COPY instance /fipam/instance +ENV APP_HOME=/fipam +ENV PYTHONPATH=${APP_HOME} +ENV PATH="$PATH:${APP_HOME}/.local/bin" +ENV GUNICORN_CMD_ARGS="--bind=0.0.0.0:5000 --workers=2 --preload" +EXPOSE 5000 +ENTRYPOINT ["gunicorn","app:create_app()"] diff --git a/app/_config.py b/app/_config.py index 23d5935..ba5f397 100644 --- a/app/_config.py +++ b/app/_config.py @@ -10,11 +10,11 @@ app_maintenance = False app_name = 'takeus-ipam' app_version = 'V1.2' app_release_date = '02/2025' -app_url = "http://127.0.0.1" +app_url = "http://0.0.0.0" class Configuration: # openssl rand -hex 32 - SECRET_KEY = 'change_me' + SECRET_KEY = '619b2920234c8c472b2a7121c82a5d62ea86a083dc00e2bc9b09b695f00641ea' # DB CONFIG SQLALCHEMY_DATABASE_URI = 'sqlite:///database.db' SQLALCHEMY_TRACK_MODIFICATIONS = False @@ -22,4 +22,4 @@ class Configuration: # CK CONFIG SESSION_COOKIE_SECURE = False # SSL REQUIRED SESSION_COOKIE_HTTPONLY = True - SESSION_COOKIE_SAMESITE = 'Lax' \ No newline at end of file + SESSION_COOKIE_SAMESITE = 'Lax' diff --git a/requirements.txt b/requirements.txt index d97ddf2..c532233 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,9 @@ +wheel +gunicorn Flask Flask-Login Flask-SQLAlchemy Flask-WTF mysql-connector-python SQLAlchemy -cryptography \ No newline at end of file +cryptography diff --git a/setup.py b/setup.py old mode 100644 new mode 100755 From 47d9078473897e558af9b67bf92c68348b4ad263 Mon Sep 17 00:00:00 2001 From: fdrock Date: Sat, 29 Mar 2025 15:42:27 -0400 Subject: [PATCH 4/9] Adding Docker Compose --- docker-compose.yml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..0084e32 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,8 @@ +name: Flask-IPAM +services: + flask-ipam: + image: ghcr.io/cafrays/flask-ipam:latest + container_name: flask-ipam + restart: unless-stopped + ports: + - 5000:5000 From bd40a774d72ac2659315b1ca1c396a4fa4b8c9e9 Mon Sep 17 00:00:00 2001 From: Cafray <165210113+cafrays@users.noreply.github.com> Date: Sat, 29 Mar 2025 15:42:43 -0400 Subject: [PATCH 5/9] Update README.md --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index a43853e..cc9fd63 100644 --- a/README.md +++ b/README.md @@ -14,3 +14,9 @@ _(I'm not an experienced developer, just a tinkerer)_ --- - Installation : [here](install.md) - Sources : [here](sources.md) + +## Docker Compose +The Docker image has a built in admin account, **PLEASE CHANGE PASSWORD AFTER INITIAL LOG IN** +- Username: admin +- Password: PleaseChangeMe +Use docker-compose.yml file to deploy. From a5c9664bf10958f10b6f066e5c422ac27b48a2b5 Mon Sep 17 00:00:00 2001 From: Cafray <165210113+cafrays@users.noreply.github.com> Date: Sat, 29 Mar 2025 15:43:30 -0400 Subject: [PATCH 6/9] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cc9fd63..617ba3e 100644 --- a/README.md +++ b/README.md @@ -18,5 +18,6 @@ _(I'm not an experienced developer, just a tinkerer)_ ## Docker Compose The Docker image has a built in admin account, **PLEASE CHANGE PASSWORD AFTER INITIAL LOG IN** - Username: admin -- Password: PleaseChangeMe +- Password: _PleaseChangeMe_ +
Use docker-compose.yml file to deploy. From e2380e6919763b4a719fa5bc003f222b33cd125c Mon Sep 17 00:00:00 2001 From: fdrock Date: Sat, 29 Mar 2025 21:47:21 -0400 Subject: [PATCH 7/9] Adding volumes to docker compose --- docker-compose.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 0084e32..fb77f82 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,8 +1,13 @@ name: Flask-IPAM services: flask-ipam: - image: ghcr.io/cafrays/flask-ipam:latest + image: ghcr.io/cafrays/flask_ipam:v1.3 container_name: flask-ipam restart: unless-stopped ports: - 5000:5000 + volumes: + - flask-ipam:/fipam/instance + +volumes: + flask-ipam: From 67094b541a54c50cfe2da6a0ab37823916357909 Mon Sep 17 00:00:00 2001 From: fdrock Date: Sat, 29 Mar 2025 21:52:22 -0400 Subject: [PATCH 8/9] Adjusted container version --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index fb77f82..c703c22 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ name: Flask-IPAM services: flask-ipam: - image: ghcr.io/cafrays/flask_ipam:v1.3 + image: ghcr.io/cafrays/flask_ipam:v1.2 container_name: flask-ipam restart: unless-stopped ports: From 275c575e9004e97b391b378d8ec0a7051d03d9f6 Mon Sep 17 00:00:00 2001 From: Takeus <68923554+TakeusV1@users.noreply.github.com> Date: Tue, 1 Apr 2025 11:42:32 +0200 Subject: [PATCH 9/9] Update docker-compose.yml --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index c703c22..f976986 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ name: Flask-IPAM services: flask-ipam: - image: ghcr.io/cafrays/flask_ipam:v1.2 + image: ghcr.io/cafrays/flask_ipam:latest container_name: flask-ipam restart: unless-stopped ports: