Update web example with WASM build and static-web-server
- Use --wasm flag for WebAssembly compilation - Add cache-busting for JS/WASM assets - Replace nginx with static-web-server on scratch (~18MB) - Run as non-root user Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
b5ccf2effa
commit
26797d954d
23
README.md
23
README.md
@ -34,17 +34,28 @@ Lightweight Flutter SDK images for CI/CD pipelines. Built on [Wolfi](https://wol
|
|||||||
|
|
||||||
## Dockerfile Examples
|
## Dockerfile Examples
|
||||||
|
|
||||||
### Web App
|
### Web App (WASM)
|
||||||
|
|
||||||
```dockerfile
|
```dockerfile
|
||||||
FROM svrnty/flutter-sdk:web-latest AS build
|
FROM svrnty/flutter-sdk:web-latest AS build
|
||||||
COPY . /app
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN flutter pub get && flutter build web --release
|
COPY . .
|
||||||
|
RUN flutter pub get && flutter build web --wasm --release
|
||||||
|
|
||||||
FROM nginx:alpine
|
# Cache-busting: append version to JS/WASM references
|
||||||
COPY --from=build /app/build/web /usr/share/nginx/html
|
RUN VERSION=$(date +%s) && cd build/web && \
|
||||||
EXPOSE 80
|
sed -i "s|flutter_bootstrap\.js\"|flutter_bootstrap.js?v=${VERSION}\"|g" index.html && \
|
||||||
|
sed -i "s|main\.dart\.js\"|main.dart.js?v=${VERSION}\"|g" flutter_bootstrap.js && \
|
||||||
|
sed -i "s|main\.dart\.mjs\"|main.dart.mjs?v=${VERSION}\"|g" flutter_bootstrap.js && \
|
||||||
|
sed -i "s|main\.dart\.wasm\"|main.dart.wasm?v=${VERSION}\"|g" flutter_bootstrap.js
|
||||||
|
|
||||||
|
FROM ghcr.io/static-web-server/static-web-server:2 AS sws
|
||||||
|
FROM scratch
|
||||||
|
COPY --from=sws /static-web-server /static-web-server
|
||||||
|
COPY --from=build /app/build/web /public
|
||||||
|
EXPOSE 8080
|
||||||
|
USER 65534
|
||||||
|
ENTRYPOINT ["/static-web-server", "-p", "8080", "-d", "/public"]
|
||||||
```
|
```
|
||||||
|
|
||||||
### Android APK
|
### Android APK
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user