npm run build does not create build directory on elasticbeanstalk












0















I am still puzzled as to why the npm run build command on an elasticbeanstalk instance does not produce the build folder when when I build the dockerfile. Its definitely not a permissions issue as I can mkdir and touch new directory and file respectively. I even list it in the dockerfile and I can confirm that the build folder isn't there.
Also the npm install works and I cal see all the installed libraries in there



However when I build the same dockerfile locally, I can see that it creates a build folder. So its definetely an environment issue. I read somewhere that sometimes npm install can time out on t2.micro. So I even upgraded to t2.small. Still the issue persists.
Can someone help me figure out as to what is going on here ?



Below is my dockerfile



FROM node:alpine as builder
WORKDIR '/app'
COPY package.json ./
RUN npm install
COPY ./ ./
RUN ls
RUN pwd
CMD ["npm", "run" ,"build"]
RUN mkdir varun
RUN touch var
RUN ls

FROM nginx
EXPOSE 80
RUN pwd
COPY --from=builder ./app/build /usr/share/nginx/html


Below are the elasticbeanstalk logs



i-0276e4b74ee15c98f Severe  29 minutes  18  --  --  --  --  --  --  --  --  --  --  0.03    0.28    0.2 0.1 99.7    0.0
Application update failed at 2018-12-29T06:18:23Z with exit status 1 and error: Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/03build.sh failed.

