aws / aws-codebuild-docker-images

Official AWS CodeBuild repository for managed Docker images http://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref.html
Other
1.1k stars 970 forks source link

Unable to build Docker image on Mac #575

Open fade2black opened 1 year ago

fade2black commented 1 year ago

Unable to build a Ubuntu 6.0 image

To Reproduce

$ git clone https://github.com/aws/aws-codebuild-docker-images.git
$ cd aws-codebuild-docker-images
$ cd ubuntu/standard/6.0
$ docker build -t aws/codebuild/standard:6.0 .

Expected behavior Create a new image

Logs

> [tools  3/10] RUN set -ex     && mkdir /tmp/ssm     && cd /tmp/ssm     && wget -q https://s3.amazonaws.com/amazon-ssm-us-east-1/latest/debian_amd64/amazon-ssm-agent.deb     && dpkg -i amazon-ssm-agent.deb:                                                                                                                                                                                          
#9 0.204 + mkdir /tmp/ssm                                                                                                                                                                            
#9 0.215 + cd /tmp/ssm
#9 0.215 + wget -q https://s3.amazonaws.com/amazon-ssm-us-east-1/latest/debian_amd64/amazon-ssm-agent.deb
#9 2.646 + dpkg -i amazon-ssm-agent.deb
#9 2.683 dpkg: error processing archive amazon-ssm-agent.deb (--install):
#9 2.683  package architecture (amd64) does not match system (arm64)
#9 2.693 Errors were encountered while processing:
#9 2.693  amazon-ssm-agent.deb
------
executor failed running [/bin/sh -c set -ex     && mkdir /tmp/ssm     && cd /tmp/ssm     && wget -q https://s3.amazonaws.com/amazon-ssm-us-east-1/latest/debian_amd64/amazon-ssm-agent.deb     && dpkg -i amazon-ssm-agent.deb]: exit code: 1

Platform:

plimbore commented 1 year ago

I encountered the same problem on Apple M1 Max, 32 GB, Monterey 12.0.1

Here is the fix:

P.S.: After these fixes there is another issue that may come in JAVA installation. I overcame that problem by removing dpkg --add-architecture i386 line and the image built successfully.

ivan-strogan commented 1 year ago

Describe the bug I am attempting to build the docker image on an Apple MacBook Pro with the M2Max hardware through the use of the built-in Rosetta x86/amd64 emulation.

To Reproduce Steps to reproduce the behavior:

  1. Clone repo
  2. cd into 7.0 folder
  3. Run docker build --platform=linux/amd64 -t aws/codebuild/standard:7.0 .
  4. I have also tried using docker build --platform=linux/amd64 --no-cache -t aws/codebuild/standard:7.0 . to ensure that it wasn't a cached data issue
  5. I get the following error
➜  7.0 git:(master) ✗ docker build --platform=linux/amd64 --no-cache -t aws/codebuild/standard:7.0 .
[+] Building 2672.4s (33/46)
 => [internal] load build definition from Dockerfile                                                                                        0.0s
 => => transferring dockerfile: 75B                                                                                                         0.0s
 => [internal] load .dockerignore                                                                                                           0.0s
 => => transferring context: 2B                                                                                                             0.0s
 => [internal] load metadata for public.ecr.aws/ubuntu/ubuntu:22.04                                                                         0.4s
 => [internal] load build context                                                                                                           0.0s
 => => transferring context: 925B                                                                                                           0.0s
 => CACHED [core 1/3] FROM public.ecr.aws/ubuntu/ubuntu:22.04@sha256:5fb5e64ee0d78fed9d65da71ed83dd61a8be37ffe01448c6d56cd61a98734302       0.0s
 => [core 2/3] RUN set -ex     && echo 'Acquire::CompressionTypes::Order:: "gz";' > /etc/apt/apt.conf.d/99use-gzip-compression     && ap  241.4s
 => [core 3/3] RUN useradd codebuild-user                                                                                                   0.4s
 => [tools  1/10] RUN set -ex    && STUNNEL_VERSION=5.69    && STUNNEL_TAR=stunnel-$STUNNEL_VERSION.tar.gz    && STUNNEL_SHA256="1ff7d9f3  58.0s
 => [tools  2/10] RUN curl -sS -o /usr/local/bin/aws-iam-authenticator https://s3.us-west-2.amazonaws.com/amazon-eks/1.25.6/2023-01-30/bin  8.3s
 => [tools  3/10] RUN set -ex     && mkdir /tmp/ssm     && cd /tmp/ssm     && wget -q https://s3.amazonaws.com/amazon-ssm-us-east-1/latest  2.6s
 => [tools  4/10] RUN curl https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip -o /tmp/awscliv2.zip     && unzip -q /tmp/awscliv2.zip  5.7s
 => [tools  5/10] RUN set -ex  && wget -qO /usr/local/bin/dotnet-install.sh https://dot.net/v1/dotnet-install.sh && chmod +x /usr/local/bi  1.1s
 => [tools  6/10] RUN git clone https://github.com/tj/n /usr/src/n      && cd /usr/src/n && make install                                    1.6s
 => [tools  7/10] RUN set -ex     && git clone https://github.com/rbenv/rbenv.git /usr/local/rbenv     && mkdir -p /usr/local/rbenv/plugin  2.6s
 => [tools  8/10] RUN curl https://pyenv.run | bash                                                                                         5.3s
 => [tools  9/10] RUN curl -L https://raw.githubusercontent.com/phpenv/phpenv-installer/master/bin/phpenv-installer | bash                  5.5s
 => [tools 10/10] RUN git clone https://github.com/syndbg/goenv.git $HOME/.goenv                                                            1.6s
 => [runtimes  1/14] RUN  /usr/local/bin/dotnet-install.sh -v 6.0.407      && dotnet --list-sdks      && rm -rf /tmp/*                     13.2s
 => [runtimes  2/14] RUN set -ex     && mkdir warmup     && cd warmup     && dotnet new     && cd ..     && rm -rf warmup     && rm -rf /t  2.9s
 => [runtimes  3/14] RUN set -ex     && curl -SL https://github.com/PowerShell/PowerShell/releases/download/v7.3.3/powershell-7.3.3-linux-  4.6s
 => [runtimes  4/14] RUN  n 18.15.0 && npm install --save-dev -g -f grunt && npm install --save-dev -g -f grunt-cli && npm install --save  15.0s
 => [runtimes  5/14] RUN rbenv install 3.2.1 && rm -rf /tmp/*     && rbenv global 3.2.1 && ruby -v                                        590.1s
 => [runtimes  6/14] COPY tools/runtime_configs/python/3.11.2 /root/.pyenv/plugins/python-build/share/python-build/3.11.2                   0.0s
 => [runtimes  7/14] RUN env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.11.2 && rm -rf /tmp/*                                294.6s
 => [runtimes  8/14] RUN pyenv global 3.11.2                                                                                                0.7s
 => [runtimes  9/14] RUN set -ex     && pip3 install --no-cache-dir --upgrade --force-reinstall "pip==23.0.1"     && pip3 install --no-ca  48.0s
 => [runtimes 10/14] COPY tools/runtime_configs/php/8.2.4 /root/.phpenv/plugins/php-build/share/php-build/definitions/8.2.4                 0.0s
 => [runtimes 11/14] RUN phpenv install 8.2.4 && rm -rf /tmp/* && phpenv global 8.2.4                                                    1259.5s
 => [runtimes 12/14] RUN echo "memory_limit = 1G;" >> "/root/.phpenv/versions/8.2.4/etc/conf.d/memory.ini"                                  0.1s
 => [runtimes 13/14] RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer                     2.2s
 => [runtimes 14/14] RUN goenv install 1.20.2 && rm -rf /tmp/* &&     goenv global  1.20.2 &&     go env -w GO111MODULE=auto                9.0s
 => [runtimes_n_corretto 1/5] RUN set -ex     && apt-get update     && apt-get install -y -qq software-properties-common apt-utils     &&  85.0s
 => ERROR [runtimes_n_corretto 2/5] RUN set -ex     && mkdir -p /opt/maven     && curl -LSso /var/tmp/apache-maven-3.9.1-bin.tar.gz https  12.9s
------
 > [runtimes_n_corretto 2/5] RUN set -ex     && mkdir -p /opt/maven     && curl -LSso /var/tmp/apache-maven-3.9.1-bin.tar.gz https://archive.apache.org/dist/maven/maven-3/3.9.1/binaries/apache-maven-3.9.1-bin.tar.gz     && echo "d3be5956712d1c2cf7a6e4c3a2db1841aa971c6097c7a67f59493a5873ccf8c8b889cf988e4e9801390a2b1ae5a0669de07673acb090a083232dbd3faf82f3e3 /var/tmp/apache-maven-3.9.1-bin.tar.gz" | sha512sum -c -     && tar xzf /var/tmp/apache-maven-3.9.1-bin.tar.gz -C /opt/maven --strip-components=1     && rm /var/tmp/apache-maven-3.9.1-bin.tar.gz     && update-alternatives --install /usr/bin/mvn mvn /opt/maven/bin/mvn 10000     && mkdir -p /root/.m2     && mkdir -p /usr/src/gradle     && wget -q "https://services.gradle.org/distributions/gradle-8.0.2-all.zip" -O "/usr/src/gradle/gradle-8.0.2-all.zip"     && unzip -q "/usr/src/gradle/gradle-8.0.2-all.zip" -d /usr/local     && echo "47a5bfed9ef814f90f8debcbbb315e8e7c654109acd224595ea39fca95c5d4da 8.0.2" | grep "8.0.2" | sed "s|8.0.2|/usr/src/gradle/gradle-8.0.2-all.zip|" | sha256sum -c -     && rm "/usr/src/gradle/gradle-8.0.2-all.zip"     && mkdir "/tmp/gradle-8.0.2"     && "/usr/local/gradle-8.0.2/bin/gradle" -p "/tmp/gradle-8.0.2" init     && "/usr/local/gradle-8.0.2/bin/gradle" -p "/tmp/gradle-8.0.2" wrapper     && perl -pi -e "s/gradle-8.0.2-bin.zip/gradle-8.0.2-all.zip/" "/tmp/gradle-8.0.2/gradle/wrapper/gradle-wrapper.properties"     && "/tmp/gradle-8.0.2/gradlew" -p "/tmp/gradle-8.0.2" init     && rm -rf "/tmp/gradle-8.0.2"      && ln -s /usr/local/gradle-8.0.2/bin/gradle /usr/bin/gradle     && rm -rf /usr/src/gradle     && curl -fSL "https://github.com/sbt/sbt/releases/download/v1.8.2/sbt-1.8.2.tgz" -o sbt.tgz     && echo "1f65344da074dbd66dfefa93c0eff8d319d772e5cad47fcbeb6ae178bbdf4686 *sbt.tgz" | sha256sum -c -     && tar xzf sbt.tgz -C /usr/local/bin/     && rm sbt.tgz:
#33 0.311 + mkdir -p /opt/maven
#33 0.328 + curl -LSso /var/tmp/apache-maven-3.9.1-bin.tar.gz https://archive.apache.org/dist/maven/maven-3/3.9.1/binaries/apache-maven-3.9.1-bin.tar.gz
#33 2.591 + echo d3be5956712d1c2cf7a6e4c3a2db1841aa971c6097c7a67f59493a5873ccf8c8b889cf988e4e9801390a2b1ae5a0669de07673acb090a083232dbd3faf82f3e3 /var/tmp/apache-maven-3.9.1-bin.tar.gz
#33 2.591 + sha512sum -c -
#33 2.634 /var/tmp/apache-maven-3.9.1-bin.tar.gz: OK
#33 2.635 + tar xzf /var/tmp/apache-maven-3.9.1-bin.tar.gz -C /opt/maven --strip-components=1
#33 2.740 + rm /var/tmp/apache-maven-3.9.1-bin.tar.gz
#33 2.758 + update-alternatives --install /usr/bin/mvn mvn /opt/maven/bin/mvn 10000
#33 2.779 update-alternatives: using /opt/maven/bin/mvn to provide /usr/bin/mvn (mvn) in auto mode
#33 2.782 + mkdir -p /root/.m2
#33 2.797 + mkdir -p /usr/src/gradle
#33 2.813 + wget -q https://services.gradle.org/distributions/gradle-8.0.2-all.zip -O /usr/src/gradle/gradle-8.0.2-all.zip
#33 8.138 + unzip -q /usr/src/gradle/gradle-8.0.2-all.zip -d /usr/local
#33 10.50 + echo 47a5bfed9ef814f90f8debcbbb315e8e7c654109acd224595ea39fca95c5d4da 8.0.2
#33 10.50 + grep 8.0.2
#33 10.50 + sed s|8.0.2|/usr/src/gradle/gradle-8.0.2-all.zip|
#33 10.50 + sha256sum -c -
#33 11.13 /usr/src/gradle/gradle-8.0.2-all.zip: OK
#33 11.13 + rm /usr/src/gradle/gradle-8.0.2-all.zip
#33 11.18 + mkdir /tmp/gradle-8.0.2
#33 11.20 + /usr/local/gradle-8.0.2/bin/gradle -p /tmp/gradle-8.0.2 init
#33 12.28
#33 12.28 Welcome to Gradle 8.0.2!
#33 12.28
#33 12.28 Here are the highlights of this release:
#33 12.28  - Improvements to the Kotlin DSL
#33 12.28  - Fine-grained parallelism from the first build with configuration cache
#33 12.28  - Configurable Gradle user home cache cleanup
#33 12.28
#33 12.29 For more details see https://docs.gradle.org/8.0.2/release-notes.html
#33 12.29
#33 12.48 Starting a Gradle Daemon (subsequent builds will be faster)
#33 12.50
#33 12.50 FAILURE: Build failed with an exception.
#33 12.50
#33 12.50 * What went wrong:
#33 12.50 A problem occurred starting process 'Gradle build daemon'
#33 12.50
#33 12.50 * Try:
#33 12.50 > Run with --stacktrace option to get the stack trace.
#33 12.50 > Run with --info or --debug option to get more log output.
#33 12.50 > Run with --scan to get full insights.
#33 12.50
#33 12.50 * Get more help at https://help.gradle.org
------
executor failed running [/bin/sh -c set -ex     && mkdir -p $MAVEN_HOME     && curl -LSso /var/tmp/apache-maven-$MAVEN_VERSION-bin.tar.gz https://archive.apache.org/dist/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz     && echo "$MAVEN_DOWNLOAD_SHA512 /var/tmp/apache-maven-$MAVEN_VERSION-bin.tar.gz" | sha512sum -c -     && tar xzf /var/tmp/apache-maven-$MAVEN_VERSION-bin.tar.gz -C $MAVEN_HOME --strip-components=1     && rm /var/tmp/apache-maven-$MAVEN_VERSION-bin.tar.gz     && update-alternatives --install /usr/bin/mvn mvn /opt/maven/bin/mvn 10000     && mkdir -p $MAVEN_CONFIG_HOME     && mkdir -p $GRADLE_PATH     && wget -q "https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-all.zip" -O "$GRADLE_PATH/gradle-$GRADLE_VERSION-all.zip"     && unzip -q "$GRADLE_PATH/gradle-$GRADLE_VERSION-all.zip" -d /usr/local     && echo "$GRADLE_DOWNLOADS_SHA256" | grep "$GRADLE_VERSION" | sed "s|$GRADLE_VERSION|$GRADLE_PATH/gradle-$GRADLE_VERSION-all.zip|" | sha256sum -c -     && rm "$GRADLE_PATH/gradle-$GRADLE_VERSION-all.zip"     && mkdir "/tmp/gradle-$GRADLE_VERSION"     && "/usr/local/gradle-$GRADLE_VERSION/bin/gradle" -p "/tmp/gradle-$GRADLE_VERSION" init     && "/usr/local/gradle-$GRADLE_VERSION/bin/gradle" -p "/tmp/gradle-$GRADLE_VERSION" wrapper     && perl -pi -e "s/gradle-$GRADLE_VERSION-bin.zip/gradle-$GRADLE_VERSION-all.zip/" "/tmp/gradle-$GRADLE_VERSION/gradle/wrapper/gradle-wrapper.properties"     && "/tmp/gradle-$GRADLE_VERSION/gradlew" -p "/tmp/gradle-$GRADLE_VERSION" init     && rm -rf "/tmp/gradle-$GRADLE_VERSION"      && ln -s /usr/local/gradle-$GRADLE_VERSION/bin/gradle /usr/bin/gradle     && rm -rf $GRADLE_PATH     && curl -fSL "https://github.com/sbt/sbt/releases/download/v${SBT_VERSION}/sbt-${SBT_VERSION}.tgz" -o sbt.tgz     && echo "${SBT_DOWNLOAD_SHA256} *sbt.tgz" | sha256sum -c -     && tar xzf sbt.tgz -C /usr/local/bin/     && rm sbt.tgz]: exit code: 1

Expected behavior Expect for the build to finish successfully.

Logs Currently N/A

Platform (please complete the following information):

Additional context Currently N/A

jhaoheng commented 11 months ago

hi there

Today, I got the same problem, and got a nice answer from @plimbore, thank you. And I see there still have not pull-request to fixed this problem. Almost a year, even add a Dockerfile-arm64 is a good option to fix this problem and reduce the next developer to ask the same question.