My docker file which is building successfully local, is as following
FROM node:14.1-alpine AS builderCOPY . /opt/webWORKDIR /opt/webRUN npm installRUN npx browserslist@latest --update-dbENV PATH=“/opt/web/node_modules/.bin:$PATH”RUN npm run buildFROM nginx:1.17-alpineRUN apk --no-cache add curlCOPY --from=builder /opt/web/build /usr/share/nginx/htmlRUN chgrp -R 0 /var/* && chmod -R g=u /var/*CMD [“nginx”, “-g”, “daemon off;“]
# Template docker-push# This template allows you to build and push your docker image to a Docker Hub account.# The workflow allows running tests, code linting and security scans on feature branches (as well as master).# The docker image will be validated and pushed to the docker registry after the code is merged to master.# Prerequisites: $DOCKERHUB_USERNAME, $DOCKERHUB_PASSWORD setup as deployment variables# image: atlassian/default-image:3image: node:14.1-alpinepipelines:branches:feature/devops: - step:name: Build and Testscript: - IMAGE_NAME=$BITBUCKET_REPO_SLUG - docker build . --file Dockerfile --tag ${IMAGE_NAME} - docker save ${IMAGE_NAME} --output “${IMAGE_NAME}.tar”services: - dockercaches: - dockerartifacts: - “*.tar”
The final solution, which worked for me was to unset the CI before running the npm run build, along with using the npm in the bitbucket pipeline, instead of the docker file.
Here I am pasting my updated pipeline, for the successfull build
image: atlassian/default-image:3pipelines:branches:feature/devops: - step:name: Build and Testscript: - npm cache clean --force - rm -rf node_modules - npm install - unset CI - npm run build - IMAGE_NAME=${BITBUCKET_REPO_SLUG} - docker build . --file Dockerfile --tag ${IMAGE_NAME} - docker save ${IMAGE_NAME} --output "${IMAGE_NAME}.tar"services: - dockercaches: - dockerartifacts: - "*.tar"
@r.abbasi hi. Thanks for your question. Try to follow Build and push a Docker image guide.
Also the suggestion is not to use node:14.1-alpine, because alpine is minimalistic, instead use the image node:14.1
Regards, Igor
I am getting the same error for the following very simple pipeline
image: node:14.17.6pipelines:branches:feature/devops: - step:name: Build and Testscript: - npm install - npm run build
@r.abbasi hi. Try to look here https://stackoverflow.com/questions/42308879/how-to-solve-npm-error-npm-err-code-elifecycle
Also similar question: https://community.atlassian.com/t5/Bitbucket-questions/Pipe-error-when-build-test/qaq-p/1099191
Thanks @r.abbasi it works
@r.abbasi hi. Do you have warnings in your local build? This was pointed here: https://stackoverflow.com/a/58701621
Regards, Igor.
@Igor Stoyanov Yeh, I had warnings in the build. Thanks for the support.
It looks like you're new here. Sign in or register to get started.