From 2a6c1f37f125cecfd1f67fa64fa3749a71e49f19 Mon Sep 17 00:00:00 2001 From: Lukas Reim Date: Sat, 21 Mar 2026 16:44:03 +0100 Subject: [PATCH] Fix docker build --- .github/workflows/main.yml | 1 + .dockerignore => docker/.dockerignore | 2 +- Dockerfile => docker/Dockerfile | 11 +++++----- docker/nginx.conf | 29 +++++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 6 deletions(-) rename .dockerignore => docker/.dockerignore (92%) rename Dockerfile => docker/Dockerfile (81%) create mode 100644 docker/nginx.conf diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a59e7fc0..62cba05e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -73,6 +73,7 @@ jobs: uses: docker/build-push-action@v5 with: context: . + file: docker/Dockerfile push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/.dockerignore b/docker/.dockerignore similarity index 92% rename from .dockerignore rename to docker/.dockerignore index b1564889..3ece515b 100644 --- a/.dockerignore +++ b/docker/.dockerignore @@ -8,4 +8,4 @@ macos/ windows/ android/ ios/ -*.iml \ No newline at end of file +*.iml diff --git a/Dockerfile b/docker/Dockerfile similarity index 81% rename from Dockerfile rename to docker/Dockerfile index 3578d079..80f71d8b 100644 --- a/Dockerfile +++ b/docker/Dockerfile @@ -15,10 +15,8 @@ RUN flutter pub get # Copy the rest of your app's source code COPY . . -RUN dart run fix_isar_web.dart - -# Build the web app for production -RUN flutter build web --release +# Build the web app for production with WASM +RUN flutter build web --wasm --release # ========================================== # Stage 2: Serve the App with Nginx @@ -26,6 +24,9 @@ RUN flutter build web --release # Use a lightweight Nginx image FROM nginx:alpine +# Copy the custom nginx.conf +COPY docker/nginx.conf /etc/nginx/nginx.conf + # Copy the compiled web files from the 'build' stage to Nginx's public folder COPY --from=build /app/build/web /usr/share/nginx/html @@ -33,4 +34,4 @@ COPY --from=build /app/build/web /usr/share/nginx/html EXPOSE 80 # Start Nginx -CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file +CMD ["nginx", "-g", "daemon off;"] diff --git a/docker/nginx.conf b/docker/nginx.conf new file mode 100644 index 00000000..63bef35d --- /dev/null +++ b/docker/nginx.conf @@ -0,0 +1,29 @@ +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + + server { + listen 80; + server_name localhost; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + try_files $uri $uri/ /index.html; + + # Required for Flutter Web WASM + add_header Cross-Origin-Embedder-Policy require-corp; + add_header Cross-Origin-Opener-Policy same-origin; + } + + # Ensure correct MIME types for WASM and JS + types { + application/wasm wasm; + application/javascript js; + } + } +}