Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev container build breaks on Mac M1 #269

Closed
paulyuk opened this issue Sep 2, 2021 · 3 comments · Fixed by #270
Closed

Dev container build breaks on Mac M1 #269

paulyuk opened this issue Sep 2, 2021 · 3 comments · Fixed by #270
Assignees
Labels
kind/bug Something isn't working
Milestone

Comments

@paulyuk
Copy link
Contributor

paulyuk commented Sep 2, 2021

Expected Behavior

Dev Container loads and builds on any modern MacOS machine (my case MacBook Pro m1) including M1 ARM architecture.

Actual Behavior

Blocking build error, and dev container fails to load

#5 12.49 E: Unable to locate package docker-ce-cli
------
executor failed running [/bin/sh -c apt-get update     && apt-get -y install --no-install-recommends apt-utils dialog 2>&1     && apt-get -y install git openssh-client less iproute2 procps lsb-release     && apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common lsb-release     && curl -fsSL https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/gpg | (OUT=$(apt-key add - 2>&1) || echo $OUT)     && add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]') $(lsb_release -cs) stable"     && apt-get update     && apt-get install -y docker-ce-cli     && pip --disable-pip-version-check --no-cache-dir install pylint     && wget -q https://raw.githubusercontent.com/dapr/cli/master/install/install.sh -O - | /bin/bash     && groupadd --gid $USER_GID $USERNAME     && useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME     && apt-get install -y sudo     && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME    && chmod 0440 /etc/sudoers.d/$USERNAME     && apt-get autoremove -y     && apt-get clean -y     && rm -rf /var/lib/apt/lists/*]: exit code: 100
[14954 ms] Command failed: docker build -f /Users/paulyuk/src/dapr/python-sdk-m1/python-sdk/.devcontainer/Dockerfile -t vsc-python-sdk-98c0d93c7bfa1900b40dfe98f890224b /Users/paulyuk/src/dapr/python-sdk-m1/python-sdk

Steps to Reproduce the Problem

Using a MacBookPro m1

  • ensure VS Code has Remote Container extension installed (and Docker Desktop)
  • clone dapr/python-sdk repo
  • cd python-sdk
  • code .
  • at prompt, reopen in Dev Container

Detailed error:

#5 12.49 E: Unable to locate package docker-ce-cli
------
executor failed running [/bin/sh -c apt-get update     && apt-get -y install --no-install-recommends apt-utils dialog 2>&1     && apt-get -y install git openssh-client less iproute2 procps lsb-release     && apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common lsb-release     && curl -fsSL https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/gpg | (OUT=$(apt-key add - 2>&1) || echo $OUT)     && add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]') $(lsb_release -cs) stable"     && apt-get update     && apt-get install -y docker-ce-cli     && pip --disable-pip-version-check --no-cache-dir install pylint     && wget -q https://raw.githubusercontent.com/dapr/cli/master/install/install.sh -O - | /bin/bash     && groupadd --gid $USER_GID $USERNAME     && useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME     && apt-get install -y sudo     && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME    && chmod 0440 /etc/sudoers.d/$USERNAME     && apt-get autoremove -y     && apt-get clean -y     && rm -rf /var/lib/apt/lists/*]: exit code: 100
[14954 ms] Command failed: docker build -f /Users/paulyuk/src/dapr/python-sdk-m1/python-sdk/.devcontainer/Dockerfile -t vsc-python-sdk-98c0d93c7bfa1900b40dfe98f890224b /Users/paulyuk/src/dapr/python-sdk-m1/python-sdk

##Hypothesis: I believe this is related to our baseline on python3.7 image which cannot build on M1. Instead per this issue we likely want to rebaseline on a bullseye image like python39.

Release Note

RELEASE NOTE:

@paulyuk paulyuk added the kind/bug Something isn't working label Sep 2, 2021
@paulyuk
Copy link
Contributor Author

paulyuk commented Sep 2, 2021

Also, dockerfile points to a specific architecture.
add-apt-repository "deb [arch=amd64]

Should be

add-apt-repository "deb [arch=$(dpkg --print-architecture)]

@paulyuk
Copy link
Contributor Author

paulyuk commented Sep 2, 2021

Related issue in VSCode Dev Containers:
microsoft/vscode-dev-containers#558 (comment)

@paulyuk
Copy link
Contributor Author

paulyuk commented Sep 2, 2021

Hypo validated. This dockerfile resolves the issue. Note new base image in "FROM" and updated deb [arch=$. .. I will submit a PR. Thank you Chuck Lantz for ideas.

#-------------------------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation and Dapr Contributors. All rights reserved.
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#-------------------------------------------------------------------------------------------------------------

FROM python:3.9-bullseye

# Avoid warnings by switching to noninteractive
ENV DEBIAN_FRONTEND=noninteractive

# This Dockerfile adds a non-root user with sudo access. Use the "remoteUser"
# property in devcontainer.json to use it. On Linux, the container user's GID/UIDs
# will be updated to match your local UID/GID (when using the dockerFile property).
# See https://aka.ms/vscode-remote/containers/non-root-user for details.
ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID

# Uncomment the following COPY line and the corresponding lines in the `RUN` command if you wish to
# include your requirements in the image itself. It is suggested that you only do this if your
# requirements rarely (if ever) change.
# COPY requirements.txt /tmp/pip-tmp/

# Configure apt and install packages
RUN apt-get update \
    && apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \
    #
    # Verify git, process tools, lsb-release (common in install instructions for CLIs) installed
    && apt-get -y install git openssh-client less iproute2 procps lsb-release \
    # Install Docker CE CLI
    && apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common lsb-release \
    && curl -fsSL https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/gpg | (OUT=$(apt-key add - 2>&1) || echo $OUT) \
    && add-apt-repository "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]') $(lsb_release -cs) stable" \
    && apt-get update \
    && apt-get install -y docker-ce-cli \
    #
    # Install pylint
    && pip --disable-pip-version-check --no-cache-dir install pylint \
    #
    # Update Python environment based on requirements.txt
    # && pip --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \
    # && rm -rf /tmp/pip-tmp \
    #
    # Install Dapr CLI
    && wget -q https://raw.githubusercontent.com/dapr/cli/master/install/install.sh -O - | /bin/bash \
    # Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user.
    && groupadd --gid $USER_GID $USERNAME \
    && useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
    # [Optional] Add sudo support for the non-root user
    && apt-get install -y sudo \
    && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\
    && chmod 0440 /etc/sudoers.d/$USERNAME \
    #
    # Clean up
    && apt-get autoremove -y \
    && apt-get clean -y \
    && rm -rf /var/lib/apt/lists/*

# Switch back to dialog for any ad-hoc use of apt-get
ENV DEBIAN_FRONTEND=dialog

paulyuk added a commit to paulyuk/python-sdk that referenced this issue Sep 2, 2021
@wcs1only wcs1only added this to the v1.3 milestone Sep 8, 2021
wcs1only added a commit that referenced this issue Sep 8, 2021
Co-authored-by: Charlie Stanley <charlie.stanley@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants