From 5ede5e7b98a68f91c6c2f3945329fe4017fe0328 Mon Sep 17 00:00:00 2001 From: jedi Date: Sat, 1 Jul 2023 17:21:32 +0200 Subject: [PATCH] stash --- docker-compose.yml | 43 +++++++ frontend/src/components/CombinedFileField.vue | 117 ++++++++++++++++++ frontend/src/store.js | 10 +- nginx.conf | 37 ++++++ proxy.sh | 3 + 5 files changed, 206 insertions(+), 4 deletions(-) create mode 100644 docker-compose.yml create mode 100644 frontend/src/components/CombinedFileField.vue create mode 100644 nginx.conf create mode 100755 proxy.sh diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..12187f1 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,43 @@ +version: '3.3' + +services: + # db: + # image: postgres + # container_name: docker-django-vue-db + # environment: + # POSTGRES_USER: user + # POSTGRES_PASSWORD: pass + # POSTGRES_DB: db + # restart: unless-stopped + # ports: + # - "5432:5432" + django: + build: + context: ./backend + dockerfile: ./Dockerfile + command: python backend/manage.py runserver 0.0.0.0:8000 + volumes: + - .:/app + ports: + - "8002:8000" + networks: + - internal + # depends_on: + # - db + vue: + build: + context: ./frontend + dockerfile: ./Dockerfile + command: nginx -g 'daemon off;' + volumes: + - .:/app + ports: + - "8001:80" + networks: + - internal + - external + depends_on: + - django +networks: + external: + internal: \ No newline at end of file diff --git a/frontend/src/components/CombinedFileField.vue b/frontend/src/components/CombinedFileField.vue new file mode 100644 index 0000000..da5e689 --- /dev/null +++ b/frontend/src/components/CombinedFileField.vue @@ -0,0 +1,117 @@ + + + + + \ No newline at end of file diff --git a/frontend/src/store.js b/frontend/src/store.js index 59824fa..211c4ef 100644 --- a/frontend/src/store.js +++ b/frontend/src/store.js @@ -264,11 +264,13 @@ export default createStore({ state.last_load.files = Date.now() return data }, - async pushFile({state, dispatch, getters}, {file}) { + async pushFile({state, dispatch, getters}, {item_id, file}) { const servers = await dispatch('getHomeServers') - const data = await servers.post(getters.signAuth, '/api/files/', file) - state.files.push(data) - return data + const data = await servers.post(getters.signAuth, '/api/item_files/'+item_id+'/', file) + if (data.mime_type) { + state.files.push(data) + return data + } }, async fetchTags({state, commit, dispatch, getters}) { if (state.last_load.tags > Date.now() - 1000 * 60 * 60 * 24) { diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..35eec4f --- /dev/null +++ b/nginx.conf @@ -0,0 +1,37 @@ +worker_processes 2; + +events { + use epoll; + worker_connections 128; +} + +error_log logs/error.log info; + +http { + server_tokens off; + include /etc/nginx/mime.types; + charset utf-8; + + access_log logs/access.log combined; + + server { + server_name localhost; + listen 0.0.0.0:8080; + + error_page 500 502 503 504 /50x.html; + + location / { + root frontend/dist/; + } + + location /api/ { + proxy_pass http://127.0.0.1:8000/api/; + } + + location /auth/ { + proxy_pass http://127.0.0.1:8000/auth/; + } + + } + +} \ No newline at end of file diff --git a/proxy.sh b/proxy.sh new file mode 100755 index 0000000..aa07e9f --- /dev/null +++ b/proxy.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +/usr/sbin/nginx -g "daemon off;pid nginx.pid;" -c nginx.conf -e nginx.log -p $(pwd) \ No newline at end of file