Add go environment vendor directory support (#781)
* Add go environment vendor directory support * Use symbolink instead of copying files to gopath * Add go vendor example package & test
This commit is contained in:
@@ -5,9 +5,9 @@ FROM ${BUILDER_IMAGE}
|
||||
|
||||
FROM golang:${GO_VERSION}
|
||||
|
||||
COPY --from=0 /builder /builder
|
||||
|
||||
ENV GOPATH /usr
|
||||
WORKDIR ${GOPATH}
|
||||
|
||||
COPY --from=0 /builder /builder
|
||||
ADD build.sh /usr/local/bin/build
|
||||
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -eux
|
||||
|
||||
srcDir=${GOPATH}/src/$(basename ${SRC_PKG})
|
||||
|
||||
trap "rm -rf ${srcDir}" EXIT
|
||||
|
||||
if [ -d ${SRC_PKG} ]
|
||||
then
|
||||
echo "Building in directory ${SRC_PKG}"
|
||||
cd ${SRC_PKG}
|
||||
go build -buildmode=plugin -i -o ${DEPLOY_PKG} .
|
||||
echo "Building in directory ${srcDir}"
|
||||
ln -sf ${SRC_PKG} ${srcDir}
|
||||
elif [ -f ${SRC_PKG} ]
|
||||
then
|
||||
fn=$(basename ${SRC_PKG})
|
||||
d=/tmp/$fn
|
||||
mkdir $d
|
||||
trap "rm -rf /tmp/$fn" EXIT
|
||||
echo "Building file ${SRC_PKG} in $d"
|
||||
|
||||
cd $d
|
||||
cp ${SRC_PKG} ./function.go
|
||||
go build -buildmode=plugin -i -o ${DEPLOY_PKG} .
|
||||
echo "Building file ${SRC_PKG} in ${srcDir}"
|
||||
mkdir -p ${srcDir}
|
||||
cp ${SRC_PKG} ${srcDir}/function.go
|
||||
fi
|
||||
|
||||
cd ${srcDir}
|
||||
go build -buildmode=plugin -i -o ${DEPLOY_PKG} .
|
||||
|
||||
Reference in New Issue
Block a user