Building a docker image fail at a step running webpack to build the client application (React).
Any tips why this happens?
Bitbucket says: Container 'docker' exceeded memory limit.
Dockerfile:
# Use an official Node runtime as a parent image
FROM node:8-alpine
# Install any needed tools
RUN apk add --no-cache --update curl ca-certificates openssl git && \
update-ca-certificates && \
addgroup -S app && \
adduser -S -g app app && \
mkdir -p /usr/src/app
# Prepare build
WORKDIR /usr/tmp
COPY . /usr/tmp
# CONSUMER KEY & SECRET must be set by environment
ENV CONSUMER_KEY=CONSUMER_KEY__
ENV CONSUMER_SECRET=CONSUMER_SECRET__
# Install deps and build the client
RUN ["npm", "install", "--no-save"]
RUN ["npm", "run", "build:client"]
# Set working directory for image
WORKDIR /usr/src/app
# Copy needed files for runtime
COPY /usr/tmp/node_modules /usr/src/app/node_modules
COPY /usr/tmp/build /usr/src/app/client
COPY ./server/ /usr/src/app/server
COPY ./package.json /usr/src/app
COPY Docker-cmd.sh /
# Set Docker-cmd executable
RUN chmod a+x /Docker-cmd.sh
# Clean up
RUN rm -fr /usr/tmp
# Set client application port
ENV PORT=80
# Make port 80 available to outside this container
EXPOSE ${PORT}
# Run /Docker-cmd.sh when the container launches
CMD [ "/Docker-cmd.sh" ]
bitbucket-pipeline.yml:
pipelines:
default:
- step:
name: Build Docker image
script:
- docker build -t test .
services:
- docker
caches:
- docker
Hi Amin,
As the error message says, the Docker process has run out of memory. Do you know which instruction in the Dockerfile it fails on?
You can increase the memory of docker with the following config:
pipelines:
default:
- step:
name: Build Docker image
script:
- docker build -t test .
services:
- docker
caches:
- docker
definitions:
services:
docker:
memory: 3072
More details are listed here. https://confluence.atlassian.com/bitbucket/use-services-and-databases-in-bitbucket-pipelines-874786688.html
Thanks,
Phil
I have this same issue and I don't find a good way to debug what is happening.
If I build the same image locally and follow the usage of resources with docker stats I can see that the MEM USAGE is never over 700 MiB.
I have 3072 MiB assigned to docker service in the pipeline.
Also... It appears to be completely random! Every single time this happens I just re-run the pipe and it works fine the second time.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have the same problem
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.