I have 3 projects using very similar (almost exact) Dockerfile. Two build images just fine on CircleCI but the third project builds an image successfully but when you try to run it, this error message is logged:
starting container process caused "chdir to cwd (\"/src\") set in config.json failed: not a directory"
/src
is from WORKDIR
in the Dockerfile below. Building locally works fine and the other 2 projects using WORKDIR
on CircleCI work fine. I’ve tried using --rm=false
and a clean cache to no avail.
Here is the Dockerfile:
FROM alpine:3.4
RUN wget "s3.amazonaws.com/aws-cli/awscli-bundle.zip" -O "awscli-bundle.zip" && \
unzip awscli-bundle.zip && \
apk add --update groff less python ca-certificates && \
rm /var/cache/apk/* && \
./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws && \
rm awscli-bundle.zip && \
rm -rf awscli-bundle
EXPOSE 4000
WORKDIR /src
COPY scripts/entrypoint.sh .
COPY go_binary_built_outside_docker .
CMD ["./entrypoint.sh"]
Here is our circle.yml
:
machine:
environment:
GODIST: "go1.7.4.linux-amd64.tar.gz"
PROJECT_GOPATH: "${HOME}/.go_workspace"
PROJECT_PARENT_PATH: "${PROJECT_GOPATH}/src/github.com/${CIRCLE_PROJECT_USERNAME}"
PROJECT_PATH: "${PROJECT_PARENT_PATH}/${CIRCLE_PROJECT_REPONAME}"
GOPATH: "${GOPATH}:${PROJECT_GOPATH}"
post:
- mkdir -p download
- test -e download/$GODIST || curl -o download/$GODIST https://storage.googleapis.com/golang/$GODIST
- sudo rm -rf /usr/local/go
- sudo tar -C /usr/local -xzf download/$GODIST
- go version
services:
- docker
dependencies:
override:
- mkdir -p "${PROJECT_PARENT_PATH}"
- rsync -avC "${HOME}/${CIRCLE_PROJECT_REPONAME}/" "${PROJECT_PATH}"
post:
- mkdir -p $GOPATH/bin
- make install
test:
override:
- cd "${PROJECT_PATH}" && make test
deployment:
prod:
branch: master
commands:
- cd "${PROJECT_PATH}" && make deploy
Here is our relevant Makefile:
build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -o repo .;
# https://circleci.com/docs/docker-btrfs-error/
ifdef CI
docker build --rm=false -t org/repo:$(CIRCLE_SHA1) .
else
docker build -t org/repo:$(CIRCLE_SHA1) .
endif
Happy to provide any other details. Thanks for the help!