Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Setup Dart with Docker
# ./Dockerfile
FROM google/dart-runtime
// ./bin/server.dart
import 'dart:io';
main() async {
var port = int.parse(Platform.environment['PORT'] ?? '4567');
var server = await HttpServer.bind(InternetAddress.anyIPv4, port);
print('Server listening at port $port');
await for (HttpRequest request in server) {
..write('Hello, World!')
Copy link

graphicbeacon commented May 17, 2020

To set yourself up:

  1. Install Docker
  2. Create your working folder
  3. Create a Dockerfile with these contents -> FROM google/dart-runtime
  4. Create a bin/server.dart file with the code snippet above.
  5. Build docker image by running -> docker build -t my/app .
  6. Run docker image -> docker run -d -p 8080:8080 my/app
  7. Visit http://localhost:8080 in your browser

Watch 30-second tutorial

Copy link

andreipa commented Jun 23, 2021

Error missing the pubspec.yaml
Is it possible to create using docker-compose?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment