Skip to content

Commit

Permalink
Use new BuildEnv system
Browse files Browse the repository at this point in the history
  • Loading branch information
clarsonneur committed Nov 24, 2017
1 parent 4fe3cb7 commit ced6607
Show file tree
Hide file tree
Showing 15 changed files with 454 additions and 177 deletions.
2 changes: 1 addition & 1 deletion bin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fi

cd $BUILD_ENV_PROJECT

create-build-env.sh
create-go-build-env.sh

glide i

Expand Down
27 changes: 0 additions & 27 deletions bin/create-build-env.sh

This file was deleted.

45 changes: 45 additions & 0 deletions bin/create-go-build-env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash
# This file is generated by BuildEnv. Avoid updating it manually.
# Instead, contribute to BuildEnv and use 'be-update'
#

MOD=go

# From BuildEnv bin/pre-wrapper.sh

BUILD_SCRIPT_PATH=$(dirname $0)
BUILD_SCRIPT_LIB_PATH=$(dirname $BUILD_SCRIPT_PATH)/lib

if [[ ! -f $BUILD_SCRIPT_LIB_PATH/run-build-env.sh ]]
then
echo "Unable to load build-env.sh. '$BUILD_SCRIPT_LIB_PATH/run-build-env.sh' not found"
exit 1
fi

source $BUILD_SCRIPT_LIB_PATH/run-build-env.sh

set -e

if [ "$BUILD_ENV_LOADED" != "true" ]
then
echo "Please go to your project and load your build environment. 'source build-env.sh'"
exit 1
fi

cd $BUILD_ENV_PROJECT

BUILD_ENV=${BE_PROJECT}-$MOD-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
$BUILD_ENV_DOCKER build -t $BUILD_ENV $PROXY $USER build-env-docker/glide
set +x

echo "'$BUILD_ENV' image built."

18 changes: 12 additions & 6 deletions bin/glide
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
#!/bin/bash
# This file is generated by BuildEnv. Avoid updating it manually.
# Instead, contribute to BuildEnv and use 'be-update'
#

MOD=go

# From BuildEnv bin/pre-wrapper.sh

BUILD_SCRIPT_PATH=$(dirname $0)
BUILD_SCRIPT_LIB=$(dirname $BUILD_SCRIPT_PATH)/lib/run-build-env.sh
BUILD_SCRIPT_LIB_PATH=$(dirname $BUILD_SCRIPT_PATH)/lib

if [[ ! -f $BUILD_SCRIPT_LIB ]]
if [[ ! -f $BUILD_SCRIPT_LIB_PATH/run-build-env.sh ]]
then
echo "Unable to load build-env.sh. '$BUILD_SCRIPT_LIB' not found"
echo "Unable to load build-env.sh. '$BUILD_SCRIPT_LIB_PATH/run-build-env.sh' not found"
exit 1
fi

source $BUILD_SCRIPT_LIB

do_docker_run forjj-golang-env /usr/bin/glide "$@"
source $BUILD_SCRIPT_LIB_PATH/run-build-env.sh
# From BuildEnv:modules/go/bin/glide.sh

docker_run ${BE_PROJECT}-golang-env /usr/bin/glide "$@"
18 changes: 12 additions & 6 deletions bin/go
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
#!/bin/bash
# This file is generated by BuildEnv. Avoid updating it manually.
# Instead, contribute to BuildEnv and use 'be-update'
#

MOD=go

# From BuildEnv bin/pre-wrapper.sh

BUILD_SCRIPT_PATH=$(dirname $0)
BUILD_SCRIPT_LIB=$(dirname $BUILD_SCRIPT_PATH)/lib/run-build-env.sh
BUILD_SCRIPT_LIB_PATH=$(dirname $BUILD_SCRIPT_PATH)/lib

if [[ ! -f $BUILD_SCRIPT_LIB ]]
if [[ ! -f $BUILD_SCRIPT_LIB_PATH/run-build-env.sh ]]
then
echo "Unable to load build-env.sh. '$BUILD_SCRIPT_LIB' not found"
echo "Unable to load build-env.sh. '$BUILD_SCRIPT_LIB_PATH/run-build-env.sh' not found"
exit 1
fi

source $BUILD_SCRIPT_LIB
source $BUILD_SCRIPT_LIB_PATH/run-build-env.sh
# From BuildEnv:modules/go/bin/go.sh

if [[ "$CGO_ENABLED" = "0" ]]
then
Expand All @@ -35,5 +42,4 @@ then
shift
fi

do_docker_run forjj-golang-env $GOBIN $BUILD_FLAGS "$@"

docker_run $BE_PROJECT-go-env $GOBIN $BUILD_FLAGS "$@"
24 changes: 24 additions & 0 deletions build-env-docker/glide/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM golang:1.7.4

MAINTAINER [email protected]

ARG UID
ARG GID

ENV GLIDE_VERSION 0.12.3
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 groupadd -g $GID developer \
&& useradd -u $UID -g $GID developer \
&& install -d -o developer -g developer -m 755 /go/src

COPY go-static /usr/local/go/bin

WORKDIR /go/src
17 changes: 17 additions & 0 deletions build-env-docker/glide/go-static
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh -e

export CGO_ENABLED=0

DEFAULT_BIN_NAME=$(basename $(pwd))

if [ "$1" = "install" ]
then
shift
/usr/local/go/bin/go build "$@"
if [ -x $DEFAULT_BIN_NAME ]
then
mv -v $DEFAULT_BIN_NAME $GOPATH/bin
fi
else
/usr/local/go/bin/go "$@"
fi
1 change: 1 addition & 0 deletions build-env.modules
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
go
8 changes: 4 additions & 4 deletions build-env.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
BE_PROJECT=forjj
export CGO_ENABLED=0

source lib/source-be-go.sh # Functions to support GoLang
source lib/source-build-env.sh # Common Build feature and functions
# Build Environment created by buildEnv
BE_PROJECT=forjj

# Add any module parameters here

source lib/source-build-env.sh
10 changes: 7 additions & 3 deletions build-unset.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Function loaded by build-env
unset_build_env

unset CGO_ENABLED
# Build Environment created by buildEnv

# unset any module parameters here

unset_build_env
fcts="`compgen -A function unset`"
unset -f $fcts
unset fcts
23 changes: 6 additions & 17 deletions lib/README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
# Common Build env functions
# Introduction

This directory contains common functions called at source time in
bin/shell scripts.
This directory is maintained by BuildEnv (https://github.com/forj-oss/build-env)

# TODO
When you need to update it (bugs/features), refresh it as follow:

In order to share the same code and stabilize it, we will need to
centralize this file with a procedure to update the source code
from the central build-env repo.
1. load your build env with `build-env` or `source build-env.sh`
2. refresh it with `be-update`

In that way, the build-env can get fixes easily, reproducible.

I imagine to define which kind of project to may be generate such files
in bin/ like glide/go or inenv.

If the project type Golang, to maintain this Golang build env.


C Larsonneur
Forj team
This will update BuildEnv wrappers (bin/) and BuildEnv libs (lib/)
Loading

0 comments on commit ced6607

Please sign in to comment.