Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce docker runcontext #236

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build-env-docker/glide/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ MAINTAINER [email protected]
ARG UID
ARG GID

ENV GLIDE_VERSION 0.13.1
ENV GLIDE_VERSION 0.13.2
ENV GLIDE_DOWNLOAD_URL=https://github.com/Masterminds/glide/releases/download/v${GLIDE_VERSION}/glide-v${GLIDE_VERSION}-linux-amd64.tar.gz \
GLIDE_HOME=/go/.glide/${GLIDE_VERSION}

Expand Down
17 changes: 6 additions & 11 deletions driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ func (a *Forj) driver_do(d *drivers.Driver, instance_name, action string, args .
d.Plugin.RunningFromDebugger()
}

if v := os.Getenv("FORJJ_SOURCE_BASE") ; v != "" {
d.Plugin.PluginBase(v)
d.Plugin.PluginSetSourceMount(path.Join(a.i.Path(), "apps", d.DriverType))
d.Plugin.PluginSetWorkspaceMount(a.w.Path())
d.Plugin.PluginSetDeploymentMount(a.d.GetReposPath())
}
d.Plugin.PluginSetSource(path.Join(a.i.Path(), "apps", d.DriverType))
d.Plugin.PluginSetDeployment(a.d.GetReposPath())
d.Plugin.PluginSetDeploymentName(a.d.Name())
Expand All @@ -205,17 +211,6 @@ func (a *Forj) driver_do(d *drivers.Driver, instance_name, action string, args .

d.Plugin.ServiceAddEnv("LOGNAME", "$LOGNAME", false)
d.Plugin.Yaml.Runtime.Docker.Env["LOGNAME"] = "$LOGNAME"
if v := os.Getenv("http_proxy"); v != "" {
d.Plugin.Yaml.Runtime.Docker.Env["http_proxy"] = v
d.Plugin.Yaml.Runtime.Docker.Env["https_proxy"] = v
}
if v := os.Getenv("no_proxy"); v != "" {
d.Plugin.Yaml.Runtime.Docker.Env["no_proxy"] = v
}
if v, b, _ := d.Plugin.GetDockerDoodParameters(); v != nil {
d.Plugin.Yaml.Runtime.Docker.Env["DOCKER_DOOD"] = strings.Join(v, " ")
d.Plugin.Yaml.Runtime.Docker.Env["DOCKER_DOOD_BECOME"] = strings.Join(b, " ")
}

if err := d.Plugin.PluginStartService(); err != nil {
return err, false
Expand Down
18 changes: 11 additions & 7 deletions glide.lock

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

21 changes: 21 additions & 0 deletions lib/build-env.fcts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ function be_ci_detected {
export CI_ENABLED=FALSE
if [[ "$WORKSPACE" != "" ]]
then
set +xe
echo "Jenkins environment detected"
export CI_WORKSPACE="$WORKSPACE"
export CI_ENABLED=TRUE
Expand Down Expand Up @@ -251,6 +252,26 @@ function docker_build_env {
then
be_create_${1}_docker_build
fi

if [[ $1 = core ]]
then
_be_gitignore
fi
}

function _be_gitignore {
if [[ -f .gitignore ]]
then
if [[ "$(grep '^.be-\*$' .gitignore)" = "" ]]
then
echo ".be-*" >> .gitignore
echo ".gitignore updated."
fi
else
echo ".be-*" > .gitignore
echo ".gitignore created."
fi

}

function _be_set_debug {
Expand Down
28 changes: 28 additions & 0 deletions lib/source-be-go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,34 @@ function go_check_and_set {
fi
echo "$1" > .be-gopath
echo "$1 added as GOPATH"
else # Determine GOPATH from current path
local curPath=$(pwd)
local parentPath=$(dirname $curPath)
local parentName=$(basename $parentPath)

while [[ $found = false ]]
do
if [[ $parentName == src ]]
then
# Check if curPath has .git
if [[ ! -d "$curPath/.git" ]]
then
echo "Unable to determine GOPATH: $curPath is not a valid GIT repository"
fi
gopath=$(dirname $parentPath)
break
fi
curPath=$parentPath
parentPath=$(dirname $curPath)
parentName=$(basename $parentPath)

done
if [[ $parentName == src ]]
then
local gopath=$(dirname $parentPath)
echo "$gopath" > .be-gopath
echo "Detected $gopath as GOPATH from $(pwd). If wrong, update .be-gopath"
fi
fi

if [[ -f .be-gopath ]]
Expand Down
4 changes: 2 additions & 2 deletions lib/source-build-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

source lib/build-env.fcts.sh

be_ci_detected

if [[ -f .build-env.def ]]
then
for var in $(grep -e '^\(.*=.*\)' .build-env.def)
Expand Down Expand Up @@ -29,8 +31,6 @@ then
return
fi

be_ci_detected

be_setup

if [ $# -ne 0 ]
Expand Down