diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..eba5889 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM python:latest + +WORKDIR /app +EXPOSE 5000 + +COPY . /app +RUN apt-get update +RUN apt-get install -y python3-pip sqlite3 ghostscript + +RUN rm /app/instance -rf +RUN bash make.sh init +RUN pip3 install -r requirements.txt +RUN pip3 install gunicorn + + +CMD [ "bash", "make.sh" , "production"] \ No newline at end of file diff --git a/README.md b/README.md index f73da25..b954397 100644 --- a/README.md +++ b/README.md @@ -97,4 +97,4 @@ pybabel update -i partitioncloud/translations/messages.pot -d partitioncloud/tra - [ ] Ajouter config:DISABLE_DARK_MODE - [x] Ajouter config:DISABLE_REGISTER - [ ] Ajouter config:ONLINE_SEARCH_BASE_QUERY pour la recherche google, actuellement 'filetype:pdf partition' -- [ ] Ajouter un Dockerfile +- [x] Ajouter un Dockerfile diff --git a/make.sh b/make.sh index 7f22af3..1b2e3c4 100755 --- a/make.sh +++ b/make.sh @@ -9,7 +9,7 @@ init () { mkdir -p "$INSTANCE_PATH/search-partitions" mkdir -p "$INSTANCE_PATH/cache/thumbnails" mkdir -p "$INSTANCE_PATH/cache/search-thumbnails" - + if ! test -f "$INSTANCE_PATH/config.py"; then echo "SECRET_KEY=\"$(python3 -c 'import secrets; print(secrets.token_hex())')\"" > "$INSTANCE_PATH/config.py" fi @@ -18,6 +18,7 @@ init () { printf "Souhaitez vous supprimer la base de données existante ? [y/n] " read -r CONFIRMATION [[ $CONFIRMATION == y ]] || exit 1 + rm "$INSTANCE_PATH/partitioncloud.sqlite" fi sqlite3 "$INSTANCE_PATH/partitioncloud.sqlite" '.read partitioncloud/schema.sql' echo "Base de données créé" @@ -40,7 +41,7 @@ start () { production () { pybabel compile -d partitioncloud/translations/ - FLASK_APP=partitioncloud /usr/bin/gunicorn \ + FLASK_APP=partitioncloud gunicorn \ wsgi:app \ --bind 0.0.0.0:$PORT } @@ -65,7 +66,11 @@ RESULT=$(type "$1") if [[ $1 && $RESULT = *"is a"*"function"* || $RESULT == *"est une fonction"* ]]; then # Import config load_config "default_config.py" - [[ ! -x "$INSTANCE_PATH/config.py" ]] && load_config "$INSTANCE_PATH/config.py" + + if test -f "instance/config.py"; then + load_config "instance/config.py" + fi + $1 ${*:2} # Call the function else usage