FROM golang:1.12-alpine as builder

ENV CGO_ENABLED 0

# Allow Go to retreive the dependencies for the build step
RUN apk add --no-cache git

# Copy local code to the container image.
WORKDIR /go/src/github.com/keptn/keptn/remediation-service
COPY . .

# Build the command inside the container.
# (You may fetch or manage dependencies here, either manually or with a tool like "godep".)
RUN CGO_ENABLED=0 GOOS=linux go build -gcflags="all=-N -l" -o remediation-service

ARG HELM_VERSION=2.12.3
RUN wget https://storage.googleapis.com/kubernetes-helm/helm-v$HELM_VERSION-linux-amd64.tar.gz && \
  tar -zxvf helm-v$HELM_VERSION-linux-amd64.tar.gz && \
  cp linux-amd64/helm /bin/helm

WORKDIR /go/src/
RUN go get github.com/go-delve/delve/cmd/dlv

WORKDIR /
ENV env=production
EXPOSE 8080 40000

CMD ["/go/bin/dlv", "--listen=:40000", "--headless=true", "--api-version=2", "exec", "/go/src/github.com/keptn/keptn/remediation-service/remediation-service"]
