11FROM mcr.microsoft.com/devcontainers/base:ubuntu
22
3+ # provide DOCKER_GID via build args if you need to force group id to match host
4+ ARG DOCKER_GID
5+ ARG TARGETARCH
6+ ENV TARGETARCH=${TARGETARCH}
7+
8+ ARG ASDF_VERSION
9+ COPY .tool-versions.asdf /tmp/.tool-versions.asdf
10+
11+ RUN if [ "$TARGETARCH" = "arm64" ] || [ "$TARGETARCH" = "aarch64" ]; then dpkg --add-architecture arm64; fi
12+
13+ # Anticipate and resolve potential permission issues with apt
14+ RUN mkdir -p /tmp && chmod 1777 /tmp
315# Install system dependencies
416RUN apt-get update \
517 && export DEBIAN_FRONTEND=noninteractive \
@@ -8,49 +20,76 @@ RUN apt-get update \
820 libffi-dev libssl-dev libxml2-dev libxslt1-dev libjpeg8-dev libbz2-dev \
921 zlib1g-dev unixodbc unixodbc-dev libsecret-1-0 libsecret-1-dev libsqlite3-dev \
1022 jq apt-transport-https ca-certificates gnupg-agent \
11- software-properties-common bash-completion python3-pip make libbz2-dev \
23+ software-properties-common bash-completion python3-pip make \
1224 libreadline-dev libsqlite3-dev wget llvm libncurses5-dev libncursesw5-dev \
13- xz-utils tk-dev liblzma-dev netcat-openbsd libyaml-dev
25+ xz-utils tk-dev liblzma-dev netcat-traditional libyaml-dev
1426
1527# Install aws stuff
16- RUN wget -O /tmp/awscliv2.zip "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" && \
28+ RUN if [ "$TARGETARCH" = "arm64" ] || [ "$TARGETARCH" = "aarch64" ]; then \
29+ wget -O /tmp/awscliv2.zip "https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip" ; \
30+ else \
31+ wget -O /tmp/awscliv2.zip "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" ; \
32+ fi && \
1733 unzip /tmp/awscliv2.zip -d /tmp/aws-cli && \
1834 /tmp/aws-cli/aws/install && \
19- rm tmp/awscliv2.zip && \
20- rm -rf /tmp/aws-cli
35+ rm /tmp/awscliv2.zip && rm -rf /tmp/aws-cli
2136
22- # Set user to vscode
23- USER vscode
37+ RUN if [ "$TARGETARCH" = "arm64" ] || [ "$TARGETARCH" = "aarch64" ]; then \
38+ wget -O /tmp/aws-sam-cli.zip "https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-arm64.zip" ; \
39+ else \
40+ wget -O /tmp/aws-sam-cli.zip "https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-x86_64.zip" ; \
41+ fi && \
42+ unzip /tmp/aws-sam-cli.zip -d /tmp/aws-sam-cli && \
43+ /tmp/aws-sam-cli/install && \
44+ rm /tmp/aws-sam-cli.zip && rm -rf /tmp/aws-sam-cli
2445
2546# Install ASDF
26- RUN git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.11.3; \
27- echo '. $HOME/.asdf/asdf.sh' >> ~/.bashrc; \
28- echo '. $HOME/.asdf/completions/asdf.bash' >> ~/.bashrc; \
47+ RUN ASDF_VERSION=$(awk '!/^#/ && NF {print $1; exit}' /tmp/.tool-versions.asdf) && \
48+ if [ "$TARGETARCH" = "arm64" ] || [ "$TARGETARCH" == "aarch64" ]; then \
49+ wget -O /tmp/asdf.tar.gz "https://github.com/asdf-vm/asdf/releases/download/v${ASDF_VERSION}/asdf-v${ASDF_VERSION}-linux-arm64.tar.gz" ; \
50+ else \
51+ wget -O /tmp/asdf.tar.gz "https://github.com/asdf-vm/asdf/releases/download/v${ASDF_VERSION}/asdf-v${ASDF_VERSION}-linux-amd64.tar.gz" ; \
52+ fi && \
53+ tar -xzf /tmp/asdf.tar.gz -C /tmp && \
54+ mkdir -p /usr/bin && \
55+ mv /tmp/asdf /usr/bin/asdf && \
56+ chmod +x /usr/bin/asdf && \
57+ rm -rf /tmp/asdf.tar.gz
58+
59+ # specify DOCKER_GID to force container docker group id to match host
60+ RUN if [ -n "${DOCKER_GID}" ]; then \
61+ if ! getent group docker; then \
62+ groupadd -g ${DOCKER_GID} docker; \
63+ else \
64+ groupmod -g ${DOCKER_GID} docker; \
65+ fi && \
66+ usermod -aG docker vscode; \
67+ fi
68+
69+ USER vscode
70+
71+ ENV PATH="/home/vscode/.asdf/shims/:$PATH"
72+ RUN \
73+ echo 'PATH="/home/vscode/.asdf/shims/:$PATH"' >> ~/.bashrc; \
2974 echo '# Install Ruby Gems to ~/gems' >> ~/.bashrc; \
3075 echo 'export GEM_HOME="$HOME/gems"' >> ~/.bashrc; \
3176 echo 'export PATH="$HOME/gems/bin:$PATH"' >> ~/.bashrc;
3277
33- ENV PATH="$PATH:/home/vscode/.asdf/bin/:/ workspaces/eps-assist-me/node_modules/.bin"
78+ ENV PATH="$PATH:/workspaces/eps-assist-me/node_modules/.bin"
3479
3580# Install ASDF plugins
36- RUN asdf plugin add python; \
37- asdf plugin add poetry https://github.com/asdf-community/asdf-poetry.git; \
38- asdf plugin add shellcheck https://github.com/luizm /asdf-shellcheck .git; \
39- asdf plugin add nodejs https://github.com/asdf-vm /asdf-nodejs .git; \
40- asdf plugin add direnv; \
41- asdf plugin add actionlint; \
81+ RUN asdf plugin add python && \
82+ asdf plugin add poetry https://github.com/asdf-community/asdf-poetry.git && \
83+ asdf plugin add nodejs https://github.com/asdf-vm /asdf-nodejs .git && \
84+ asdf plugin add shellcheck https://github.com/luizm /asdf-shellcheck .git && \
85+ asdf plugin add direnv && \
86+ asdf plugin add actionlint && \
4287 asdf plugin add ruby https://github.com/asdf-vm/asdf-ruby.git
4388
44- # Set working directory
4589WORKDIR /workspaces/eps-assist-me
46-
47- # Copy .tool-versions
4890ADD .tool-versions /workspaces/eps-assist-me/.tool-versions
4991ADD .tool-versions /home/vscode/.tool-versions
5092
51- # Install tools
52- RUN asdf install; \
53- asdf reshim python; \
54- asdf reshim poetry; \
55- asdf reshim nodejs; \
56- asdf direnv setup --shell bash --version 2.32.2;
93+ # install python before poetry to ensure correct python version is used
94+ RUN asdf install python && \
95+ asdf install
0 commit comments