Skip to content

Commit

Permalink
Configure devcontainer to use same uid/gid as docker base (#2872)
Browse files Browse the repository at this point in the history
  • Loading branch information
relud committed Jan 8, 2024
1 parent f3da607 commit b7deda8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
FROM mcr.microsoft.com/devcontainers/python:3.11-bullseye@sha256:105bf6a63ab025206f019a371a735fec6553db0be520030c7a2fd0e002947232

ARG userid=10001
ARG groupid=10001

WORKDIR /app

# add a non-privileged user for installing and running the application
RUN groupadd --gid $groupid app && \
useradd -g app --uid $userid --shell /usr/sbin/nologin --create-home app && \
chown app:app /app/

# Install Debian packages
RUN apt-get update && \
apt-get install -y ripgrep
Expand Down
4 changes: 3 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,7 @@
"charliermarsh.ruff"
]
}
}
},
"remoteUser": "app",
"updateRemoteUserUID": false
}
3 changes: 3 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ services:
service: test
build:
dockerfile: .devcontainer/Dockerfile
args:
userid: ${USE_UID:-10001}
groupid: ${USE_GID:-10001}
image: tecken-devcontainer
entrypoint: ["sleep", "inf"]

Expand Down

0 comments on commit b7deda8

Please sign in to comment.