From 39acfddea31a20adacf92b716e309aa84c52663d Mon Sep 17 00:00:00 2001 From: arnaucube Date: Fri, 28 May 2021 19:42:51 +0200 Subject: [PATCH] Add container launcher script --- launch-container/Dockerfile.rust | 35 ++++++++++++++++++++++++ launch-container/lc | 47 ++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 launch-container/Dockerfile.rust create mode 100755 launch-container/lc diff --git a/launch-container/Dockerfile.rust b/launch-container/Dockerfile.rust new file mode 100644 index 0000000..f19232f --- /dev/null +++ b/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 diff --git a/launch-container/lc b/launch-container/lc new file mode 100755 index 0000000..d42abc6 --- /dev/null +++ b/launch-container/lc @@ -0,0 +1,47 @@ +#!/bin/bash + +if [[ $1 == "help" ]]; then + echo "lc (Launch Container) help: +=========================== + - lc new : create new image & + container using the selected dockerfile + - available dockerfiles: go, rust + - lc stop : stop container + - lc rm : remove container + - lc ls: list containers + - lc stop : stop container + - lc : 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