Archived
1
0

Merge pull request #2001 from cdr/docker-user-1c5d

docker: Allow passing $DOCKER_USER to set the username in the container
This commit is contained in:
Anmol Sethi 2020-08-27 15:51:28 -04:00 committed by GitHub
commit d8d5908d85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 7 deletions

View File

@ -13,7 +13,8 @@ main() {
release-gcp \
release-images \
dist \
.cache
.cache \
node-*
pushd lib/vscode
git clean -xffd

View File

@ -35,9 +35,10 @@ RUN ARCH="$(dpkg --print-architecture)" && \
printf "user: coder\ngroup: coder\n" > /etc/fixuid/config.yml
COPY release-packages/code-server*.deb /tmp/
COPY ci/release-image/entrypoint.sh /usr/bin/entrypoint.sh
RUN dpkg -i /tmp/code-server*$(dpkg --print-architecture).deb && rm /tmp/code-server*.deb
EXPOSE 8080
USER coder
WORKDIR /home/coder
ENTRYPOINT ["dumb-init", "fixuid", "-q", "/usr/bin/code-server", "--bind-addr", "0.0.0.0:8080", "."]
ENTRYPOINT ["/usr/bin/entrypoint.sh", "--bind-addr", "0.0.0.0:8080", "."]

18
ci/release-image/entrypoint.sh Executable file
View File

@ -0,0 +1,18 @@
#!/usr/bin/env sh
set -eu
if [ "${DOCKER_USER-}" ]; then
echo "$DOCKER_USER ALL=(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers.d/nopasswd > /dev/null
sudo usermod --login "$DOCKER_USER" \
--move-home --home "/home/$DOCKER_USER" \
coder
sudo groupmod -n "$DOCKER_USER" coder
sudo sed -i "/coder/d" /etc/sudoers.d/nopasswd
sudo sed -i "s/coder/$DOCKER_USER/g" /etc/fixuid/config.yml
export HOME="/home/$DOCKER_USER"
fi
# This isn't set by default.
export USER="$(whoami)"
dumb-init fixuid -q /usr/bin/code-server "$@"

View File

@ -4,11 +4,11 @@ set -euo pipefail
main() {
cd "$(dirname "$0")/../.."
if [[ $OSTYPE == darwin* ]]; then
NODE_VERSION=v12.18.3
curl -L "https://nodejs.org/dist/$NODE_VERSION/node-$NODE_VERSION-darwin-x64.tar.gz" | tar -xz
PATH="$PWD/node-$NODE_VERSION-darwin-x64/bin:$PATH"
fi
NODE_OS="$(uname | tr '[:upper:]' '[:lower:]')"
NODE_ARCH="$(uname -m | sed 's/86_64/64/; s/aarch64/arm64/')"
curl -L "https://nodejs.org/dist/$NODE_VERSION/node-$NODE_VERSION-$NODE_OS-$NODE_ARCH.tar.gz" | tar -xz
PATH="$PWD/node-$NODE_VERSION-$NODE_OS-$NODE_ARCH/bin:$PATH"
# https://github.com/actions/upload-artifact/issues/38
tar -xzf release-npm-package/package.tar.gz