diff --git a/Dockerfile b/Dockerfile index 137e91c..04e84b5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,7 +27,10 @@ RUN pip install --no-cache-dir -r files/requirements.txt COPY . . +RUN rm files/db.sqlite -f + RUN /usr/local/bin/alembic -c alembic/alembic.ini upgrade head # Command to run the FastAPI application -CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8080"] \ No newline at end of file +# CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8080"] +CMD ["bash", "/app/scripts/run.sh"] \ No newline at end of file diff --git a/README.md b/README.md index 497f859..70a73ea 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ mkdir -p ~/.db-middleware/scripts && rm -rf ~/.db-middleware/scripts/* && cd ~/.db-middleware/scripts && wget -qO setup.sh https://gitea.abdulhade.com/abdulhade/db-middleware/raw/branch/main/scripts/setup.sh && -sudo bash setup.sh +bash setup.sh ``` diff --git a/scripts/manager.sh b/scripts/manager.sh index af60b94..a053493 100755 --- a/scripts/manager.sh +++ b/scripts/manager.sh @@ -230,9 +230,9 @@ load_config() { get_run_command() { local RUN_COMMAND="docker run -d --name $CONTAINER_NAME" if [[ $HAS_LOCAL_DBS -eq 1 || $HAS_LOCAL_DBS == "1" ]]; then - RUN_COMMAND+=" --network host" + RUN_COMMAND+=" --env API_HOST=localhost --env API_PORT=${API_PORT:-8080} --network host" else - RUN_COMMAND+=" -p ${API_PORT:-8080}:8080" + RUN_COMMAND+=" --env API_HOST=0.0.0.0 --env API_PORT=${API_PORT:-8080} -p ${API_PORT:-8080}:8080" fi RUN_COMMAND+=" $IMAGE_NAME" echo $RUN_COMMAND @@ -664,6 +664,7 @@ main() { restart) restart;; status) status ;; show_config) show_config ;; + update_config) update_config;; stop) stop ;; *) echo "Invalid argument: $1"; usage ;; esac diff --git a/scripts/run.sh b/scripts/run.sh new file mode 100755 index 0000000..68ccc85 --- /dev/null +++ b/scripts/run.sh @@ -0,0 +1,4 @@ + +#!/bin/bash + +uvicorn main:app --host $API_HOST --port $API_PORT \ No newline at end of file diff --git a/scripts/setup.sh b/scripts/setup.sh index b30a20e..9345ad5 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -55,6 +55,6 @@ export PATH="$HOME/.local/bin:$PATH" source ~/.bashrc sudo usermod -aG docker $USER - +newgrp docker # Run the manager.sh script with the "install" argument "$APP_DIR/scripts/manager.sh" install \ No newline at end of file