Shell commands are not available

I’m trying to execute beego commands while building the following pipeline. It throws an error at the build phase saying bee: not found. I’ve verified that command independently inside the docker image.

workspace:
 base: /go
 path: src/github.com/apremalal/my-app

pipeline:
 build:
   image: apremalal/glide:0.5
   environment:    
     - GOOS=linux
     - GOARCH=amd64
   commands:
     - export PATH=$PATH:$GOPATH/bin
     - bee gendocs
     - glide install
     - export CGO_ENABLED=0
     - export GOOS=linux
     - export GOARCH=amd64
     - go test -v -coverpkg=./controllers ./controllers_test -coverprofile=c.out && go tool cover -func=c.out
     - go build
   when:
     event: [ push, tag ]

This is the Dockerfile for apremalal/glide. I was able to execute bee commands locally using this image.

# https://hub.docker.com/_/golang
FROM golang:1.10-alpine

MAINTAINER Anuruddha <anuruddhapremalal@gmail.com>

RUN apk update && \
    apk upgrade && \
    apk add git

RUN go get golang.org/x/tools/cmd/goimports
RUN go get github.com/beego/bee
RUN apk add --update --no-cache \
        ca-certificates \
        # https://github.com/Masterminds/glide#supported-version-control-systems
        git mercurial subversion bzr \
        openssh \
 && update-ca-certificates \
    \
 # Install build dependencies
 && apk add --no-cache --virtual .build-deps \
        curl make \
    \
 # Download and unpack Glide sources
 && curl -L -o /tmp/glide.tar.gz \
          https://github.com/Masterminds/glide/archive/v0.13.1.tar.gz \
 && tar -xzf /tmp/glide.tar.gz -C /tmp \
 && mkdir -p $GOPATH/src/github.com/Masterminds \
 && mv /tmp/glide-* $GOPATH/src/github.com/Masterminds/glide \
 && cd $GOPATH/src/github.com/Masterminds/glide \
    \
 # Build and install Glide executable
 && make install \
    \
 # Install Glide license
 && mkdir -p /usr/local/share/doc/glide \
 && cp LICENSE /usr/local/share/doc/glide/ \
    \
 # Cleanup unnecessary files
 && apk del .build-deps \
 && rm -rf /var/cache/apk/* \
           $GOPATH/src/* \
           /tmp/*

ENV PATH=$PATH:$GOPATH/bin
WORKDIR $GOPATH

What would be the reason for bee command to not available in drone execution environment?

What would be the reason for bee command to not available in drone execution environment?

Yes, because the workspace is set to /go which means a volume is mounted at this path. This volume overrides the original folder in the image, which is why /go/bin is not available. For example, consider this:

docker volume create foo
docker run -v foo:/go apremalal/glide:0.5

I recommend moving the bee binary to /bin in your base image, so that it is not impacted when a volume is mounted on top of /go

+RUN mv /go/bin/bee /bin
ENV PATH=$PATH:$GOPATH/bin
WORKDIR $GOPATH

You could alternatively try altering the base workspace path, but note that this could potentially lead to other complications

workspace:
- base: /go
- path: src/github.com/apremalal/my-app
+ base: /go/src
+ path: github.com/apremalal/my-app

Thanks for the great explanation. Went with altering the workspace path and it worked.