Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ WORKDIR /app

# App code
COPY . .
COPY example.env .env

# Install deps (only main/runtime deps)
RUN poetry install --no-interaction --no-ansi --only main
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
global-include *.yaml
global-include *.env
14 changes: 2 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,7 @@ Then run the following command to get up and running:
poetry lock && poetry install --all-extras
```

Once you have that, get a baseline `.env` and run the API:

```shell
cp example.env .env
```
Once you have that run the API:

```shell
poetry run python3 icoapi/api.py
Expand All @@ -75,13 +71,7 @@ INSTALL_DIR="/etc/icoapi"
SERVICE_PATH="/etc/systemd/system"
```

Please note that the install script expects that the root folder of the repository contains an `.env` configuration file. You can use `example.env` as starting point:

```sh
cp example.env .env
```

After you created the configuration file, run the script to install normally:
Run the script to install normally:

```sh
./install.sh
Expand Down
File renamed without changes.
7 changes: 7 additions & 0 deletions icoapi/scripts/file_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from typing import Tuple
import shutil
import re
from importlib.resources import files


from dotenv import load_dotenv
from platformdirs import user_data_dir
Expand All @@ -26,6 +28,11 @@ def load_env_file():
bundle_dir = sys._MEIPASS
logger.warning(f"Environment variables not found in local directory. Trying to load from app data: {bundle_dir}")
env_loaded = load_dotenv(os.path.join(bundle_dir, "config", ".env"), verbose=True)
if not env_loaded:
# Fourth try: load default configuration from package data
package_data = files('icoapi').joinpath("config")
logger.warning(f"Environment variables not found in app data. Trying to load from package data: %s", package_data)
env_loaded = load_dotenv(stream=(package_data.joinpath("default.env").open('r', encoding='utf-8')))
if not env_loaded:
logger.critical(f"Environment variables not found")
raise EnvironmentError(".env not found")
Expand Down
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ sudo mkdir -p $INSTALL_DIR
sudo chown $USER:$USER $INSTALL_DIR

echo "Copying application files..."
FILES_AND_DIRS=("config" "$MODULE_NAME" "pyproject.toml" "README.md")
FILES_AND_DIRS=("$MODULE_NAME" "pyproject.toml" "README.md")

for ITEM in "${FILES_AND_DIRS[@]}"; do
#cp -r "$ITEM" "$INSTALL_DIR"
Expand Down