Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Building a Nuxt project using Docker only fails in the BitBucket pipeline

bweber
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 27, 2024

I have a project I am building that uses Vue with Vite and Nuxt. The project uses Docker, and the docker container builds completely normally in my local environment. When I try to build the docker container in the bitbucket pipeline environment, it fails every time. I have tried many different solutions around allocating space, but they haven't made a difference. I also can't find any way to get a more detailed error log, so the only error I'm left with tells me nothing. I also have tried making my environment as close to the bitbucket pipelines as I can, but every build still works locally. I'm left with these questions:

1) How can I get a more helpful error log?

2) Are there any tools for replicating the bitbucket pipeline environment on my computer so I can reproduce the problem locally?

3) Why would a docker build work locally but not in the bitbucket pipeline? Isn't the point of docker that it works in every environment? (My best lead at the moment is that they use two different networks, but I don't know how that would change anything)

 


This is my Docker file:

 

# Declare the base image
FROM node:18-alpine

# Build step
# 1. copy package.json and package-lock.json to /app dir
RUN mkdir /app
COPY ./package*.json /app/

# 2. Change working directory to newly created app dir
WORKDIR /app

# 3 . Install dependencies
RUN npm cache clean --force && npm install

# 4. Copy the source code to /app dir
COPY . .

# 5. Build the app
RUN npm run build

# 6. Expose port 4173 on the container
EXPOSE 4173

# 7. Run the app
CMD ["npm", "run", "preview"]

 


This is the relevant error log in the bitbucket pipeline:
#4 [9/9] RUN npm run build
#4 sha256:0fe8ab14dc2301ac8aaaf368f0a3e3be4bdb196f812e8b09835bf029f0b62ccd
#4 0.529
#4 0.529 > curator@0.0.0 build
#4 0.529 > cross-env NUXT_APP_BASE_URL=/curator-ui/ nuxt build --verbose
#4 0.529
#4 0.914 Nuxt 3.11.2 with Nitro 2.9.6
#4 4.763 ℹ Building client...
#4 4.779 ℹ vite v5.2.8 building for production...
#4 4.823 ℹ transforming...
#4 16.33 ℹ ✓ 854 modules transformed.
#4 16.78 Inspect report generated at /app/.nuxt/analyze/.vite-inspect
#4 17.44 ℹ rendering chunks...
#4 18.05 ℹ computing gzip size...
#4 18.19 ℹ .nuxt/dist/client/manifest.json                        10.12 kB │ gzip:   1.49 kB
#4 18.19 ℹ .nuxt/dist/client/_nuxt/LoadingOverlay.CN2Vr0U1.css     0.08 kB │ gzip:   0.10 kB
... This continues with a bunch of nuxt items ...
#4 18.23 ℹ .nuxt/dist/client/_nuxt/C47_dAMR.js                   535.55 kB │ gzip: 175.07 kB
#4 18.23 ℹ .nuxt/dist/client/_nuxt/DrsPblm4.js                   917.27 kB │ gzip: 305.09 kB
#4 18.23 ℹ ✓ built in 13.46s
#4 18.24 ✔ Client built in 13472ms
#4 18.24 ℹ Building server...
#4 18.24 ℹ vite v5.2.8 building SSR bundle for production...
#4 18.35 ℹ transforming...
#4 30.21 ℹ ✓ 713 modules transformed.
#4 31.25 Inspect report generated at /app/.nuxt/analyze/.vite-inspect
#4 32.45 ℹ rendering chunks...
#4 33.29 ℹ .nuxt/dist/server/_nuxt/_id_-styles.CNX6znJC.mjs                        0.08 kB
#4 33.29 ℹ .nuxt/dist/server/_nuxt/_id_-styles.aREm4Hto.mjs                        0.08 kB
... This continues with a bunch of chunks ...
#4 33.41 ℹ .nuxt/dist/server/_nuxt/entry-styles-1.mjs-Cf-N_X7E.js                242.99 kB │ map:     0.11 kB
#4 33.41 ℹ .nuxt/dist/server/server.mjs                                          790.34 kB │ map: 1,596.65 kB
#4 33.41 ℹ ✓ built in 15.17s
#4 33.43 ✔ Server built in 15191ms
#4 33.53 [nitro] ✔ Generated public .output/public
#4 33.54 [nitro] ℹ Building Nuxt Nitro server (preset: node-server)
#4 200.8 [nitro] ✔ Nuxt Nitro server built
#4 ERROR: process "/bin/sh -c npm run build" did not complete successfully: exit code: 1
------
> [9/9] RUN npm run build:
------
process "/bin/sh -c npm run build" did not complete successfully: exit code: 1

On a successful local build, the logs will continue at the error point by listing all the chunks built by the nitro server, giving the total size, and showing a command for previewing the application.

1 answer

1 accepted

1 vote
Answer accepted
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 28, 2024

Hey @bweber ,

and welcome to the Community!

By reading your description, I understand the error is happening during a Docker build. The Docker build is executed in a separate container (docker service container) from the build container (where the script runs) and has its own memory allocated to it.

I suspect you may be using the default memory allocated to docker service, which is 1GB, and this is not being enough for the npm command to complete, hence causing your build to fail.

For that, I would suggest that you increase the memory for the docker service by adding the following definition to your YML file : 

definitions:
services:
docker:
memory: 2048

This would make 2GB of memory available for the docker service. You can start with 2GB and increase it as needed.

Considering that the docker service is the only service in your step, in normal steps you can increase the size of the docker service up to 3GB, while in large steps (size: 2x), it can be defined as up to 7GB.

For more details on how memory is allocated between the build and service containers, I would also recommend checking the following documentation: 

I hope that helps! Let us know in case you have any questions.

Thank you, @bweber !

Patrik S

bweber
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 28, 2024

Hi Patrik,

Thank you for the welcome!

The solution you proposed ended up working! Thank you so much. I have spent countless hours running in circles over this, and I really appreciate you taking the time to respond.

Thanks again!

Braden

Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 28, 2024

Hey @bweber ,

You're very welcome!

Happy to hear that increasing the docker memory did the trick :) 

Feel free to reach out to the Community if you ever need help in the future.

Have a great day, @bweber !

Patrik S

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events