Add Dockerfile

This commit is contained in:
augustin64 2024-02-25 15:56:40 +01:00
parent 5d0535ef70
commit 3cbc586c78
3 changed files with 25 additions and 4 deletions

16
Dockerfile Normal file
View File

@ -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"]

View File

@ -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

11
make.sh
View File

@ -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