From dc4da9f8694c1f816b1ba214d5171fa0c5f04abb Mon Sep 17 00:00:00 2001 From: "Ivan I. Ovchinnikov" Date: Mon, 15 Dec 2025 17:33:27 +0000 Subject: [PATCH] feat: init excalidraw repo --- .env.example | 6 +++++ .gitignore | 2 ++ docker-compose.yml | 57 ++++++++++++++++++++++++++++++++++++++++++++++ nginx.conf | 35 ++++++++++++++++++++++++++++ playbook.yml | 20 ++++++++++++++++ 5 files changed, 120 insertions(+) create mode 100644 .env.example create mode 100644 .gitignore create mode 100644 docker-compose.yml create mode 100644 nginx.conf create mode 100644 playbook.yml diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..0d2f2b9 --- /dev/null +++ b/.env.example @@ -0,0 +1,6 @@ +APP_HOST=draw.nstest.local +ROOM_HOST=draw.nstest.local +STORAGE_BACKEND_HOST=draw.nstest.local/storage + +DB_USER= +DB_PASS= diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d7d9635 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +mongo-data/ +.env diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..3764c20 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,57 @@ +services: + app: + image: alswl/excalidraw:v0.18.0-fork-b3 + restart: unless-stopped + environment: + - VITE_APP_BACKEND_V2_GET_URL=https://${STORAGE_BACKEND_HOST}/api/v2/scenes/ + - VITE_APP_BACKEND_V2_POST_URL=https://${STORAGE_BACKEND_HOST}/api/v2/scenes/ + - VITE_APP_WS_SERVER_URL=https://${ROOM_HOST}/ + - VITE_APP_FIREBASE_CONFIG={} + - VITE_APP_HTTP_STORAGE_BACKEND_URL=https://${STORAGE_BACKEND_HOST}/api/v2 + - VITE_APP_STORAGE_BACKEND=http + - VITE_APP_DISABLE_TRACKING=true + - PUBLIC_URL=https://${APP_HOST} + networks: + - draw + + storage: + image: alswl/excalidraw-storage-backend:v2023.11.11 + restart: unless-stopped + environment: + - STORAGE_URI=mongodb://${DB_USER}:${DB_PASS}@mongodb:27017 + networks: + - draw + + room: + image: excalidraw/excalidraw-room:sha-49bf529 + restart: unless-stopped + environment: + PORT: 3002 + networks: + - draw + + mongodb: + image: mongo:7.0.5-jammy + restart: unless-stopped + environment: + - MONGO_INITDB_ROOT_USERNAME=${DB_USER} + - MONGO_INITDB_ROOT_PASSWORD=${DB_PASS} + volumes: + - ./mongo-data:/data/db + user: "1000" + networks: + - draw + + nginx: + container_name: nginx-server-ex + image: nginx + restart: always + ports: + - 5000:80 + volumes: + - ./nginx.conf:/etc/nginx/nginx.conf + networks: + - draw + +networks: + draw: diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..dbb1264 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,35 @@ +events {} +http { +server { + listen 80; + + location / { + proxy_pass http://app:80/; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /storage/ { + proxy_pass http://storage:8080/; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /socket.io/ { + proxy_pass http://room:3002; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header Host $host; + } + + client_max_body_size 40M; +} +} diff --git a/playbook.yml b/playbook.yml new file mode 100644 index 0000000..0a3b6a6 --- /dev/null +++ b/playbook.yml @@ -0,0 +1,20 @@ +--- +- name: Start Excalidraw + hosts: localhost + become: yes + vars: + mongodb_data_dir: "{{ playbook_dir }}/mongo-data" + + tasks: + - name: Ensure Excalidraw directories exist and have permissions + file: + path: "{{ item }}" + state: directory + mode: '777' + loop: + - "{{ mongodb_data_dir }}" + + - name: Start Excalidraw + command: docker-compose up -d + args: + chdir: "{{ playbook_dir }}"