Add container launcher script
arnaucube root@arnaucube.com
Fri, 28 May 2021 19:42:51 +0200
2 files changed,
82 insertions(+),
0 deletions(-)
A
launch-container/Dockerfile.rust
@@ -0,0 +1,35 @@
+# FROM ubuntu:20.04 +FROM alpine:3.7 + +RUN apt-get update && \ + apt-get -y dist-upgrade && \ + apt-get install -y \ + apt-utils \ + build-essential \ + wget \ + curl \ + git \ + neovim \ + vim && \ + apt-get clean + +RUN curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs \ + https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim +RUN curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ + https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim +RUN curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs \ + https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim + +# install rust +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y + +RUN git clone https://github.com/arnaucube/configs.git && \ + cp configs/.vimrc ~/ && \ + cp configs/vimconfigbase.vim ~/ && \ + mkdir ~/.config && \ + mkdir ~/.config/nvim && \ + cp configs/init.vim ~/.config/nvim/ + +WORKDIR /root + +ENTRYPOINT /bin/sh
A
launch-container/lc
@@ -0,0 +1,47 @@
+#!/bin/bash + +if [[ $1 == "help" ]]; then + echo "lc (Launch Container) help: +=========================== + - lc new <dockerfile> <container_name> <image_name>: create new image & + container using the selected dockerfile + - available dockerfiles: go, rust + - lc stop <container_name>: stop container + - lc rm <container_name>: remove container + - lc ls: list containers + - lc stop <container_name> <image_name>: stop container + - lc <container_name>: launch container + " + exit 0 +elif [[ $1 == "new" ]]; then + # $2: lang, $3: container_name, $4: image_name + + if [[ $2 == "rust" ]]; then + 2="Dockerfile.rust" + elif [[ $2 == "go" ]]; then + 2="Dockerfile.go" + else + echo "available dockerfiles: go, rust" + exit 0 + fi + + sudo docker build -t $4 -f $2 . + sudo docker run -it --entrypoint=/bin/bash --name $3 $4 + exit 0 +elif [[ $1 == "stop" ]]; then + # $2: container_name + sudo docker stop $2 + exit 0 +elif [[ $1 == "rm" ]]; then + # $2: container_name + sudo docker stop $2 + sudo docker rm $2 + exit 0 +elif [[ $1 == "ls" ]]; then + sudo docker ps -a + exit 0 +fi + +# $1: container_name, $2: image_name +sudo docker start $1 +sudo docker container exec -it $1 bash