mirror of
https://github.com/aleleba/aleleba-vscode-dockerfile-configuration.git
synced 2025-06-18 20:08:13 -06:00
Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
b5cbdca7ef | |||
68bdbd4c61 | |||
a164ccadff | |||
d755728ed8 | |||
c17566fd5f |
14
Dockerfile
14
Dockerfile
@ -12,6 +12,20 @@ RUN sudo apt-get install -y wget
|
|||||||
#Instalando jq
|
#Instalando jq
|
||||||
RUN sudo apt-get install -y jq
|
RUN sudo apt-get install -y jq
|
||||||
|
|
||||||
|
RUN adduser --gecos '' --disabled-password vscode \
|
||||||
|
&& echo "vscode ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/nopasswd
|
||||||
|
|
||||||
|
RUN ARCH="$(dpkg --print-architecture)" \
|
||||||
|
&& curl -fsSL "https://github.com/boxboat/fixuid/releases/download/v0.6.0/fixuid-0.6.0-linux-$ARCH.tar.gz" | tar -C /usr/local/bin -xzf - \
|
||||||
|
&& chown root:root /usr/local/bin/fixuid \
|
||||||
|
&& chmod 4755 /usr/local/bin/fixuid \
|
||||||
|
&& mkdir -p /etc/fixuid \
|
||||||
|
&& printf "user: vscode\ngroup: vscode\n" > /etc/fixuid/config.yml
|
||||||
|
|
||||||
|
USER 1000
|
||||||
|
ENV USER=vscode
|
||||||
|
WORKDIR /home/vscode
|
||||||
|
|
||||||
#Instalando devtunnel
|
#Instalando devtunnel
|
||||||
#Comandos que no se deben olvidar correr al crear el devtunnel
|
#Comandos que no se deben olvidar correr al crear el devtunnel
|
||||||
#devtunnel user login -g -d
|
#devtunnel user login -g -d
|
||||||
|
@ -1,53 +1,31 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#if [[ -z "${HOME_USER}" ]]; then
|
set -eu
|
||||||
#HOME_USER="vscode"
|
|
||||||
#fi
|
|
||||||
|
|
||||||
set -e
|
if [[ -z "${HOME_USER}" ]]; then
|
||||||
|
HOME_USER="vscode"
|
||||||
# use specified user name or use `vscode` if not specified
|
|
||||||
HOME_USER="${HOME_USER:-vscode}"
|
|
||||||
|
|
||||||
# use specified group name or use the same user name also as the group name
|
|
||||||
MY_GROUP="${MY_GROUP:-${HOME_USER}}"
|
|
||||||
|
|
||||||
# use the specified UID for the user
|
|
||||||
MY_UID="${MY_UID:-1000}"
|
|
||||||
|
|
||||||
# use the specified GID for the user
|
|
||||||
MY_GID="${MY_GID:-${MY_UID}}"
|
|
||||||
|
|
||||||
|
|
||||||
# check to see if group exists; if not, create it
|
|
||||||
if grep -q -E "^${MY_GROUP}:" /etc/group > /dev/null 2>&1
|
|
||||||
then
|
|
||||||
echo "INFO: Group exists; skipping creation"
|
|
||||||
else
|
|
||||||
echo "INFO: Group doesn't exist; creating..."
|
|
||||||
# create the group
|
|
||||||
addgroup -g "${MY_GID}" "${MY_GROUP}" || (echo "INFO: Group exists but with a different name; renaming..."; groupmod -g "${MY_GID}" -n "${MY_GROUP}" "$(awk -F ':' '{print $1":"$3}' < /etc/group | grep ":${MY_GID}$" | awk -F ":" '{print $1}')")
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#addgroup nonroot
|
||||||
# check to see if user exists; if not, create it
|
|
||||||
if id -u "${HOME_USER}" > /dev/null 2>&1
|
|
||||||
then
|
|
||||||
echo "INFO: User exists; skipping creation"
|
|
||||||
else
|
|
||||||
echo "INFO: User doesn't exist; creating..."
|
|
||||||
# create the user
|
|
||||||
adduser -u "${MY_UID}" -G "${MY_GROUP}" -h "/home/${HOME_USER}" -s /bin/sh -D "${HOME_USER}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# make the directories needed to run my app
|
|
||||||
mkdir -p /opt/myapp
|
|
||||||
|
|
||||||
# change ownership of any directories needed to run my app as the proper UID/GID
|
|
||||||
chown -R "${HOME_USER}:${MY_GROUP}" "/opt/myapp"
|
|
||||||
|
|
||||||
# addgroup nonroot
|
|
||||||
#adduser --disabled-password --gecos "" ${HOME_USER}
|
#adduser --disabled-password --gecos "" ${HOME_USER}
|
||||||
# echo "${HOME_USER} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
|
#echo "${HOME_USER} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
|
||||||
|
|
||||||
|
# We do this first to ensure sudo works below when renaming the user.
|
||||||
|
# Otherwise the current container UID may not exist in the passwd database.
|
||||||
|
eval "$(fixuid -q)"
|
||||||
|
|
||||||
|
if [ "${HOME_USER-}" ]; then
|
||||||
|
USER="$HOME_USER"
|
||||||
|
if [ "$HOME_USER" != "$(whoami)" ]; then
|
||||||
|
echo "$HOME_USER ALL=(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers.d/nopasswd > /dev/null
|
||||||
|
# Unfortunately we cannot change $HOME as we cannot move any bind mounts
|
||||||
|
# nor can we bind mount $HOME into a new home as that requires a privileged container.
|
||||||
|
sudo usermod --login "$HOME_USER" vscode
|
||||||
|
sudo groupmod -n "$HOME_USER" vscode
|
||||||
|
|
||||||
|
sudo sed -i "/vscode/d" /etc/sudoers.d/nopasswd
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
#Creating extensions folder
|
#Creating extensions folder
|
||||||
sudo mkdir /home/${HOME_USER}/.config/Code
|
sudo mkdir /home/${HOME_USER}/.config/Code
|
||||||
|
@ -1 +1 @@
|
|||||||
1.1.2
|
2.0.0
|
Reference in New Issue
Block a user