9 Commits

Author SHA1 Message Date
2435201c80 use default dind network with public dns
Some checks failed
continuous-integration/drone/push Build is failing
2020-02-16 06:21:32 -08:00
f6efe03551 use mirror:// protocol for apt
Some checks failed
continuous-integration/drone/push Build was killed
2020-02-16 05:53:07 -08:00
41114ce60a testing a focal update, drone, et c
Some checks failed
continuous-integration/drone/push Build was killed
2020-02-16 05:50:24 -08:00
a1485030e8 latest, seems to sort of work 2019-08-04 19:02:42 -07:00
b8d90f2f8f set up working user 2019-08-04 03:12:26 -07:00
c7f2b8e9d2 add docker client 2019-08-04 02:19:48 -07:00
5713b283ed seems to work now 2019-08-04 01:12:18 -07:00
f9970f8b2f progress, not working yet 2019-08-03 16:22:25 -07:00
eec711a6b1 initial testing 2019-08-03 14:10:05 -07:00
11 changed files with 213 additions and 162 deletions

19
.drone.yml Normal file
View File

@@ -0,0 +1,19 @@
kind: pipeline
name: default
steps:
- name: docker
image: plugins/docker
settings:
build_args:
- UBUNTU_MIRROR_URL=http://ubuntumirror.app.las1.eeqj.de/ubuntu
repo: sneak/sandbox
username:
from_secret: docker_username
password:
from_secret: docker_password
tags:
- ${DRONE_BRANCH//\//-}-${DRONE_COMMIT_SHA:0:8}
- ${DRONE_COMMIT_SHA}
- ${DRONE_BRANCH/\//-}
- latest

View File

@@ -1,10 +1,21 @@
FROM ubuntu:16.04 FROM ubuntu:focal
ADD ./sources.list /etc/apt/sources.list ARG USERNAME_TO_ADD=user
ARG UID_TO_ADD=1000
ARG GID_TO_ADD=1000
RUN echo "#!/bin/sh\nexit 101" > /usr/sbin/policy-rc.d ARG UBUNTU_MIRROR_URL=mirror://mirrors.ubuntu.com/mirrors.txt
# setup
ADD ./run.sh /tmp/run.sh ADD ./run.sh /tmp/run.sh
RUN bash /tmp/run.sh && rm /tmp/run.sh RUN bash /tmp/run.sh && rm /tmp/run.sh
ADD ./my_init /usr/sbin/my_init
RUN chmod +x /usr/sbin/my_init #cleanup
CMD /usr/sbin/my_init RUN apt-get clean && \
rm -rf \
/var/lib/apt/lists/* \
/tmp/* \
/var/tmp/* \
/etc/ssh/ssh_host_*_key
EXPOSE 22

View File

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

View File

@@ -1,55 +1,11 @@
# Usage # sneak/sandbox
FIXME update this example command
``` ```
docker run -d --name sandbox sneak/sandbox ; docker run -d -p 22:22 -v /home:/home sneak/sandbox
docker exec -ti sandbox script -q -c "TERM=xterm-color byobu" /dev/null
``` ```
(The 'script' bit works around a bug where `docker exec -t` doesn't
give you a usable tty.)
Or, if you're clever and run an Ubuntu mirror (or caching reverse proxy) on
your docker host:
```
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
```
# Includes Things Like
* vim
* neovim
* rbenv
* default-jre
* docker (from docker)
* docker-compose
* docker-machine
* bash completion
* python (from ubuntu)
* setuptools
* virtualenv
* node4 (from ubuntu)
* coffeescript
* coffeelint
* go1.6 (from ubuntu)
* byobu and screen
* awscli (from pypi)
* irssi
* runit / daemontools
* envdir
* build-essential
* make
* latex and fonts (from ubuntu)
* Other useful misc tools
* pv
* pbzip2
* nmap
* ppss
* pwgen
* netcat and telnet
* and much more...
# TODO # TODO
* ctags / enhanced vim * ctags / enhanced vim
@@ -72,12 +28,12 @@ docker exec -ti sandbox script -q -c "TERM=xterm-color byobu" /dev/null
Feedback is appreciated, PRs are encouraged. Feedback is appreciated, PRs are encouraged.
Drop me an email or tweet [@sneakdotberlin](https://twitter.com/sneakdotberlin).
# Author # Author
Jeffrey Paul <sneak@sneak.berlin> Jeffrey Paul <sneak@sneak.berlin>
[sneak@sneak.berlin](mailto:sneak@sneak.berlin)
https://sneak.berlin https://sneak.berlin
[@sneakdotberlin](https://twitter.com/sneakdotberlin) [@sneakdotberlin](https://twitter.com/sneakdotberlin)

View File

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

View File

@@ -1,3 +0,0 @@
#!/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

View File

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

10
bin/start-container Normal file
View File

@@ -0,0 +1,10 @@
#!/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

View File

@@ -1,9 +0,0 @@
#!/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

237
run.sh
View File

@@ -2,55 +2,98 @@
export DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND=noninteractive
set -x set -x
set -e
exec 1> >(tee -a /var/log/sandboxbuild.log) 2>&1 exec 1> >(tee -a /var/log/sandboxbuild.log) 2>&1
MURM="main universe restricted multiverse"
C="focal"
cat > /etc/apt/sources.list.new <<EOF
deb $UBUNTU_MIRROR_URL $C $MURM
deb $UBUNTU_MIRROR_URL $C-updates $MURM
deb $UBUNTU_MIRROR_URL $C-backports $MURM
deb $UBUNTU_MIRROR_URL $C-security $MURM
EOF
PKGS=" PKGS="
apt-transport-https
apt-utils apt-utils
aspell
aspell-en
automake
bash-completion bash-completion
bc
bind9-host bind9-host
bonnie++ bonnie++
build-essential build-essential
byobu byobu
cmake
command-not-found command-not-found
curl
daemontools daemontools
debmirror debmirror
default-jre default-jre
diffstat
dnsutils
docker.io
dos2unix
editorconfig
ffmpeg
fonts-indic fonts-indic
fonts-ipafont-gothic fonts-ipafont-gothic
fonts-ipafont-mincho fonts-ipafont-mincho
fortune fortune
git git
gnupg-agent
gnupg2
golang-go golang-go
host
imagemagick
iputils-ping
irssi irssi
jq jq
lcov
ldap-auth-client ldap-auth-client
ldap-utils ldap-utils
lftp
libasound2
libatk1.0-0
libboost-all-dev libboost-all-dev
libdb++-dev libdb++-dev
libgconf-2-4
libgtk-3-0
libjpeg-dev
libnss-mdns libnss-mdns
libnss3
libpng-dev
libssl-dev
libtool
libxcursor1
libxml2 libxml2
libxml2-dev libxml2-dev
libxslt1-dev libxslt1-dev
locales
lsof lsof
mailutils mailutils
make make
man
man-db man-db
mercurial
mosh mosh
mutt mutt
netcat-openbsd netcat-openbsd
nmap nmap
nodejs
npm
nscd nscd
openssh-server openssh-server
pass
pbzip2 pbzip2
pinentry-curses
pkg-config pkg-config
psmisc
pv pv
pwgen pwgen
python python3
python-dev python3-dev
python-pip python3-pip
python-software-properties
rbenv rbenv
rsync rsync
rsyslog rsyslog
@@ -61,62 +104,108 @@ PKGS="
snmp snmp
snmpd snmpd
software-properties-common software-properties-common
strace
sudo
tcpdump
telnet telnet
texlive-latex-base texlive-latex-base
tmux tmux
tree
ttf-wqy-microhei ttf-wqy-microhei
ttf-wqy-zenhei ttf-wqy-zenhei
vagrant vagrant
vim vim
vim-gtk
wamerican-insane wamerican-insane
wget wget
xterm
zip
" "
apt-get update apt update
apt-get -y upgrade apt -y upgrade
apt install -y $PKGS
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 # install neovim
add-apt-repository ppa:neovim-ppa/unstable add-apt-repository ppa:neovim-ppa/unstable
apt-get update apt update
apt-get install neovim apt install -y neovim
# install ruby-build for rbenv install mkdir -p /etc/bashrc.d
git clone https://github.com/rbenv/ruby-build.git /root/.rbenv/plugins/ruby-build mkdir -p /etc/profile.d
# install some rbenv versions cat >> /etc/bash.bashrc <<'EOF'
rbenv install 2.3.0 if ! shopt -oq posix; then
rbenv install jruby-9.0.5.0 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 [[ -d "$HOME/.bashrc.d" ]]; then
for FN in /etc/bashrc.d/*.sh; do
source "$FN"
done
fi
if ! shopt -oq posix; then
for FN in /etc/profile.d/*.sh; do
source "$FN"
done
if [[ -d "$HOME/.profile.d" ]]; then
for FN in /etc/profile.d/*.sh; do
source "$FN"
done
fi
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 gems # install some gems
GEMS=" GEMS="
@@ -127,47 +216,39 @@ for GEM in $GEMS ; do
gem install -V $GEM gem install -V $GEM
done done
# install ppss, paralell processing shell script ################################################################################
## install ppss, paralell processing shell script
################################################################################
cd /usr/local/bin cd /usr/local/bin
wget https://raw.githubusercontent.com/sneak/ppss/master/ppss wget https://git.eeqj.de/sneak/ppss/raw/branch/master/ppss
chmod +x ./ppss chmod +x ./ppss
# update npm ################################################################################
npm update -g --loglevel info npm ## upgrade pip and install bare essentials
## update other python packages as possible
# install some npm packages ################################################################################
NPM_PKGS=" #pip3 install --upgrade pip
coffee-script pip3 install setuptools
coffeelint #pip3 install pip-review
" #pip-review --verbose --auto
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 # install other python packages
PIP_PKGS=" PIP_PKGS="
virtualenv
pylint
awscli awscli
pipenv
pylint
virtualenv
glances
" "
for PKG in $PIP_PKGS; do for PKG in $PIP_PKGS; do
pip install $PKG pip3 install $PKG
done done
# cleanup filesystem after build ################################################################################
## add working user and add to sudo nopassword
rm -rf \ ################################################################################
/root/.cache \ groupadd -g $GID_TO_ADD $USERNAME_TO_ADD
/var/cache/* \ useradd -u $UID_TO_ADD -g $GID_TO_ADD -s /bin/bash $USERNAME_TO_ADD
/var/lib/apt/lists/* \ usermod -p '*' $USERNAME_TO_ADD
/core echo "$USERNAME_TO_ADD ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

View File

@@ -1,4 +0,0 @@
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