diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/laser-app.iml b/.idea/laser-app.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/.idea/laser-app.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..ba24381 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..42c843c --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 6a66d92..7fd36fe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,29 +1,29 @@ FROM python:3.8-slim LABEL name=laser-app version=0.1 -WORKDIR /opt + RUN apt update RUN apt install -y --no-install-recommends build-essential\ gcc\ libagg2-dev\ libpotrace-dev\ - nginx-light\ pkg-config\ - python-dev\ - redis-server + python-dev RUN rm -f /etc/nginx/sites-enabled/* RUN pip3 install flask numpy pillow redis RUN pip3 install pypotrace COPY ./server/files/nginx/sites-enabled/site.conf /etc/nginx/sites-enabled + +WORKDIR /opt COPY . . -COPY ./server/entrypoint.sh /usr/bin/ -RUN chmod +x /usr/bin/entrypoint.sh +# COPY ./server/entrypoint.sh /usr/bin/ +# RUN chmod +x /usr/bin/entrypoint.sh +# +# ENTRYPOINT /usr/bin/entrypoint.sh -EXPOSE 80 EXPOSE 5000 -EXPOSE 9001 # Start the main process. CMD ["python", "./server.py", "-i", "db"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..da2c8b8 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,49 @@ +version: "3.7" +services: + nginx: + image: nginx:latest + ports: + - 80:80 + expose: + - 80:80 + networks: + - snap_net + volumes: + - .:/opt:ro + - ./server/files/nginx/sites-enabled/site.conf:/etc/nginx/conf.d/default.conf:ro +# command: sleep 60000 + + app: + image: laserapp:0.1 + environment: + - DB_HOST=redis + expose: + - 5000 + ports: + - "5000:5000" + networks: + - snap_net + volumes: + - ./app/:/app/ +# command: sleep 60000 + + worker: + image: laserapp:0.1 + environment: + - DB_HOST=redis + networks: + - snap_net + volumes: + - ./app/:/app/ + command: bash -c "while true; do /usr/local/bin/python3 worker.py; sleep 1; done" + + redis: + image: redis + networks: + - snap_net + ports: + - 6379 + +networks: + snap_net: + driver: bridge diff --git a/js/main.js b/js/main.js index a971f5b..041e13a 100644 --- a/js/main.js +++ b/js/main.js @@ -106,36 +106,15 @@ $(document).ready(function(){ img = new Image(); var objectUrl = _URL.createObjectURL(file); img.onload = function () { - let w = 640 - let h = 640 * this.height / this.width - showSnap(this,w,h) + let w = 640; + let h = 640 * this.height / this.width; + showSnap(this,w,h); }; img.src = objectUrl; } - if(files && typeof FileReader !== "undefined") { - for(var i=0; i