diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 882e1f5a..68838998 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,14 +1,30 @@ FROM mcr.microsoft.com/devcontainers/base:ubuntu -ARG TARGETARCH -ENV TARGETARCH=${TARGETARCH} +# provide DOCKER_GID via build args if you need to force group id to match host +ARG DOCKER_GID + +# specify DOCKER_GID to force container docker group id to match host +RUN if [ -n "${DOCKER_GID}" ]; then \ + if ! getent group docker; then \ + groupadd -g ${DOCKER_GID} docker; \ + else \ + groupmod -g ${DOCKER_GID} docker; \ + fi && \ + usermod -aG docker vscode; \ + fi ARG ASDF_VERSION COPY .tool-versions.asdf /tmp/.tool-versions.asdf +ARG TARGETARCH +ENV TARGETARCH=${TARGETARCH} + # Add amd64 architecture if on arm64 RUN if [ "$TARGETARCH" = "arm64" ] || [ "$TARGETARCH" = "aarch64" ]; then dpkg --add-architecture amd64; fi +# Anticipate and resolve potential permission issues with apt +RUN mkdir -p /tmp && chmod 1777 /tmp + RUN apt-get update \ && export DEBIAN_FRONTEND=noninteractive \ && apt-get -y dist-upgrade \ @@ -51,7 +67,6 @@ RUN ASDF_VERSION=$(awk '!/^#/ && NF {print $1; exit}' /tmp/.tool-versions.asdf) tar -xvzf /tmp/asdf.tar.gz && \ mv asdf /usr/bin - USER vscode ENV PATH="/home/vscode/.asdf/shims/:$PATH" diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 046e505f..23bb9210 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -6,7 +6,9 @@ "build": { "dockerfile": "Dockerfile", "context": "..", - "args": {} + "args": { + "DOCKER_GID": "${env:DOCKER_GID:}" + } }, "mounts": [ "source=${env:HOME}${env:USERPROFILE}/.aws,target=/home/vscode/.aws,type=bind",