Awscli inside Docker: The user-provided path ./static does not exist

I’m using the awscli from a Docker image and mounting my files in the Docker container to upload my static files to S3. Everything works locally, so this is an issue with using CircleCI with Docker and the awscli.

My Makefile looks like this:

CC_AWS_BUCKET = my-bucket

DOCKER_RUN_AWSCLI = docker run --rm \
	-e "AWS_ACCESS_KEY_ID=${CC_AWS_ACCESS_KEY_ID}" \
	-e "AWS_SECRET_ACCESS_KEY=${CC_AWS_SECRET_ACCESS_KEY}" \
	-e "AWS_DEFAULT_REGION=us-east-1" \
	-v "$$(pwd):/project" \
	mesosphere/aws-cli

docker-upload-s3:
    ${DOCKER_RUN_AWSCLI} s3 cp ./static s3://${CC_AWS_BUCKET}/static --recursive

Here is what my config.yml looks like:

version: 2
workflows:
  version: 2
  install_deps_build_and_deploy:
    jobs:
      - install_deps:
          filters:
            branches:
              only: /.*/
            tags:
              ignore: /.*/
      - build_and_deploy:
          filters:
            tags:
              only: /^v.*/
            branches:
              ignore: /.*/
jobs:
  install_deps:
    docker:
      - image: circleci/node:10.12
    steps:
      - checkout
      - restore_cache:
          keys: 
            - node_modules-{{ checksum "yarn.lock" }}
            - node_modules
      - run:
          name: Install dependencies.
          command: yarn install
      - save_cache:
          key: node_modules-{{ checksum "yarn.lock" }}
          paths:
            - "node_modules"
  build_and_deploy:
    docker:
      - image: circleci/node:10.12
    steps:
      - checkout
      - setup_remote_docker
      # Can't currently use cache due to fsevents on Mac and package.lock discrepancy. Fix later.
      - run:
          name: Install dependencies.
          command: yarn install
      - run:
          name: Build the application.
          command: yarn build
      - run:
          name: Upload assets to S3.
          command: make docker-upload-s3
      - run:
          name: Login to docker.
          command: docker login -u $CC_DOCKER_USER -p $CC_DOCKER_PASSWORD > /dev/null
      - run:
          name: Build the docker image.
          command: make docker-build-pm2
      - run:
          name: Push the docker image.
          command: make docker-push-pm2
      - add_ssh_keys:
          fingerprints:
            - "xx"
      - run:
          name: Deploy pm2 applications.
          command: make remote-deploy-pm2
      - run:
          name: Deploy the nginx application!
          command: make docker-reload-nginx

So I can run make docker-upload-s3 locally, and it uploads static folder to S3. But I can’t run this inside CircleCI as I get the error I pasted above.

The files definitely exist in the CircleCI build, and I confirmed the AWS tokens work as I used the same tokens locally.

Never mind… I decided to run everything in a Docker container, including the yarn install stuff. It all works!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.