Dart docker image

195 views
Skip to first unread message

TA

unread,
Jul 18, 2017, 5:26:02 PM7/18/17
to Dart Web Development
This is my Dart dockerfile.

FROM google/dart-runtime

WORKDIR /DartDocker

ADD pubspec.* /DartDocker/
RUN pub get
ADD . /DartDocker
RUN pub get --offline

CMD []
ENTRYPOINT ["/usr/bin/dart", "web/main.dart"]


This is the exception I am getting :

$ winpty docker run -i -t googledart:1.0.0
The built-in library 'dart:js' is not available on the stand-alone VM.
'component.dart': error: line 1 pos 1: library handler failed
import 'dart:js' as js;

Please let me know if I should use a different image. 

Günter Zöchbauer

unread,
Jul 19, 2017, 3:08:58 AM7/19/17
to Dart Web Development
I'm not sure what you try to accomplish.

"web/main.dart" seems to be a web application, which can only be run in the browser, but your code runs it with the server side VM

TA

unread,
Jul 19, 2017, 1:42:59 PM7/19/17
to Dart Web Development
I am building a docker image for my Client side UI as per this link from google.

Günter Zöchbauer

unread,
Jul 20, 2017, 8:28:45 AM7/20/17
to Dart Web Development
A docker image is not a browser and as I said a web application only runs in a browser.

Perhaps you want to run `pub build` and deploy the output to a web server.
You can use a Docker image with any web server like nginx, Apache, node, ... and add the output of `pub build` to such an image

TA

unread,
Jul 20, 2017, 4:50:42 PM7/20/17
to Dart Web Development
Thanks for the help. I understood. I tried to do nginx as a proxy for index.html. IT worked fine. 

This is my working Dockerfile. Next steps is to do pub build as part of my dockerfile.

FROM ubuntu:latest
RUN apt-get update
RUN apt-get install -y nginx
RUN rm -rf /etc/nginx/sites-enabled/default
# Define mountable directories.
#VOLUME ["/etc/nginx/sites-enabled", "/etc/nginx/certs", "/etc/nginx/conf.d", "/var/log/nginx", "/var/www/html"] 

# Define working directory.
WORKDIR /etc/nginx

# Define default command.
# nginx.conf redirecting to index.html of the webapp
COPY nginx.conf  /etc/nginx/nginx.conf
RUN mkdir -p /webapp
COPY build/  /webapp/

# Expose ports.
EXPOSE 80
EXPOSE 443
CMD ["nginx", "-g", "daemon off;"]cd ../

Günter Zöchbauer

unread,
Jul 21, 2017, 2:23:21 AM7/21/17
to Dart Web Development
glad to hear :)
Reply all
Reply to author
Forward
0 new messages