Skip to content

Clarify Dart getting started steps #2062

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 25, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 33 additions & 15 deletions dart/content.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,36 @@ By utilizing Dart's support for ahead-of-time (AOT) [compilation to executables]

## Using this image

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).
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).

The following `Dockerfile` performs two steps:
### Creating a Dart server app

After installing the Dart SDK, use the `dart` command to create a new server app:

```shell
$ dart create -t server-shelf myserver
```

### Running the server with Docker Desktop

If you have [Docker Desktop](https://www.docker.com/get-started) installed, you can build and run on your machine with the `docker` command:

```shell
$ docker build -t dart-server .
$ docker run -it --rm -p 8080:8080 --name myserver dart-server
```

When finished, you can stop the container using the name you provided:

```shell
$ docker kill myserver
```

## Image documentation

### `Dockerfile`

The `Dockerfile` created by the `dart` tool performs two steps:

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

Expand Down Expand Up @@ -42,7 +69,9 @@ EXPOSE 8080
CMD ["/app/bin/server"]
```

We recommend you also have a `.dockerignore` file like the following:
### `.dockerignore`

Additionally it creates a recommended `.dockerignore` file, which enumarates files that should be omitted from the built Docker image:

```text
.dockerignore
Expand All @@ -55,17 +84,6 @@ build/
.packages
```

If you have [Docker Desktop](https://www.docker.com/get-started) installed, you can build and run on your machine with the `docker` command:

```shell
$ docker build -t dart-server .
$ docker run -it --rm -p 8080:8080 --name myserver dart-server
```

When finished, you can stop the container using the name you provided:

```shell
$ docker kill myserver
```
--

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