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:
commit
d8d5908d85
@ -13,7 +13,8 @@ main() {
|
|||||||
release-gcp \
|
release-gcp \
|
||||||
release-images \
|
release-images \
|
||||||
dist \
|
dist \
|
||||||
.cache
|
.cache \
|
||||||
|
node-*
|
||||||
|
|
||||||
pushd lib/vscode
|
pushd lib/vscode
|
||||||
git clean -xffd
|
git clean -xffd
|
||||||
|
@ -35,9 +35,10 @@ RUN ARCH="$(dpkg --print-architecture)" && \
|
|||||||
printf "user: coder\ngroup: coder\n" > /etc/fixuid/config.yml
|
printf "user: coder\ngroup: coder\n" > /etc/fixuid/config.yml
|
||||||
|
|
||||||
COPY release-packages/code-server*.deb /tmp/
|
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
|
RUN dpkg -i /tmp/code-server*$(dpkg --print-architecture).deb && rm /tmp/code-server*.deb
|
||||||
|
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
USER coder
|
USER coder
|
||||||
WORKDIR /home/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
18
ci/release-image/entrypoint.sh
Executable 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 "$@"
|
@ -4,11 +4,11 @@ set -euo pipefail
|
|||||||
main() {
|
main() {
|
||||||
cd "$(dirname "$0")/../.."
|
cd "$(dirname "$0")/../.."
|
||||||
|
|
||||||
if [[ $OSTYPE == darwin* ]]; then
|
NODE_VERSION=v12.18.3
|
||||||
NODE_VERSION=v12.18.3
|
NODE_OS="$(uname | tr '[:upper:]' '[:lower:]')"
|
||||||
curl -L "https://nodejs.org/dist/$NODE_VERSION/node-$NODE_VERSION-darwin-x64.tar.gz" | tar -xz
|
NODE_ARCH="$(uname -m | sed 's/86_64/64/; s/aarch64/arm64/')"
|
||||||
PATH="$PWD/node-$NODE_VERSION-darwin-x64/bin:$PATH"
|
curl -L "https://nodejs.org/dist/$NODE_VERSION/node-$NODE_VERSION-$NODE_OS-$NODE_ARCH.tar.gz" | tar -xz
|
||||||
fi
|
PATH="$PWD/node-$NODE_VERSION-$NODE_OS-$NODE_ARCH/bin:$PATH"
|
||||||
|
|
||||||
# https://github.com/actions/upload-artifact/issues/38
|
# https://github.com/actions/upload-artifact/issues/38
|
||||||
tar -xzf release-npm-package/package.tar.gz
|
tar -xzf release-npm-package/package.tar.gz
|
||||||
|
Loading…
Reference in New Issue
Block a user