I have a circleci build that’s failing when it tries to build a Docker image. Specifically it fails when it tries to execute an npm build script. The script fails immediately because the root user apparently doesn’t have permission to copy files within the working directory that it owns.
This is the output from the script:
#!/bin/bash -eo pipefail
.circleci/build.sh
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
Attempting to pull Docker image 472490737436.dkr.ecr.us-east-1.amazonaws.com/viewer-frontend:9d4881bac9edb04ba7395e67f5ce1bebe174b732 to check if it already exists
Building Docker image 472490737436.dkr.ecr.us-east-1.amazonaws.com/viewer-frontend:9d4881bac9edb04ba7395e67f5ce1bebe174b732 in path . with args --build-arg GITHUB_OAUTH_TOKEN=****************************************
Sending build context to Docker daemon 2.209MB
Step 1/23 : FROM ubuntu:18.04 as intermediate
---> 6526a1858e5d
Step 2/23 : ARG GITHUB_OAUTH_TOKEN
---> Using cache
---> 729e0176df2a
Step 3/23 : RUN if [ -z "$GITHUB_OAUTH_TOKEN" ]; then echo "ERROR: You must set GITHUB_OAUTH_TOKEN as a Docker build arg."; exit 1; fi
---> Using cache
---> 9c1e76fd9f31
Step 4/23 : ENV GRUNTWORK_INSTALLER_VERSION v0.0.22
---> Using cache
---> 5be8a12bf0e7
Step 5/23 : ENV GRUNTKMS_VERSION v0.0.8
---> Using cache
---> 9c63f9293dab
Step 6/23 : RUN apt-get update && apt-get install -y curl sudo
---> Using cache
---> 82905c5c5225
Step 7/23 : RUN curl -Ls https://raw.githubusercontent.com/gruntwork-io/gruntwork-installer/master/bootstrap-gruntwork-installer.sh | bash /dev/stdin --version "$GRUNTWORK_INSTALLER_VERSION" && gruntwork-install --repo "https://github.com/gruntwork-io/gruntkms" --binary-name "gruntkms" --tag "$GRUNTKMS_VERSION"
---> Using cache
---> 3d7c7a813451
Step 8/23 : FROM node:14
---> 40ce906a3734
Step 9/23 : COPY --from=intermediate /usr/local/bin/gruntkms /usr/local/bin/gruntkms
---> Using cache
---> 722669b4aef6
Step 10/23 : RUN npm install --verbose -g nodemon
---> Using cache
---> 26b365fb9c36
Step 11/23 : WORKDIR /app
---> Using cache
---> 70e28906a6fc
Step 12/23 : COPY package*.json ./
---> Using cache
---> 0c1a57856ce2
Step 13/23 : RUN npm install --verbose
---> Using cache
---> ba1140507066
Step 14/23 : COPY . .
---> 9e37f7329a72
Step 15/23 : RUN chown -R $USER:$USER /app
---> Running in 135fbbe7be09
---> f731eb0b9069
Removing intermediate container 135fbbe7be09
Step 16/23 : RUN chmod -R 777 /app
---> Running in 67a201716d10
---> 626afd0d553f
Removing intermediate container 67a201716d10
Step 17/23 : RUN ls -lah /app/
---> Running in a41a7bc9d85d
total 1.1M
drwxrwxrwx 23 root root 4.0K Sep 10 01:01 .
drwxr-xr-x 70 root root 4.0K Sep 10 01:01 ..
drwxrwxrwx 2 root root 4.0K Sep 10 01:01 .circleci
-rwxrwxrwx 1 root root 31 Sep 10 01:00 .dockerignore
-rwxrwxrwx 1 root root 145 Sep 10 01:00 .env
-rwxrwxrwx 1 root root 49 Sep 10 01:00 .eslintignore
-rwxrwxrwx 1 root root 280 Sep 10 01:00 .gitignore
-rwxrwxrwx 1 root root 1.8K Sep 10 01:00 Dockerfile
-rwxrwxrwx 1 root root 5.5K Sep 10 01:00 README.md
drwxrwxrwx 2 root root 4.0K Sep 10 01:01 bin
drwxrwxrwx 2 root root 4.0K Sep 10 01:01 config
-rwxrwxrwx 1 root root 419 Sep 10 01:00 docker-compose.yml
drwxrwxrwx 3503 root root 36K Sep 10 01:01 node_modules
-rwxrwxrwx 1 root root 925K Sep 10 01:00 package-lock.json
-rwxrwxrwx 1 root root 3.5K Sep 10 01:00 package.json
drwxrwxrwx 5 root root 4.0K Sep 10 01:01 public
-rwxrwxrwx 1 root root 3.2K Sep 10 01:00 server.js
drwxrwxrwx 23 root root 4.0K Sep 10 01:01 src
drwxrwxrwx 2 root root 4.0K Sep 10 01:01 tls
-rwxrwxrwx 1 root root 636 Sep 10 01:00 tsconfig.json
---> 2d7aa40e3015
Removing intermediate container a41a7bc9d85d
Step 18/23 : RUN pwd
---> Running in bbc89db60d6c
/app
---> babae612e9c4
Removing intermediate container bbc89db60d6c
Step 19/23 : RUN whoami
---> Running in 2931d31574c0
root
---> 26e10bac5681
Removing intermediate container 2931d31574c0
Step 20/23 : RUN npm run build
---> Running in 3351dd1a1e5a
> viewer-frontend@0.2.0 build /app
> react-scripts build
Failed to compile.
EPERM: operation not permitted, copyfile '/app/public/favicon.ico' -> '/app/build/favicon.ico'