FROM ubuntu:trusty

ARG GO_VERSION
ARG GO_SHA256
ARG DEP_VERSION
ARG METALINTER_VERSION

ENV PATH=/usr/local/go/bin:/go/bin:$PATH

# Update should be kept together with install; it forces a docker cache break when we alter packages
RUN apt-get update && apt-get install -y \
	# for installing curl/dep
	curl            \
	# for dep
	git             \
	# for make
	build-essential \
	#  for awscli (it uses libyaml)
	libyaml-dev libpython2.7-dev \
	# for aws-cli
	python3-pip

RUN pip3 install awscli

# Install Golang
RUN curl -s -LO "https://storage.googleapis.com/golang/go${GO_VERSION}.linux-amd64.tar.gz"
RUN echo "${GO_SHA256}  go${GO_VERSION}.linux-amd64.tar.gz" | sha256sum --check
RUN tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz
RUN rm go${GO_VERSION}.linux-amd64.tar.gz

# Install binaries into a secondary directory
ENV GOPATH=/go
RUN go get -u gopkg.in/alecthomas/gometalinter.v${METALINTER_VERSION}
RUN ln -s `which gometalinter.v${METALINTER_VERSION}` /go/bin/gometalinter
RUN gometalinter --install
RUN curl -L "https://github.com/golang/dep/releases/download/v${DEP_VERSION}/dep-linux-amd64" > /go/bin/dep
RUN chmod a+x /go/bin/dep

# This just makes using SSH and git commands easier in the repository
ADD ssh_config /root/.ssh/config

