(basename string, idx, grpcPort int)
| 149 | } |
| 150 | |
| 151 | func initService(basename string, idx, grpcPort int) service { |
| 152 | var svc service |
| 153 | |
| 154 | svc.name = name(basename, idx) |
| 155 | svc.Image = opts.Image + ":" + opts.Tag |
| 156 | svc.ContainerName = containerName(svc.name) |
| 157 | svc.WorkingDir = fmt.Sprintf("/data/%s", svc.name) |
| 158 | // EmitUser is a public hook in compose/hooks.go. The upstream |
| 159 | // default returns "" so the generated compose service inherits the |
| 160 | // image's own USER directive. Downstream consumers that run dgraph |
| 161 | // as a non-root user under compose override the hook to return a |
| 162 | // "uid:gid" string such as "${UID:-65532}", which is emitted as the |
| 163 | // service's `user:` field. Bind-mounted host paths must be readable |
| 164 | // by that uid for the container to start cleanly. |
| 165 | if u := EmitUser(); u != "" { |
| 166 | svc.User = u |
| 167 | } |
| 168 | if idx > 1 { |
| 169 | svc.DependsOn = append(svc.DependsOn, name(basename, idx-1)) |
| 170 | } |
| 171 | svc.Labels = map[string]string{"cluster": "test"} |
| 172 | |
| 173 | svc.Ports = []string{ |
| 174 | toPort(grpcPort), |
| 175 | toPort(grpcPort + 1000), // http port |
| 176 | } |
| 177 | |
| 178 | if opts.LocalBin { |
| 179 | svc.Volumes = append(svc.Volumes, volume{ |
| 180 | Type: "bind", |
| 181 | Source: "$GOPATH/bin", |
| 182 | Target: "/gobin", |
| 183 | ReadOnly: true, |
| 184 | }) |
| 185 | } |
| 186 | |
| 187 | switch { |
| 188 | case opts.DataVol: |
| 189 | svc.Volumes = append(svc.Volumes, volume{ |
| 190 | Type: "volume", |
| 191 | Source: "data", |
| 192 | Target: "/data", |
| 193 | }) |
| 194 | case opts.DataDir != "": |
| 195 | svc.Volumes = append(svc.Volumes, volume{ |
| 196 | Type: "bind", |
| 197 | Source: opts.DataDir, |
| 198 | Target: "/data", |
| 199 | }) |
| 200 | default: |
| 201 | // no data volume |
| 202 | } |
| 203 | |
| 204 | svc.Command = buildvars.BinaryName.Get() |
| 205 | if opts.LocalBin { |
| 206 | svc.Command = buildvars.GoBinDgraphPath.Get() |
| 207 | } |
| 208 | if opts.UserOwnership { |
no test coverage detected
searching dependent graphs…