diff --git a/.metadata b/.metadata index 7fd5968..a89c977 100644 --- a/.metadata +++ b/.metadata @@ -15,7 +15,7 @@ migration: - platform: root create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 - - platform: linux + - platform: web create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..00840de --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +# Build +FROM ubuntu:22.04 + +RUN apt update +RUN apt install -y curl git wget unzip +RUN apt clean + +RUN git clone https://github.com/flutter/flutter.git /usr/local/flutter +ENV PATH="/usr/local/flutter/bin:/usr/local/flutter/bin/cache/dart-sdk/bin:${PATH}" + +RUN flutter channel stable +RUN flutter upgrade + +RUN mkdir /portarius/ +COPY . /portarius/ +WORKDIR /portarius/ +RUN flutter build web + +# Runtime +FROM nginx:alpine +LABEL org.opencontainers.image.source="https://github.com/zbejas/portarius" +COPY nginx.conf /etc/nginx/conf.d/default.conf +COPY --from=0 /portarius/build/web/ /usr/share/nginx/html/ \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index 21973b1..fca35fc 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,5 +1,7 @@ import 'dart:convert'; +import 'dart:io'; import 'package:flex_color_scheme/flex_color_scheme.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:hive/hive.dart'; @@ -19,7 +21,11 @@ import 'pages/settings/settings.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); - Hive.init((await path_provider.getApplicationDocumentsDirectory()).path); + + // If platform is web, skip init + if (!kIsWeb) { + Hive.init((await path_provider.getApplicationDocumentsDirectory()).path); + } Hive.registerAdapter(TokenAdapter()); Hive.registerAdapter(UserAdapter()); diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..5696998 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,11 @@ +server { + listen 80 default_server; + listen [::]:80 default_server; + root /usr/share/nginx/html; + index index.html; + + location / { + add_header 'Access-Control-Allow-Origin' '*'; + try_files $uri $uri/ =404; + } +} diff --git a/web/favicon.png b/web/favicon.png new file mode 100644 index 0000000..8aaa46a Binary files /dev/null and b/web/favicon.png differ diff --git a/web/icons/Icon-192.png b/web/icons/Icon-192.png new file mode 100644 index 0000000..b749bfe Binary files /dev/null and b/web/icons/Icon-192.png differ diff --git a/web/icons/Icon-512.png b/web/icons/Icon-512.png new file mode 100644 index 0000000..88cfd48 Binary files /dev/null and b/web/icons/Icon-512.png differ diff --git a/web/icons/Icon-maskable-192.png b/web/icons/Icon-maskable-192.png new file mode 100644 index 0000000..eb9b4d7 Binary files /dev/null and b/web/icons/Icon-maskable-192.png differ diff --git a/web/icons/Icon-maskable-512.png b/web/icons/Icon-maskable-512.png new file mode 100644 index 0000000..d69c566 Binary files /dev/null and b/web/icons/Icon-maskable-512.png differ diff --git a/web/index.html b/web/index.html new file mode 100644 index 0000000..0748723 --- /dev/null +++ b/web/index.html @@ -0,0 +1,58 @@ + + +
+ +