Format and add multi-stage Dockerfile

This commit is contained in:
Alex Ellis 2017-05-04 21:34:36 +01:00
parent 968002c15f
commit 024bd5419b
2 changed files with 13 additions and 7 deletions

View File

@ -18,8 +18,8 @@ EXPOSE 8080
ENV http_proxy "" ENV http_proxy ""
ENV https_proxy "" ENV https_proxy ""
COPY --from 0 gateway . COPY --from=0 /go/src/github.com/alexellis/faas/gateway/gateway .
COPY --from 0 assets assets COPY assets assets
CMD ["./gateway"] CMD ["./gateway"]

View File

@ -174,11 +174,8 @@ func makeSpec(request *requests.CreateFunctionRequest) swarm.ServiceSpec {
max := uint64(1) max := uint64(1)
nets := []swarm.NetworkAttachmentConfig{ nets := []swarm.NetworkAttachmentConfig{
swarm.NetworkAttachmentConfig{Target: request.Network}, {Target: request.Network},
} }
// TODO: request.EnvProcess should only be set if it's not nil, otherwise we override anything in the Docker image already
spec := swarm.ServiceSpec{ spec := swarm.ServiceSpec{
TaskTemplate: swarm.TaskSpec{ TaskTemplate: swarm.TaskSpec{
RestartPolicy: &swarm.RestartPolicy{ RestartPolicy: &swarm.RestartPolicy{
@ -187,7 +184,6 @@ func makeSpec(request *requests.CreateFunctionRequest) swarm.ServiceSpec {
}, },
ContainerSpec: swarm.ContainerSpec{ ContainerSpec: swarm.ContainerSpec{
Image: request.Image, Image: request.Image,
Env: []string{fmt.Sprintf("fprocess=%s", request.EnvProcess)},
Labels: map[string]string{"function": "true"}, Labels: map[string]string{"function": "true"},
}, },
Networks: nets, Networks: nets,
@ -196,5 +192,15 @@ func makeSpec(request *requests.CreateFunctionRequest) swarm.ServiceSpec {
Name: request.Service, Name: request.Service,
}, },
} }
// TODO: request.EnvProcess should only be set if it's not nil, otherwise we override anything in the Docker image already
var env []string
if len(request.EnvProcess) > 0 {
env = append(env, fmt.Sprintf("fprocess=%s", request.EnvProcess))
}
if len(env) > 0 {
spec.TaskTemplate.ContainerSpec.Env = env
}
return spec return spec
} }