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

Bitbucket docker build container differs from local docker build

Anton Didenko
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!
June 29, 2023

Hi there!

Some time ago, our project was migrated from Gitlab to Bitbucket. On Gitlab, we had a pipeline to build an app inside a Docker container and push it to Gitlab, and then deploy it to ECS.

I'm using docker service and the same script in Bitbucket pipelines (except for pushing to AWS ECR), but the final image seems to be different from the one built in Gitlab or locally. Consequently, it fails to start correctly after deployment. 

Something seems to be going wrong with the AWS SDK and getcomposer installation.

Here's the relevant section of the dockerfile:

RUN apt-get update \
&& apt-get install --assume-yes -y git zip unzip \
&& curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" \
&& unzip awscliv2.zip \
&& ./aws/install \
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
&& composer require aws/aws-sdk-php \
&& rm -rf /var/lib/apt/lists/* /awscliv2.zip /aws /tmp/* /var/tmp/* /root/.composer

The command composer require aws/aws-sdk-php should create the essential vendor directory inside the working directory. I can see this directory when I build the image locally. However, the final image built using Bitbucket pipelines doesn't seem to have this directory, and I can't figure out why.

The only way to fix the app after deployment is to run this command again via SSH.

 

Could you please advice me with this issue?

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 30, 2023

Hi Anton and welcome to the community!

If I understand correctly, you are building a Docker image during a Pipelines build, from a Dockerfile that has the section you posted in your question?

If so, I haven't been able to reproduce so far the issue you are reporting. I used a Dockerfile with a base image I chose at random:

FROM php:8.3.0alpha2-zts-bullseye

WORKDIR /var

RUN apt-get update \
&& apt-get install --assume-yes -y git zip unzip \
&& curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" \
&& unzip awscliv2.zip \
&& ./aws/install \
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
&& composer require aws/aws-sdk-php \
&& rm -rf /var/lib/apt/lists/* /awscliv2.zip /aws /tmp/* /var/tmp/* /root/.composer

After building this in Pipelines and pushing it to a Docker registry, I can see the vendor directory inside /var if I start a container from this image.

  • Do you see any sort of warning or error in the output of the docker build command that would indicate some issue?

  • Are you running this Pipelines build in our own infrastructure or are you using one of our Runners?

  • Could you perhaps post all the content of the Dockerfile so I can attempt to reproduce it again? Perhaps the base image or some other command in the Dockerfile are also relevant to the issue.

    If you don't feel comfortable sharing that here, you could also create a ticket with the support team, which will be visible only to you and Atlassian staff. If we have an open support ticket, the engineer working on it will be able to access your build and troubleshooting should be faster. You can create a ticket via https://support.atlassian.com/contact/#/, in "What can we help you with?" select "Technical issues and bugs" and then Bitbucket Cloud as product.


Kind regards,
Theodora

Suggest an answer

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

Atlassian Community Events