Compare commits

..

No commits in common. "master" and "last-xenial-version" have entirely different histories.

9 changed files with 107 additions and 168 deletions

View File

@ -1,19 +1,10 @@
FROM phusion/baseimage:0.11
CMD ["/sbin/my_init"]
FROM ubuntu:16.04
ADD ./sources.list /etc/apt/sources.list
# setup
RUN echo "#!/bin/sh\nexit 101" > /usr/sbin/policy-rc.d
ADD ./run.sh /tmp/run.sh
RUN bash /tmp/run.sh && rm /tmp/run.sh
# enable ssh
RUN rm -f /etc/service/sshd/down
#cleanup
RUN apt-get clean && \
rm -rf \
/var/lib/apt/lists/* \
/tmp/* \
/var/tmp/* \
/etc/ssh/ssh_host_*_key
ADD ./my_init /usr/sbin/my_init
RUN chmod +x /usr/sbin/my_init
CMD /usr/sbin/my_init

View File

@ -1,7 +1,11 @@
YYYYMMDD := $(shell date +%Y%m%d)
BRANCH := $(shell git branch | sed -n -e 's/^\* \(.*\)/\1/p')
default: build
build:
script -q ./build.log docker build --no-cache -t sneak/sandbox:$(YYYYMMDD) .
script -q ./build.log docker build --no-cache -t sneak/sandbox .
docker tag sneak/sandbox sneak/sandbox:$(YYYYMMDD)
push:
docker push sneak/sandbox
docker push sneak/sandbox:$(YYYYMMDD)

3
bin/sandbox Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
docker run -d --name sandbox sneak/sandbox
docker exec -ti sandbox script -q -c "TERM=xterm-color byobu" /dev/null

3
bin/sandbox-fast Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
docker run -d --add-host archive.ubuntu.com:172.17.0.1 --name sandbox sneak/sandbox
docker exec -ti sandbox script -q -c "TERM=xterm-color byobu" /dev/null

3
bin/sandbox-kill Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
docker kill sandbox
docker rm sandbox

View File

@ -1,10 +0,0 @@
#!/bin/bash
IMAGE="sneak/sandbox:next"
docker run
-v /home/sneak:/home/sneak \
-v /storage/admin:/root \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /root/.ssh/authorized_keys:/root/.ssh/authorized_keys \
$IMAGE

9
my_init Normal file
View File

@ -0,0 +1,9 @@
#!/bin/bash
export > /etc/environment
/usr/sbin/runsvdir-start &
sleep 1
if [[ ! -e /var/log/syslog ]]; then
touch /var/log/syslog
fi
exec tail -qf /var/log/syslog /etc/service/*/log/*.log

212
run.sh
View File

@ -1,95 +1,56 @@
#!/bin/bash
export DEBIAN_FRONTEND=noninteractive
USERNAME="sneak"
set -x
set -e
exec 1> >(tee -a /var/log/sandboxbuild.log) 2>&1
PKGS="
apt-transport-https
apt-utils
aspell
aspell-en
automake
bash-completion
bc
bind9-host
bonnie++
build-essential
byobu
cmake
command-not-found
curl
daemontools
debmirror
default-jre
diffstat
dnsutils
docker.io
dos2unix
editorconfig
ffmpeg
fonts-indic
fonts-ipafont-gothic
fonts-ipafont-mincho
fortune
git
gnupg-agent
gnupg2
golang-go
host
imagemagick
iputils-ping
irssi
jq
lcov
ldap-auth-client
ldap-utils
libasound2
libatk1.0-0
libboost-all-dev
libdb++-dev
libgconf-2-4
libgtk-3-0
libjpeg-dev
libnss-mdns
libnss3
libpng-dev
libssl-dev
libtool
libxcursor1
libxml2
libxml2-dev
libxslt1-dev
locales
lsof
mailutils
make
man
man-db
mercurial
mosh
mutt
netcat-openbsd
nmap
nodejs
npm
nscd
openssh-server
pass
pbzip2
pinentry-curses
pkg-config
pkg-config
psmisc
pv
pwgen
python
python3
python-dev
python3-dev
python-pip
python3-pip
python-software-properties
rbenv
rsync
rsyslog
@ -100,96 +61,62 @@ PKGS="
snmp
snmpd
software-properties-common
strace
sudo
tcpdump
telnet
texlive-latex-base
tmux
tree
ttf-wqy-microhei
ttf-wqy-zenhei
vagrant
vim
vim-gtk
wamerican-insane
wget
xterm
zip
"
apt update
apt -y upgrade
apt install -y $PKGS
apt-get update
apt-get -y upgrade
for PKG in $PKGS ; do
apt-get install -y $PKG
done
# install docker
apt-get install -y docker
#apt-get install apt-transport-https ca-certificates
#apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 \
# --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
#echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" > \
# /etc/apt/sources.list.d/docker.list
#apt-get update
#apt-get install docker-engine
# install docker machine (this is gross):
curl -L \
https://github.com/docker/machine/releases/download/v0.6.0/docker-machine-`uname -s`-`uname -m` > \
/usr/local/bin/docker-machine && \
chmod +x /usr/local/bin/docker-machine
# install docker compose (also gross):
curl -L \
https://github.com/docker/compose/releases/download/1.6.2/docker-compose-`uname -s`-`uname -m` > \
/usr/local/bin/docker-compose && \
chmod +x /usr/local/bin/docker-compose
# and completion
curl -L \
https://raw.githubusercontent.com/docker/compose/$(docker-compose version --short)/contrib/completion/bash/docker-compose > \
/etc/bash_completion.d/docker-compose
# install neovim
add-apt-repository ppa:neovim-ppa/unstable
apt update
apt install -y neovim
apt-get update
apt-get install neovim
mkdir -p /etc/bashrc.d
mkdir -p /etc/profile.d
# install ruby-build for rbenv install
git clone https://github.com/rbenv/ruby-build.git /root/.rbenv/plugins/ruby-build
cat >> /etc/bash.bashrc <<'EOF'
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
for FN in /etc/bashrc.d/*.sh; do
source "$FN"
done
if ! shopt -oq posix; then
for FN in /etc/profile.d/*.sh; do
source "$FN"
done
fi
EOF
################################################################################
## install nvm + node
################################################################################
export NVM_DIR='/usr/local/nvm'
mkdir -p "$NVM_DIR"
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
cat > /etc/bashrc.d/100.nvm.sh <<'EOF'
source /usr/local/nvm/nvm.sh
EOF
source /etc/bashrc.d/100.nvm.sh
nvm install node
nvm use node
################################################################################
## install yarn
################################################################################
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg |
apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" |
tee /etc/apt/sources.list.d/yarn.list
apt update && apt install -y yarn
################################################################################
## install rbenv + ruby
################################################################################
git clone https://github.com/rbenv/rbenv.git /usr/local/rbenv
cat > /etc/bashrc.d/100.rbenv.sh <<'EOF'
export PATH="/usr/local/rbenv/bin:$PATH"
eval "$(rbenv init -)"
EOF
source /etc/bashrc.d/100.rbenv.sh
mkdir -p "$(rbenv root)"/plugins
git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
rbenv install $(rbenv install -l | grep -v - | tail -1)
#rbenv install 2.6.3
#rbenv install jruby-9.0.5.0
# install some rbenv versions
rbenv install 2.3.0
rbenv install jruby-9.0.5.0
# install some gems
GEMS="
@ -200,38 +127,47 @@ for GEM in $GEMS ; do
gem install -V $GEM
done
################################################################################
## install ppss, paralell processing shell script
################################################################################
# install ppss, paralell processing shell script
cd /usr/local/bin
wget https://raw.githubusercontent.com/sneak/ppss/master/ppss
chmod +x ./ppss
################################################################################
## upgrade pip and install bare essentials
## update other python packages as possible
################################################################################
#pip3 install --upgrade pip
pip3 install setuptools
#pip3 install pip-review
#pip-review --verbose --auto
# update npm
npm update -g --loglevel info npm
# install some npm packages
NPM_PKGS="
coffee-script
coffeelint
"
for PKG in $NPM_PKGS ; do
npm install -g --loglevel info $PKG
done
# upgrade pip and install bare essentials
# update other packages as possible
pip install --upgrade pip
pip install setuptools
pip install pip-review
pip-review --verbose --auto
# install other python packages
PIP_PKGS="
awscli
pipenv
pylint
virtualenv
pylint
awscli
"
for PKG in $PIP_PKGS; do
pip3 install $PKG
pip install $PKG
done
################################################################################
## add working user and add to sudo nopassword
################################################################################
groupadd -g 1000 $USERNAME
useradd -u 1000 -g 1000 -s /bin/bash $USERNAME
usermod -p '*' $USERNAME
echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
# cleanup filesystem after build
rm -rf \
/root/.cache \
/var/cache/* \
/var/lib/apt/lists/* \
/core

View File

@ -1,4 +1,4 @@
deb mirror://mirrors.ubuntu.com/mirrors.txt bionic main universe multiverse restricted
deb mirror://mirrors.ubuntu.com/mirrors.txt bionic-updates main universe multiverse restricted
deb mirror://mirrors.ubuntu.com/mirrors.txt bionic-security main universe multiverse restricted
deb mirror://mirrors.ubuntu.com/mirrors.txt bionic-backports main universe multiverse restricted
deb mirror://mirrors.ubuntu.com/mirrors.txt xenial main universe
deb mirror://mirrors.ubuntu.com/mirrors.txt xenial-updates main universe
deb mirror://mirrors.ubuntu.com/mirrors.txt xenial-security main universe
deb mirror://mirrors.ubuntu.com/mirrors.txt xenial-backports main universe