Skip to content

Commit f18fd26

Browse files
authored
Clarify Dart getting started steps (#2062)
Based on feedback in dart-lang/dart-docker#28
1 parent 302e2fd commit f18fd26

File tree

1 file changed

+33
-15
lines changed

1 file changed

+33
-15
lines changed

dart/content.md

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,36 @@ By utilizing Dart's support for ahead-of-time (AOT) [compilation to executables]
88

99
## Using this image
1010

11-
We recommend creating small runtime images by leveraging Dart's support for ahead-of-time (AOT) [compilation to executables](https://dart.dev/tools/dart-compile#exe). This enables creating small runtime images (~10 MB).
11+
We recommend using small runtime images that leverage Dart's support for ahead-of-time (AOT) [compilation to executables](https://dart.dev/tools/dart-compile#exe). This enables creating small runtime images (~10 MB).
1212

13-
The following `Dockerfile` performs two steps:
13+
### Creating a Dart server app
14+
15+
After installing the Dart SDK, use the `dart` command to create a new server app:
16+
17+
```shell
18+
$ dart create -t server-shelf myserver
19+
```
20+
21+
### Running the server with Docker Desktop
22+
23+
If you have [Docker Desktop](https://www.docker.com/get-started) installed, you can build and run on your machine with the `docker` command:
24+
25+
```shell
26+
$ docker build -t dart-server .
27+
$ docker run -it --rm -p 8080:8080 --name myserver dart-server
28+
```
29+
30+
When finished, you can stop the container using the name you provided:
31+
32+
```shell
33+
$ docker kill myserver
34+
```
35+
36+
## Image documentation
37+
38+
### `Dockerfile`
39+
40+
The `Dockerfile` created by the `dart` tool performs two steps:
1441

1542
1. Using the Dart SDK in the `dart:stable` image, compiles your server (`bin/server.dart`) to an executable (`server`).
1643

@@ -42,7 +69,9 @@ EXPOSE 8080
4269
CMD ["/app/bin/server"]
4370
```
4471

45-
We recommend you also have a `.dockerignore` file like the following:
72+
### `.dockerignore`
73+
74+
Additionally it creates a recommended `.dockerignore` file, which enumarates files that should be omitted from the built Docker image:
4675

4776
```text
4877
.dockerignore
@@ -55,17 +84,6 @@ build/
5584
.packages
5685
```
5786

58-
If you have [Docker Desktop](https://www.docker.com/get-started) installed, you can build and run on your machine with the `docker` command:
59-
60-
```shell
61-
$ docker build -t dart-server .
62-
$ docker run -it --rm -p 8080:8080 --name myserver dart-server
63-
```
64-
65-
When finished, you can stop the container using the name you provided:
66-
67-
```shell
68-
$ docker kill myserver
69-
```
87+
--
7088

7189
Maintained with ❤️ by the [Dart](https://dart.dev) team.

0 commit comments

Comments
 (0)