diff --git a/README.md b/README.md index 459be97..a46f2c2 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,17 @@ # enowars8-service-ImagiDate # TODOs -* Make CSS a bit better -* Add ulimits and always restart flags ## php part * make the heart icon beat ;) -* add volumes for images +* Make CSS a bit better ## python part -* add volumes for yaml files -* add cleaner for yaml files +* DONE ## checker part * DONE + ## misc * add extra account for fun ;) * https://github.com/cat-milk/Anime-Girls-Holding-Programming-Books/blob/master/Linux/Ryo_Yamada_Reading_ArchLinux_Book.jpg for Julian diff --git a/service/api/Dockerfile b/service/api/Dockerfile index 4c596ae..c7fb056 100644 --- a/service/api/Dockerfile +++ b/service/api/Dockerfile @@ -9,8 +9,15 @@ RUN mkdir uploads RUN chown -R appuser:appuser /app/uploads/ RUN pip install --no-cache-dir -r requirements.txt -EXPOSE 5000 +COPY run.sh /root +COPY cleaner.sh /root +RUN chmod +x /root/run.sh +RUN chmod +x /root/cleaner.sh +#RUN bash /root/cleaner.sh & +EXPOSE 5000 ENV FLASK_APP=api_server.py -CMD ["flask", "run", "--host=0.0.0.0"] + +ENTRYPOINT /root/run.sh +#CMD ["flask", "run", "--host=0.0.0.0"] #CMD ["flask", "run", "--debug", "--host=0.0.0.0"] \ No newline at end of file diff --git a/service/api/cleaner.sh b/service/api/cleaner.sh new file mode 100644 index 0000000..be43bdc --- /dev/null +++ b/service/api/cleaner.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +directory="/app/uploads" + +while true; do + + find "$directory" -mindepth 1 -maxdepth 1 -mmin +10 -print | while IFS= read -r item; do + echo "Deleting $item" + rm -r "$item" + done + sleep 60 +done diff --git a/service/api/run.sh b/service/api/run.sh new file mode 100644 index 0000000..ab6b034 --- /dev/null +++ b/service/api/run.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +/root/cleaner.sh & + +flask run --host=0.0.0.0 \ No newline at end of file diff --git a/service/docker-compose.yaml b/service/docker-compose.yaml index 63c3ddb..bbab343 100644 --- a/service/docker-compose.yaml +++ b/service/docker-compose.yaml @@ -5,18 +5,33 @@ services: build: context: . container_name: wcyd + volumes: + - profile_pic_store:/var/www/html/uploads ports: - "8080:80" depends_on: - db - + restart: "unless-stopped" + deploy: + resources: + limits: + memory: 2G + api: build: context: ./api container_name: api_server + volumes: + - yaml_store:/app/uploads expose: - "5000" + restart: "unless-stopped" + deploy: + resources: + limits: + memory: 2G + db: image: mysql:8.0 @@ -34,4 +49,6 @@ services: # - 5000:3306 volumes: - mysql_db: \ No newline at end of file + mysql_db: + yaml_store: + profile_pic_store: \ No newline at end of file