summaryrefslogtreecommitdiff
path: root/docs/howto/HowToUseDockerImage.md
blob: a28502cf076cc9ab0c0d059989447c392447cde7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# How to use docker image of nnfw

We have a docker image to build `nnfw` repo.

This docker image is built from https://github.sec.samsung.net/STAR/nnfw/blob/master/docker/Dockerfile and based on Ubuntu 16.04.
And prebuilt docker image is available from Samsung private docker registry.

This document describes how to use prebuilt docker image when developing `nnfw`.

## How to install docker

Follow [Installing Docker](https://docs.docker.com/)

- For Ubuntu, follow [Installing Docker on Ubuntu](https://docs.docker.com/install/linux/docker-ce/ubuntu/)

These are the actual steps to install using apt package manager:
```
$ sudo apt-get install \
     apt-transport-https \
     ca-certificates \
     curl \
     software-properties-common
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo apt-key fingerprint 0EBFCD88
```
```
$ sudo add-apt-repository \
     "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
     $(lsb_release -cs) \
	 stable"
$ sudo apt-get update
```
```
$ sudo apt-get install docker-ce
```

## Configure docker daemon

1. Set HTTP/HTTPS proxy

    * For Ubuntu, follow [Setting HTTP/HTTPS proxy environment variables](https://docs.docker.com/v17.09/engine/admin/systemd/#httphttps-proxy)

If you are behind an HTTP or HTTPS proxy server, you will need to add this configuration in the Docker systemd service file.
These are the actual steps to set an HTTP/HTTPS proxy environment variable:
```
$ sudo mkdir -p /etc/systemd/system/docker.service.d
$ sudo vi etc/systemd/system/docker.service.d/http-proxy.conf
```
```
[Service]
Environment="HTTP_PROXY=http://10.112.1.184:8080/" "HTTPS_PROXY=https://10.112.1.184:8080/" "NO_PROXY=localhost,127.0.0.1"
```
```
$ sudo systemctl daemon-reload
$ sudo systemctl restart docker
$ systemctl show --property=Environment docker
```

2. Edit configuration file of docker daemon

First you have to add Samsung private docker reigstry to your docker daemon.
Depending on your docker daemon installed, there are two ways of configuration.


If there is a `/etc/default/docker`, please edit the file as below.
```
$ sudo vi /etc/default/docker

DOCKER_OPTS="--insecure-registry docker.sec.samsung.net:5000"
```

If there is a `/etc/docker/daemon.json`, please edit the file as below.
```
{
  ...,
  "insecure-registries": [..., "docker.sec.samsung.net:5000"]
}
```

3. Then restart docker daemon as below.

```
$ sudo service docker restart     // Ubuntu 14.04

or

$ sudo systemctl restart docker   // Ubuntu 16.04
```

## Install docker image of `nnfw`

Let's pull docker image for `nnfw` repo and tag it to `nnfw_docker:latest`

```
$ docker pull docker.sec.samsung.net:5000/star/nnfw/nnfw_docker:1.5
$ docker tag docker.sec.samsung.net:5000/star/nnfw/nnfw_docker:1.5 nnfw_docker:latest
```

If you would like to build `nnfw` tizen package using gbs, pull `nnfw_docker_tizen`.
```
$ docker pull docker.sec.samsung.net:5000/star/nnfw/nnfw_docker_tizen:1.2
$ docker tag docker.sec.samsung.net:5000/star/nnfw/nnfw_docker_tizen:1.2 nnfw_docker_tizen:latest
```

## Build docker image instead of pull

You can build docker image in your environment instead of pull docker image from server.

```
$ cd nnfw
$ ./run build-docker
```

Default docker image name is `nnfw_docker`. If you want to change image name and/or tag, use `-t` or `--tag` option

```
$ cd nnfw
$ ./run build-docker -t nnfw_docker_test
```

You can use options supported by `docker build` command (ex. `--network` option)

```
$ cd nnfw
$ ./run build-docker --network=host --no-cache
```

If you want to build docker image for tizen build, use `--tizen` option

```
```
$ cd nnfw
$ ./run build-docker --tizen
```
```


## Use docker image to build `nnfw`
Three different targets for `nnfw` can be built using docker image.

1. Build `nnfw` for `x86_64` target
```
$ cd nnfw
$ docker run --rm -v $(pwd):/opt/nnfw -w /opt/nnfw nnfw_docker make install
```
or use `docker_run_test.sh` for convenience as below.
```
$ cd nnfw
$ ./run docker_run_test.sh
```
You can find built artifacts at `nnfw/Product/x86_64-linux.debug`.

2. Cross build `nnfw` for ARM on x86_64 host

You should prepare RootFS, following [Cross Building for ARM](https://github.sec.samsung.net/STAR/nnfw/blob/master/docs/howto/CrossBuildForArm.md) except ACL build and cross build steps. Then execute below commands. If your RootFS directory is different with below directory, change it to correct path and ensure the path is absolute.
```
$ cd nnfw
$ ROOTFS_DIR=$(pwd)/tools/cross/rootfs/arm \
./run docker_build_cross_arm_ubuntu.sh
```
You can find built artifacts at `nnfw/Product/armv7l-linux.debug/`.

3. Build `nnfw` for Tizen ARM package on x86_64 host
```
$ cd nnfw
$ ./run docker_gbs_build.sh
```
You can find built artifacts at `Product/out/rpm`.