I'm trying to build a dart server that can serve flutter web apps. I've tried it a few different ways, building from scratch, using shelf (and shelf_static), and lastly GetX, but I can't get them to run in a docker container. For instance, I currently have a simple structure:
-myApp/
-web/
-Dockerfile
-pubspec.yaml
-server.dart
I took the basic flutter demo app (with the floating button & counter), added web support, then did $ flutter build web, and took the build/web folder and copied it here as just web. Pubspec only includes get_server and build_runner, the server.dart file is only:
import 'package:get_server/get_server.dart';
void main() => runApp(GetServer(home: FolderWidget('web')));
And then my Dockerfile looks like this (based on this github repo):
################
FROM google/dart:2.10
RUN apt -y update && apt -y upgrade
WORKDIR /app
COPY pubspec.yaml /app/pubspec.yaml
RUN dart pub get
COPY . .
RUN dart pub get --offline
RUN dart pub run build_runner build --delete-conflicting-outputs
RUN dart compile exe /app/server.dart -o /app/server
########################
FROM subfuzion/dart:slim
COPY --from=0 /app /app
EXPOSE 8080
ENTRYPOINT ["/app/server"]
If I run the server from the command line:
$ dart server.dart
It runs perfectly. But if I build docker and run it:
$ docker build -t myApp .
$ docker run -d -p 8080:8080 myapp
It just says that the page can't be found. Does anyone know what I'm doing wrong? Or have suggestions for how to host a Flutter Web App using a Dart Server (it doesn't have to be GetX).