Azure / azure-dev

A developer CLI that reduces the time it takes for you to get started on Azure. The Azure Developer CLI (azd) provides a set of developer-friendly commands that map to key stages in your workflow - code, build, deploy, monitor, repeat.
https://aka.ms/azd
MIT License
403 stars 195 forks source link

[Issue] Optimize devcontainer Dockerfiles #1533

Open jongio opened 1 year ago

jongio commented 1 year ago

We are using --platform=amd64, which shouldn't be needed anymore. Please test on Apple Silicon after removing because that would be the reason to have that flag, as it was crashing w/o it.

Also, let's investigate if we can use language specific base containers instead of the /base container.

i.e. mcr.microsoft.com/devcontainers/python:3.9

instead of mcr.microsoft.com/devcontainers/base

And do that for every lang.

For the node projects use the node base, .net/.net, etc.

pamelafox commented 1 year ago

Re --platform=amd64, is that not needed anymore with the current azd release or future ones? (I can test on my M1 if its in current release).

jongio commented 1 year ago

It's not azd dependent, so you can remove now and test. (If you feel like helped that is :))

pamelafox commented 1 year ago

Hm, when I remove it, I get a failure on what looks like the install-azd stage:

 => ERROR [dev_container_auto_added_stage_label 2/2] RUN curl -fsSL https  2.3s
------
 > [dev_container_auto_added_stage_label 2/2] RUN curl -fsSL https://aka.ms/install-azd.sh | bash     && curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg     && mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg     && sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/debian/$(lsb_release -rs | cut -d'.' -f 1)/prod $(lsb_release -cs) main" > /etc/apt/sources.list.d/dotnetdev.list'     && apt-get update && apt-get install -y azure-functions-core-tools-4     && apt update && apt-get install -y xdg-utils:
#0 2.109 install-azd: ERROR: Architecture not supported: aarch64 on platform: linux
#0 2.109 install-azd: ERROR: Unhandled
[2023-02-10T19:06:15.532Z]  error
#0 2.116 main: line 27: no_telemetry: unbound variable

It works when I put it back.

My file-

ARG VARIANT=bullseye
FROM --platform=amd64 mcr.microsoft.com/devcontainers/python:0-${VARIANT}
RUN curl -fsSL https://aka.ms/install-azd.sh | bash \
    && curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg \
    && mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg \
    && sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/debian/$(lsb_release -rs | cut -d'.' -f 1)/prod $(lsb_release -cs) main" > /etc/apt/sources.list.d/dotnetdev.list' \
    && apt-get update && apt-get install -y azure-functions-core-tools-4 \
    && apt update && apt-get install -y xdg-utils
rajeshkamal5050 commented 1 year ago

@pamelafox can you try with the internal ARM64 bits which was shared and give us feedback?

rajeshkamal5050 commented 1 year ago

@danieljurek assuming that this depends on #1314 moving to Gallium. Please adjust, if otherwise.

danieljurek commented 1 year ago

Dependency is correct. Until we're publishing ARM64 binaries for Linux the Linux devcontainers will need to run in amd64 emulation mode when running on ARM64 hosts.