Skip to content

docker: Allow passing $DOCKER_USER to set the username in the container #2001

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ci/build/clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ main() {
release-gcp \
release-images \
dist \
.cache
.cache \
node-*

pushd lib/vscode
git clean -xffd
Expand Down
3 changes: 2 additions & 1 deletion ci/release-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 18 additions & 0 deletions ci/release-image/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"
10 changes: 5 additions & 5 deletions ci/steps/release-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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_VERSION=v12.18.3
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
Expand Down