Skip to content

Commit

Permalink
adds volumes, cleaner, ulimits and always_restart flag
Browse files Browse the repository at this point in the history
  • Loading branch information
moaath committed Jun 10, 2024
1 parent 78e1de1 commit 8270cae
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 9 deletions.
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
11 changes: 9 additions & 2 deletions service/api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
12 changes: 12 additions & 0 deletions service/api/cleaner.sh
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions service/api/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

/root/cleaner.sh &

flask run --host=0.0.0.0
21 changes: 19 additions & 2 deletions service/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -34,4 +49,6 @@ services:
# - 5000:3306

volumes:
mysql_db:
mysql_db:
yaml_store:
profile_pic_store:

0 comments on commit 8270cae

Please sign in to comment.