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/README.md b/README.md index a43853e..617ba3e 100644 --- a/README.md +++ b/README.md @@ -14,3 +14,10 @@ _(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. diff --git a/app/_config.py b/app/_config.py index 518944a..ff87515 100644 --- a/app/_config.py +++ b/app/_config.py @@ -12,7 +12,7 @@ app_maintenance = False app_name = 'takeus-ipam' app_version = 'V1.3' app_release_date = '02/2025' -app_url = "http://127.0.0.1" +app_url = "http://0.0.0.0" class Configuration: # replace SECRET_KEY with value from "openssl rand -hex 32" or similar for STATIC sessions @@ -25,4 +25,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/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..f976986 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,13 @@ +name: Flask-IPAM +services: + flask-ipam: + image: ghcr.io/cafrays/flask_ipam:latest + container_name: flask-ipam + restart: unless-stopped + ports: + - 5000:5000 + volumes: + - flask-ipam:/fipam/instance + +volumes: + flask-ipam: diff --git a/install.md b/install.md index f5886da..0d38692 100644 --- a/install.md +++ b/install.md @@ -2,10 +2,16 @@ 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
-- You don't need to create `wsgi.py`, when asked, replace : `wsgi:app` with `'app:create_app()'` . +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` +- 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 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`)_ 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