# 手动构建

To build the Dashboard with Docker, you simply download the `Dockerfile` file from the **root directory** to your device (no need to download all source codes) then follow this guide.

The `manager-api` and `web` will be included in this build guide product.

### Prerequisites

Before using Docker to build images and start containers, make sure that the following dependencies are installed and running in your environment.

1. [Docker](https://docs.docker.com/engine/install/)
2. [etcd](https://etcd.io/docs/v3.4.0/dl-build/) 3.4.0+

### Build

```bash
# Execute the build command in the directory where the Dockerfile is located (by default, the project root), specifying the tag manually.
$ docker build -t apisix-dashboard:$tag .

# For users in mainland China, the `ENABLE_PROXY` parameter can be provided to speed up module downloads.
$ docker build -t apisix-dashboard:$tag . --build-arg ENABLE_PROXY=true

# If you want to use the latest codes to build, you can specify the `APISIX_DASHBOARD_VERSION` parameter to `master`.
# This parameter can also be specified as branch name of a specific version, such as `v2.1.1`.
$ docker build -t apisix-dashboard:$tag . --build-arg APISIX_DASHBOARD_VERSION=master
```

### Launch

1. Preparing configuration files

Before starting the container, the configuration file `conf.yaml` needs to be prepared inside the **host** to override the default [configuration file](https://app.gitbook.com/s/-MQtZefWebJLMmwRok3p/deployment-1/api/conf/conf.yaml) inside the container.

Kindly note:

* Only when `conf.listen.host` is `0.0.0.0` can the external network access the services within the container.
* `conf.etcd.endpoints` must be able to access the `etcd` service within the container. For example: use `host.docker.internal:2379` so that the container can access `etcd` on the host network.
* Launch the Dashboard

```bash
# /path/to/conf.yaml Requires an absolute path pointing to the configuration file mentioned above.
$ docker run -d -p 9000:9000 -v /path/to/conf.yaml:/usr/local/apisix-dashboard/conf/conf.yaml --name apisix-dashboard apisix-dashboard:$tag
```

1. Check if the container started successfully

```bash
$ docker ps -a
```

If the container `apisix-dashboard` is ok, visit `http://127.0.0.1:9000` to use the dashboard with GUI, where the default username and password are `admin`.

1. Stop the Dashboard

```bash
$ docker stop apisix-dashboard
```

### Other

1. Caching is not recommended when building a image multiple times.

```bash
$ docker build -t apisix-dashboard:$tag . --no-cache=true
```