cat: Dockerrun.aws.json: No such file or directory
cat: Dockerrun.aws.json: No such file or directory
cat: Dockerrun.aws.json: No such file or directory
alpine: Pulling from library/node
7fc670963d22: Pull complete
Digest: sha256:d2180576a96698b0c7f0b00474c48f67a494333d9ecb57c675700395aeeb2c35
Status: Downloaded newer image for node:alpine
Successfully pulled node:alpine
Sending build context to Docker daemon 625.7kB
Step 1/15 : FROM node:alpine as builder
---> 9036ebdbc59d
Step 2/15 : WORKDIR '/app'
---> Running in e623a08307d5
Removing intermediate container e623a08307d5
---> b4e9fe3e4b82
Step 3/15 : COPY package.json ./
---> cb5e6a9b109b
Step 4/15 : RUN npm install
---> Running in 8a00eb1143a5
[91mnpm[0m[91m [0m[91mWARN[0m[91m

Removing intermediate container 8a00eb1143a5
---> c568ef0a4bc3
Step 5/15 : COPY ./ ./
---> cfb3e22fc373
Step 6/15 : RUN ls
---> Running in f6aad2a0f22e
Dockerfile
Dockerfile.dev
README.md
docker-compose.yml
node_modules
package-lock.json
package.json
public
src
Removing intermediate container f6aad2a0f22e
---> 016d1ded2f97
Step 7/15 : RUN pwd
---> Running in eaae644b1d96
/app
Removing intermediate container eaae644b1d96
---> 61285a5062ea
Step 8/15 : CMD ["npm", "run" ,"build"]
---> Running in 5cbca2213f4f
Removing intermediate container 5cbca2213f4f
---> 8566953eebaa
Step 9/15 : RUN mkdir varun
---> Running in a078760b6dcb
Removing intermediate container a078760b6dcb
---> 34c25b5aab32
Step 10/15 : RUN touch var
---> Running in d725dafc9409
Removing intermediate container d725dafc9409
---> 70195ffecb54
Step 11/15 : RUN ls
---> Running in b96bc198883c
Dockerfile
Dockerfile.dev
README.md
docker-compose.yml
node_modules
package-lock.json
package.json
public
src
var
varun
Removing intermediate container b96bc198883c
---> 1b205ffb5e3f
Step 12/15 : FROM nginx
latest: Pulling from library/nginx
bbdb1fbd4a86: Pull complete
Digest: sha256:304008857c8b73ed71fefde161dd336240e116ead1f756be5c199afe816bc448
Status: Downloaded newer image for nginx:latest
---> 7042885a156a
Step 13/15 : EXPOSE 80
---> Running in 412e17c44274
Removing intermediate container 412e17c44274
---> e1e1ea0c7dfb
Step 14/15 : RUN pwd
---> Running in 1bc298a11ef1
/
Removing intermediate container 1bc298a11ef1
---> 291575f13e2f
Step 15/15 : COPY --from=builder ./app/build /usr/share/nginx/html
COPY failed: stat /var/lib/docker/devicemapper/mnt/e2b112f1a046c00990aa6fc01e9fabc9e147420a214682a06637ef8cbcb9414a/rootfs/app/build: no such file or directory
Failed to build Docker image aws_beanstalk/staging-app, retrying...
Sending build context to Docker daemon 625.7kB









share|improve this question



























    0















    I am still puzzled as to why the npm run build command on an elasticbeanstalk instance does not produce the build folder when when I build the dockerfile. Its definitely not a permissions issue as I can mkdir and touch new directory and file respectively. I even list it in the dockerfile and I can confirm that the build folder isn't there.
    Also the npm install works and I cal see all the installed libraries in there



    However when I build the same dockerfile locally, I can see that it creates a build folder. So its definetely an environment issue. I read somewhere that sometimes npm install can time out on t2.micro. So I even upgraded to t2.small. Still the issue persists.
    Can someone help me figure out as to what is going on here ?



    Below is my dockerfile



    FROM node:alpine as builder
    WORKDIR '/app'
    COPY package.json ./
    RUN npm install
    COPY ./ ./
    RUN ls
    RUN pwd
    CMD ["npm", "run" ,"build"]
    RUN mkdir varun
    RUN touch var
    RUN ls

    FROM nginx
    EXPOSE 80
    RUN pwd
    COPY --from=builder ./app/build /usr/share/nginx/html


    Below are the elasticbeanstalk logs



    i-0276e4b74ee15c98f Severe  29 minutes  18  --  --  --  --  --  --  --  --  --  --  0.03    0.28    0.2 0.1 99.7    0.0
    Application update failed at 2018-12-29T06:18:23Z with exit status 1 and error: Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/03build.sh failed.

    cat: Dockerrun.aws.json: No such file or directory
    cat: Dockerrun.aws.json: No such file or directory
    cat: Dockerrun.aws.json: No such file or directory
    alpine: Pulling from library/node
    7fc670963d22: Pull complete
    Digest: sha256:d2180576a96698b0c7f0b00474c48f67a494333d9ecb57c675700395aeeb2c35
    Status: Downloaded newer image for node:alpine
    Successfully pulled node:alpine
    Sending build context to Docker daemon 625.7kB
    Step 1/15 : FROM node:alpine as builder
    ---> 9036ebdbc59d
    Step 2/15 : WORKDIR '/app'
    ---> Running in e623a08307d5
    Removing intermediate container e623a08307d5
    ---> b4e9fe3e4b82
    Step 3/15 : COPY package.json ./
    ---> cb5e6a9b109b
    Step 4/15 : RUN npm install
    ---> Running in 8a00eb1143a5
    [91mnpm[0m[91m [0m[91mWARN[0m[91m

    Removing intermediate container 8a00eb1143a5
    ---> c568ef0a4bc3
    Step 5/15 : COPY ./ ./
    ---> cfb3e22fc373
    Step 6/15 : RUN ls
    ---> Running in f6aad2a0f22e
    Dockerfile
    Dockerfile.dev
    README.md
    docker-compose.yml
    node_modules
    package-lock.json
    package.json
    public
    src
    Removing intermediate container f6aad2a0f22e
    ---> 016d1ded2f97
    Step 7/15 : RUN pwd
    ---> Running in eaae644b1d96
    /app
    Removing intermediate container eaae644b1d96
    ---> 61285a5062ea
    Step 8/15 : CMD ["npm", "run" ,"build"]
    ---> Running in 5cbca2213f4f
    Removing intermediate container 5cbca2213f4f
    ---> 8566953eebaa
    Step 9/15 : RUN mkdir varun
    ---> Running in a078760b6dcb
    Removing intermediate container a078760b6dcb
    ---> 34c25b5aab32
    Step 10/15 : RUN touch var
    ---> Running in d725dafc9409
    Removing intermediate container d725dafc9409
    ---> 70195ffecb54
    Step 11/15 : RUN ls
    ---> Running in b96bc198883c
    Dockerfile
    Dockerfile.dev
    README.md
    docker-compose.yml
    node_modules
    package-lock.json
    package.json
    public
    src
    var
    varun
    Removing intermediate container b96bc198883c
    ---> 1b205ffb5e3f
    Step 12/15 : FROM nginx
    latest: Pulling from library/nginx
    bbdb1fbd4a86: Pull complete
    Digest: sha256:304008857c8b73ed71fefde161dd336240e116ead1f756be5c199afe816bc448
    Status: Downloaded newer image for nginx:latest
    ---> 7042885a156a
    Step 13/15 : EXPOSE 80
    ---> Running in 412e17c44274
    Removing intermediate container 412e17c44274
    ---> e1e1ea0c7dfb
    Step 14/15 : RUN pwd
    ---> Running in 1bc298a11ef1
    /
    Removing intermediate container 1bc298a11ef1
    ---> 291575f13e2f
    Step 15/15 : COPY --from=builder ./app/build /usr/share/nginx/html
    COPY failed: stat /var/lib/docker/devicemapper/mnt/e2b112f1a046c00990aa6fc01e9fabc9e147420a214682a06637ef8cbcb9414a/rootfs/app/build: no such file or directory
    Failed to build Docker image aws_beanstalk/staging-app, retrying...
    Sending build context to Docker daemon 625.7kB









    share|improve this question

























      0












      0








      0








      I am still puzzled as to why the npm run build command on an elasticbeanstalk instance does not produce the build folder when when I build the dockerfile. Its definitely not a permissions issue as I can mkdir and touch new directory and file respectively. I even list it in the dockerfile and I can confirm that the build folder isn't there.
      Also the npm install works and I cal see all the installed libraries in there



      However when I build the same dockerfile locally, I can see that it creates a build folder. So its definetely an environment issue. I read somewhere that sometimes npm install can time out on t2.micro. So I even upgraded to t2.small. Still the issue persists.
      Can someone help me figure out as to what is going on here ?



      Below is my dockerfile



      FROM node:alpine as builder
      WORKDIR '/app'
      COPY package.json ./
      RUN npm install
      COPY ./ ./
      RUN ls
      RUN pwd
      CMD ["npm", "run" ,"build"]
      RUN mkdir varun
      RUN touch var
      RUN ls

      FROM nginx
      EXPOSE 80
      RUN pwd
      COPY --from=builder ./app/build /usr/share/nginx/html


      Below are the elasticbeanstalk logs



      i-0276e4b74ee15c98f Severe  29 minutes  18  --  --  --  --  --  --  --  --  --  --  0.03    0.28    0.2 0.1 99.7    0.0
      Application update failed at 2018-12-29T06:18:23Z with exit status 1 and error: Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/03build.sh failed.

      cat: Dockerrun.aws.json: No such file or directory
      cat: Dockerrun.aws.json: No such file or directory
      cat: Dockerrun.aws.json: No such file or directory
      alpine: Pulling from library/node
      7fc670963d22: Pull complete
      Digest: sha256:d2180576a96698b0c7f0b00474c48f67a494333d9ecb57c675700395aeeb2c35
      Status: Downloaded newer image for node:alpine
      Successfully pulled node:alpine
      Sending build context to Docker daemon 625.7kB
      Step 1/15 : FROM node:alpine as builder
      ---> 9036ebdbc59d
      Step 2/15 : WORKDIR '/app'
      ---> Running in e623a08307d5
      Removing intermediate container e623a08307d5
      ---> b4e9fe3e4b82
      Step 3/15 : COPY package.json ./
      ---> cb5e6a9b109b
      Step 4/15 : RUN npm install
      ---> Running in 8a00eb1143a5
      [91mnpm[0m[91m [0m[91mWARN[0m[91m

      Removing intermediate container 8a00eb1143a5
      ---> c568ef0a4bc3
      Step 5/15 : COPY ./ ./
      ---> cfb3e22fc373
      Step 6/15 : RUN ls
      ---> Running in f6aad2a0f22e
      Dockerfile
      Dockerfile.dev
      README.md
      docker-compose.yml
      node_modules
      package-lock.json
      package.json
      public
      src
      Removing intermediate container f6aad2a0f22e
      ---> 016d1ded2f97
      Step 7/15 : RUN pwd
      ---> Running in eaae644b1d96
      /app
      Removing intermediate container eaae644b1d96
      ---> 61285a5062ea
      Step 8/15 : CMD ["npm", "run" ,"build"]
      ---> Running in 5cbca2213f4f
      Removing intermediate container 5cbca2213f4f
      ---> 8566953eebaa
      Step 9/15 : RUN mkdir varun
      ---> Running in a078760b6dcb
      Removing intermediate container a078760b6dcb
      ---> 34c25b5aab32
      Step 10/15 : RUN touch var
      ---> Running in d725dafc9409
      Removing intermediate container d725dafc9409
      ---> 70195ffecb54
      Step 11/15 : RUN ls
      ---> Running in b96bc198883c
      Dockerfile
      Dockerfile.dev
      README.md
      docker-compose.yml
      node_modules
      package-lock.json
      package.json
      public
      src
      var
      varun
      Removing intermediate container b96bc198883c
      ---> 1b205ffb5e3f
      Step 12/15 : FROM nginx
      latest: Pulling from library/nginx
      bbdb1fbd4a86: Pull complete
      Digest: sha256:304008857c8b73ed71fefde161dd336240e116ead1f756be5c199afe816bc448
      Status: Downloaded newer image for nginx:latest
      ---> 7042885a156a
      Step 13/15 : EXPOSE 80
      ---> Running in 412e17c44274
      Removing intermediate container 412e17c44274
      ---> e1e1ea0c7dfb
      Step 14/15 : RUN pwd
      ---> Running in 1bc298a11ef1
      /
      Removing intermediate container 1bc298a11ef1
      ---> 291575f13e2f
      Step 15/15 : COPY --from=builder ./app/build /usr/share/nginx/html
      COPY failed: stat /var/lib/docker/devicemapper/mnt/e2b112f1a046c00990aa6fc01e9fabc9e147420a214682a06637ef8cbcb9414a/rootfs/app/build: no such file or directory
      Failed to build Docker image aws_beanstalk/staging-app, retrying...
      Sending build context to Docker daemon 625.7kB









      share|improve this question














      I am still puzzled as to why the npm run build command on an elasticbeanstalk instance does not produce the build folder when when I build the dockerfile. Its definitely not a permissions issue as I can mkdir and touch new directory and file respectively. I even list it in the dockerfile and I can confirm that the build folder isn't there.
      Also the npm install works and I cal see all the installed libraries in there



      However when I build the same dockerfile locally, I can see that it creates a build folder. So its definetely an environment issue. I read somewhere that sometimes npm install can time out on t2.micro. So I even upgraded to t2.small. Still the issue persists.
      Can someone help me figure out as to what is going on here ?



      Below is my dockerfile



      FROM node:alpine as builder
      WORKDIR '/app'
      COPY package.json ./
      RUN npm install
      COPY ./ ./
      RUN ls
      RUN pwd
      CMD ["npm", "run" ,"build"]
      RUN mkdir varun
      RUN touch var
      RUN ls

      FROM nginx
      EXPOSE 80
      RUN pwd
      COPY --from=builder ./app/build /usr/share/nginx/html


      Below are the elasticbeanstalk logs



      i-0276e4b74ee15c98f Severe  29 minutes  18  --  --  --  --  --  --  --  --  --  --  0.03    0.28    0.2 0.1 99.7    0.0
      Application update failed at 2018-12-29T06:18:23Z with exit status 1 and error: Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/03build.sh failed.

      cat: Dockerrun.aws.json: No such file or directory
      cat: Dockerrun.aws.json: No such file or directory
      cat: Dockerrun.aws.json: No such file or directory
      alpine: Pulling from library/node
      7fc670963d22: Pull complete
      Digest: sha256:d2180576a96698b0c7f0b00474c48f67a494333d9ecb57c675700395aeeb2c35
      Status: Downloaded newer image for node:alpine
      Successfully pulled node:alpine
      Sending build context to Docker daemon 625.7kB
      Step 1/15 : FROM node:alpine as builder
      ---> 9036ebdbc59d
      Step 2/15 : WORKDIR '/app'
      ---> Running in e623a08307d5
      Removing intermediate container e623a08307d5
      ---> b4e9fe3e4b82
      Step 3/15 : COPY package.json ./
      ---> cb5e6a9b109b
      Step 4/15 : RUN npm install
      ---> Running in 8a00eb1143a5
      [91mnpm[0m[91m [0m[91mWARN[0m[91m

      Removing intermediate container 8a00eb1143a5
      ---> c568ef0a4bc3
      Step 5/15 : COPY ./ ./
      ---> cfb3e22fc373
      Step 6/15 : RUN ls
      ---> Running in f6aad2a0f22e
      Dockerfile
      Dockerfile.dev
      README.md
      docker-compose.yml
      node_modules
      package-lock.json
      package.json
      public
      src
      Removing intermediate container f6aad2a0f22e
      ---> 016d1ded2f97
      Step 7/15 : RUN pwd
      ---> Running in eaae644b1d96
      /app
      Removing intermediate container eaae644b1d96
      ---> 61285a5062ea
      Step 8/15 : CMD ["npm", "run" ,"build"]
      ---> Running in 5cbca2213f4f
      Removing intermediate container 5cbca2213f4f
      ---> 8566953eebaa
      Step 9/15 : RUN mkdir varun
      ---> Running in a078760b6dcb
      Removing intermediate container a078760b6dcb
      ---> 34c25b5aab32
      Step 10/15 : RUN touch var
      ---> Running in d725dafc9409
      Removing intermediate container d725dafc9409
      ---> 70195ffecb54
      Step 11/15 : RUN ls
      ---> Running in b96bc198883c
      Dockerfile
      Dockerfile.dev
      README.md
      docker-compose.yml
      node_modules
      package-lock.json
      package.json
      public
      src
      var
      varun
      Removing intermediate container b96bc198883c
      ---> 1b205ffb5e3f
      Step 12/15 : FROM nginx
      latest: Pulling from library/nginx
      bbdb1fbd4a86: Pull complete
      Digest: sha256:304008857c8b73ed71fefde161dd336240e116ead1f756be5c199afe816bc448
      Status: Downloaded newer image for nginx:latest
      ---> 7042885a156a
      Step 13/15 : EXPOSE 80
      ---> Running in 412e17c44274
      Removing intermediate container 412e17c44274
      ---> e1e1ea0c7dfb
      Step 14/15 : RUN pwd
      ---> Running in 1bc298a11ef1
      /
      Removing intermediate container 1bc298a11ef1
      ---> 291575f13e2f
      Step 15/15 : COPY --from=builder ./app/build /usr/share/nginx/html
      COPY failed: stat /var/lib/docker/devicemapper/mnt/e2b112f1a046c00990aa6fc01e9fabc9e147420a214682a06637ef8cbcb9414a/rootfs/app/build: no such file or directory
      Failed to build Docker image aws_beanstalk/staging-app, retrying...
      Sending build context to Docker daemon 625.7kB






      amazon-web-services docker npm dockerfile amazon-elastic-beanstalk






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Dec 29 '18 at 6:30









      Varun Babu PozhathVarun Babu Pozhath

      242214




      242214
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Oh my god..Finally after 1 full day of tinkering everything on aws, figured it out. I was using CMD instead of RUN to execute the command npm run build. CMD doesn't actually run it when you are building a dockerfile. So the folder isn't actually there for my second image to use.






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53967262%2fnpm-run-build-does-not-create-build-directory-on-elasticbeanstalk%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Oh my god..Finally after 1 full day of tinkering everything on aws, figured it out. I was using CMD instead of RUN to execute the command npm run build. CMD doesn't actually run it when you are building a dockerfile. So the folder isn't actually there for my second image to use.






            share|improve this answer




























              0














              Oh my god..Finally after 1 full day of tinkering everything on aws, figured it out. I was using CMD instead of RUN to execute the command npm run build. CMD doesn't actually run it when you are building a dockerfile. So the folder isn't actually there for my second image to use.






              share|improve this answer


























                0












                0








                0







                Oh my god..Finally after 1 full day of tinkering everything on aws, figured it out. I was using CMD instead of RUN to execute the command npm run build. CMD doesn't actually run it when you are building a dockerfile. So the folder isn't actually there for my second image to use.






                share|improve this answer













                Oh my god..Finally after 1 full day of tinkering everything on aws, figured it out. I was using CMD instead of RUN to execute the command npm run build. CMD doesn't actually run it when you are building a dockerfile. So the folder isn't actually there for my second image to use.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Dec 29 '18 at 7:59









                Varun Babu PozhathVarun Babu Pozhath

                242214




                242214






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53967262%2fnpm-run-build-does-not-create-build-directory-on-elasticbeanstalk%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Monofisismo

                    Angular Downloading a file using contenturl with Basic Authentication

                    Olmecas