From aebe76ad96804d2a4f5627c1080a064dd9a1ca28 Mon Sep 17 00:00:00 2001 From: Saw-jan Date: Thu, 21 Mar 2024 17:16:37 +0545 Subject: [PATCH] build: add support for app_loading via ocis env --- dev/docker/nginx.conf | 11 +++++ dev/docker/web.config.json | 2 +- docker-compose.override.example.yml | 12 +++++ docker-compose.yml | 69 ++++++++++++++++++++++++----- package.json | 1 + pnpm-lock.yaml | 19 +++++--- vite.config.ts | 8 +++- 7 files changed, 102 insertions(+), 20 deletions(-) create mode 100644 dev/docker/nginx.conf create mode 100644 docker-compose.override.example.yml diff --git a/dev/docker/nginx.conf b/dev/docker/nginx.conf new file mode 100644 index 0000000..177614f --- /dev/null +++ b/dev/docker/nginx.conf @@ -0,0 +1,11 @@ +server { + listen 80; + server_name localhost; + + location / { + add_header 'Access-Control-Allow-Origin' '*'; + } + root /usr/share/nginx/html; + index index.html index.htm; + try_files $uri $uri/ /index.html; +} \ No newline at end of file diff --git a/dev/docker/web.config.json b/dev/docker/web.config.json index 92b0095..c8b7ca1 100644 --- a/dev/docker/web.config.json +++ b/dev/docker/web.config.json @@ -48,7 +48,7 @@ }, { "id": "presentation-viewer", - "path": "http://localhost:8082/web-app-presentation-viewer.js" + "path": "https://host.docker.internal:3000/com.github.jankaritech.web.mdpresentation/extension.js" } ] } diff --git a/docker-compose.override.example.yml b/docker-compose.override.example.yml new file mode 100644 index 0000000..c101387 --- /dev/null +++ b/docker-compose.override.example.yml @@ -0,0 +1,12 @@ +services: + ocis: + image: owncloud/ocis:latest + environment: + WEB_UI_CONFIG_FILE: null + WEB_ASSET_APPS_PATH: /web/apps + volumes: + - ./dist:/web/apps:ro + + extension: + profiles: + - skip diff --git a/docker-compose.yml b/docker-compose.yml index 3e3621d..833bbc9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,24 +1,69 @@ services: ocis: - image: ${OCIS_IMAGE:-owncloud/ocis:latest} - container_name: web_ocis + image: ${OCIS_IMAGE:-owncloud/ocis:5.0.0} entrypoint: /bin/sh command: ['-c', 'ocis init || true && ocis server'] - ports: - - 9200:9200 environment: # OCIS OCIS_URL: https://host.docker.internal:9200 - OCIS_INSECURE: '${OCIS_INSECURE:-true}' - OCIS_LOG_LEVEL: '${OCIS_LOG_LEVEL:-error}' - + OCIS_INSECURE: true + OCIS_LOG_LEVEL: error # WEB WEB_UI_CONFIG_FILE: /web/config.json - WEB_ASSET_APPS_PATH: /web/apps - # IDM - IDM_CREATE_DEMO_USERS: '${DEMO_USERS:-true}' - IDM_ADMIN_PASSWORD: '${ADMIN_PASSWORD:-admin}' + IDM_CREATE_DEMO_USERS: ${DEMO_USERS:-true} + IDM_ADMIN_PASSWORD: admin + # PROXY + PROXY_ENABLE_BASIC_AUTH: true + PROXY_TLS: false volumes: - ./dev/docker/web.config.json:/web/config.json:ro - - ./dist:/web/apps:ro + extra_hosts: + - host.docker.internal:host-gateway + labels: + traefik.enable: true + traefik.http.routers.ocis.tls: true + traefik.http.routers.ocis.rule: PathPrefix(`/`) + traefik.http.routers.ocis.entrypoints: ocis + traefik.http.services.ocis.loadbalancer.server.port: 9200 + depends_on: + - traefik + + extension: + image: nginx:1.25.3 + volumes: + - ./dev/docker/nginx.conf:/etc/nginx/conf.d/default.conf:ro + - ./dist:/usr/share/nginx/html:ro + labels: + traefik.enable: true + traefik.http.routers.extension.tls: true + traefik.http.routers.extension.rule: PathPrefix(`/`) + traefik.http.routers.extension.entrypoints: extension + traefik.http.services.extension.loadbalancer.server.port: 80 + depends_on: + - traefik + + traefik: + image: traefik:2.11.0 + restart: unless-stopped + command: + [ + '--log.level=ERROR', + '--api.insecure=true', + '--api.dashboard=true', + '--pilot.dashboard=false', + '--providers.docker=true', + '--entrypoints.ocis.address=:9200', + '--entrypoints.extension.address=:3000', + '--providers.docker.exposedbydefault=false', + '--entrypoints.websecure.http.tls.options=default' + ] + labels: + traefik.enable: true + traefik.http.routers.traefik.rule: HostRegexp(`{any:.+}`) + ports: + - 8080:8080 # traefik dashboard + - 9200:9200 # ocis + - 3000:3000 # extension + volumes: + - /var/run/docker.sock:/var/run/docker.sock:ro diff --git a/package.json b/package.json index 1c536f5..d3bea5f 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "@babel/eslint-parser": "^7.23.10", "@ownclouders/extension-sdk": "0.0.5-alpha.2", "@ownclouders/prettier-config": "0.0.1", + "@types/node": "^20.11.30", "@typescript-eslint/eslint-plugin": "^7.1.1", "eslint": "^8.57.0", "eslint-config-prettier": "^9.1.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d9864c7..41b31d7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -28,6 +28,9 @@ devDependencies: '@ownclouders/prettier-config': specifier: 0.0.1 version: 0.0.1 + '@types/node': + specifier: ^20.11.30 + version: 20.11.30 '@typescript-eslint/eslint-plugin': specifier: ^7.1.1 version: 7.1.1(@typescript-eslint/parser@7.1.1)(eslint@8.57.0)(typescript@5.3.3) @@ -51,7 +54,7 @@ devDependencies: version: 5.3.3 vite: specifier: ^5.0.12 - version: 5.1.3(sass@1.71.0) + version: 5.1.3(@types/node@20.11.30)(sass@1.71.0) vue: specifier: ^3.4.16 version: 3.4.19(typescript@5.3.3) @@ -634,7 +637,7 @@ packages: rollup-plugin-node-polyfills: 0.2.1 rollup-plugin-serve: 2.0.3 sass: 1.71.0 - vite: 5.1.3(sass@1.71.0) + vite: 5.1.3(@types/node@20.11.30)(sass@1.71.0) transitivePeerDependencies: - vue dev: true @@ -859,6 +862,12 @@ packages: undici-types: 5.26.5 dev: false + /@types/node@20.11.30: + resolution: {integrity: sha512-dHM6ZxwlmuZaRmUPfv1p+KrdD1Dci04FbdEm/9wEMouFqxYoFl5aMkt0VMAUtYRQDyYvD41WJLukhq/ha3YuTw==} + dependencies: + undici-types: 5.26.5 + dev: true + /@types/parse-json@4.0.2: resolution: {integrity: sha512-dISoDXWWQwUquiKsyZ4Ng+HX2KsPL7LyHKHQwgGFEA3IaKac4Obd+h2a/a6waisAoepJlBcx9paWqjA8/HVjCw==} dev: false @@ -1113,7 +1122,7 @@ packages: vite: ^4.0.0 || ^5.0.0 vue: ^3.2.25 dependencies: - vite: 5.1.3(sass@1.71.0) + vite: 5.1.3(@types/node@20.11.30)(sass@1.71.0) vue: 3.4.19(typescript@5.3.3) dev: true @@ -2818,7 +2827,6 @@ packages: /undici-types@5.26.5: resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} - dev: false /update-browserslist-db@1.0.13(browserslist@4.23.0): resolution: {integrity: sha512-xebP81SNcPuNpPP3uzeW1NYXxI3rxyJzF3pD6sH4jE7o/IX+WtSpwnVU+qIsDPyk0d3hmFQ7mjqc6AtV604hbg==} @@ -2853,7 +2861,7 @@ packages: hasBin: true dev: false - /vite@5.1.3(sass@1.71.0): + /vite@5.1.3(@types/node@20.11.30)(sass@1.71.0): resolution: {integrity: sha512-UfmUD36DKkqhi/F75RrxvPpry+9+tTkrXfMNZD+SboZqBCMsxKtO52XeGzzuh7ioz+Eo/SYDBbdb0Z7vgcDJew==} engines: {node: ^18.0.0 || >=20.0.0} hasBin: true @@ -2881,6 +2889,7 @@ packages: terser: optional: true dependencies: + '@types/node': 20.11.30 esbuild: 0.19.12 postcss: 8.4.35 rollup: 4.12.0 diff --git a/vite.config.ts b/vite.config.ts index 5cb2aa7..aa9261b 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,13 +1,17 @@ import { defineConfig } from '@ownclouders/extension-sdk' import { id } from './public/manifest.json' +// TODO: make APPS_LOADING default when supported ocis is released +const base = + process.env.APPS_LOADING === 'true' ? '/assets/apps' : 'https://host.docker.internal:3000' + export default defineConfig({ - base: '/vendor/apps/com.github.jankaritech.web.mdpresentation/', + base: `${base}/${id}/`, build: { rollupOptions: { output: { dir: `dist/${id}`, - entryFileNames: `extension.js` + entryFileNames: 'extension.js' } } }