From 6e5151f7ecc23a8863176e7532a9e0d566818cce Mon Sep 17 00:00:00 2001 From: Navid Shaikh Date: Thu, 1 Mar 2018 14:02:42 +0530 Subject: [PATCH] Adds $GOPATH/bin to PATH and reduces an extra layer from image Merges `yum -y update` layer with `yum install golang` layer. Creates $GOPATH/src and $GOPATH/bin directories. Appends $GOPATH/bin to $PATH env variable. Uses $GOPATH as workdir instead of hard cording `/go` --- golang/centos7/Dockerfile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/golang/centos7/Dockerfile b/golang/centos7/Dockerfile index 974c0692..2b265ed6 100644 --- a/golang/centos7/Dockerfile +++ b/golang/centos7/Dockerfile @@ -1,10 +1,11 @@ FROM centos:7 -RUN yum -y update && yum clean all +ENV GOPATH /go -RUN mkdir -p /go && chmod -R 777 /go && \ +RUN yum -y update && \ + mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH" && \ yum -y install git golang && yum clean all -ENV GOPATH /go +ENV PATH $PATH:$GOPATH/bin -WORKDIR /go +WORKDIR $GOPATH