Skip to content

Commit

Permalink
Support for glide and go 1.7 from docker
Browse files Browse the repository at this point in the history
  • Loading branch information
clarsonneur committed Jan 18, 2017
1 parent 5fa56fa commit 95330d6
Show file tree
Hide file tree
Showing 11 changed files with 200 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ tasks.json
/cli/debug_cli/main.go
/*/*.iml
/vendor
.glide
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM golang:1.7.1

ENV http_proxy="http://web-proxy.gre.hpecorp.net:8080" \
https_proxy="http://web-proxy.gre.hpecorp.net:8080"

ENV APP_NAME forjj
ENV GLIDE_VERSION 0.12.1
ENV GLIDE_DOWNLOAD_URL https://github.com/Masterminds/glide/releases/download/v${GLIDE_VERSION}/glide-v${GLIDE_VERSION}-linux-amd64.tar.gz

RUN curl -fsSL "$GLIDE_DOWNLOAD_URL" -o glide.tar.gz \
&& tar -xzf glide.tar.gz \
&& mv linux-amd64/glide /usr/bin/ \
&& rm -r linux-amd64 \
&& rm glide.tar.gz
# Create a directory inside the container to store all our application and then
# make it the working directory.
RUN mkdir -p /go/src/${APP_NAME}
WORKDIR /go/src/${APP_NAME}

COPY . /go/src/${APP_NAME}

RUN glide up \
&& go build


15 changes: 14 additions & 1 deletion bin/build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
#/bin/bash
#/bin/bash -e

#CGO_ENABLED=0 go install

BUILD_ENV=forjj-golang-env

if [ "$http_proxy" != "" ]
then
PROXY="--build-arg http_proxy=$http_proxy --build-arg https_proxy=$http_proxy --build-arg no_proxy=$no_proxy"
fi

USER="--build-arg UID=$(id -u) --build-arg GID=$(id -g)"

set -x
sudo docker build -t $BUILD_ENV $PROXY $USER glide

go install

scp -P5001 $GOPATH/bin/forjj lacws.emea.hpqcorp.net:/storage/install/published/larsonsh/forjj
22 changes: 22 additions & 0 deletions bin/glide
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
#

if [ "$http_proxy" != "" ]
then
PROXY="-e http_proxy=$http_proxy -e https_proxy=$http_proxy -e no_proxy=$no_proxy"
fi

USER="-u $(id -u)"
PROJECT="$(basename $(pwd))"
echo "PROJECT = $PROJECT"

if [ "$GOPATH" = "" ]
then
echo "GOPATH not set. Please set it."
exit 1
fi

MOUNT="-v $GOPATH:/go -v $(pwd):/go/src/$PROJECT -w /go/src/$PROJECT"

sudo docker run --rm -it $MOUNT -t $BUILD_ENV $PROXY $USER forjj-golang-env /usr/bin/glide "$@"

22 changes: 22 additions & 0 deletions bin/go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
#

if [ "$http_proxy" != "" ]
then
PROXY="-e http_proxy=$http_proxy -e https_proxy=$http_proxy -e no_proxy=$no_proxy"
fi

USER="-u $(id -u)"
PROJECT="$(basename $(pwd))"
echo "PROJECT = $PROJECT"

if [ "$GOPATH" = "" ]
then
echo "GOPATH not set. Please set it."
exit 1
fi

MOUNT="-v $GOPATH:/go -v $(pwd):/go/src/$PROJECT -w /go/src/$PROJECT"

sudo docker run --rm -it $MOUNT -t $BUILD_ENV $PROXY $USER forjj-golang-env /usr/local/go/bin/go "$@"

22 changes: 22 additions & 0 deletions bin/inenv
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
#

if [ "$http_proxy" != "" ]
then
PROXY="-e http_proxy=$http_proxy -e https_proxy=$http_proxy -e no_proxy=$no_proxy"
fi

USER="-u $(id -u)"
PROJECT="$(basename $(pwd))"
echo "PROJECT = $PROJECT"

if [ "$GOPATH" = "" ]
then
echo "GOPATH not set. Please set it."
exit 1
fi

MOUNT="-v $GOPATH:/go -v $(pwd):/go/src/$PROJECT -w /go/src/$PROJECT"

sudo docker run --rm -it $MOUNT -t $BUILD_ENV $PROXY $USER forjj-golang-env bash

6 changes: 6 additions & 0 deletions build-env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
if [ "$FORJJ_PATH" = "" ]
then
FORJJ_PATH=$PATH
export PATH=$(pwd)/bin:$PATH
echo "Build env loaded. To unload it, use 'source build-unset.sh"
fi
5 changes: 5 additions & 0 deletions build-unset.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if [ "$FORJJ_PATH" != "" ]
then
export PATH=$FORJJ_PATH
unset FORJJ_PATH
fi
48 changes: 48 additions & 0 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions glide.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package: github.hpe.com/christophe-larsonneur/forjj
import:
- package: github.com/alecthomas/kingpin
repo: https://github.com/clarsonneur/kingpin
version: get-commands-from-context
- package: github.com/kr/text
- package: github.com/kvz/logstreamer
- package: github.com/forj-oss/goforjj
- package: github.com/forj-oss/forjj-modules
repo: https://github.com/clarsonneur/forjj-modules
version: new-actions
subpackages:
- trace
- cli
- package: golang.org/x/net
subpackages:
- proxy
- package: gopkg.in/yaml.v2
17 changes: 17 additions & 0 deletions glide/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM golang:1.7.1

ARG UID
ARG GID

ENV GLIDE_VERSION 0.12.1
ENV GLIDE_DOWNLOAD_URL https://github.com/Masterminds/glide/releases/download/v${GLIDE_VERSION}/glide-v${GLIDE_VERSION}-linux-amd64.tar.gz

RUN curl -fsSL "$GLIDE_DOWNLOAD_URL" -o glide.tar.gz \
&& tar -xzf glide.tar.gz \
&& mv linux-amd64/glide /usr/bin/ \
&& rm -r linux-amd64 \
&& rm glide.tar.gz
# Create a directory inside the container to store all our application and then
# make it the working directory.
RUN mkdir -p /go/src && groupadd -g $GID developer && useradd -u $UID -g $GID developer
WORKDIR /go/src

0 comments on commit 95330d6

Please sign in to comment.