Browse Source

Add container launcher script

master
arnaucube 3 years ago
parent
commit
39acfddea3
2 changed files with 82 additions and 0 deletions
  1. +35
    -0
      launch-container/Dockerfile.rust
  2. +47
    -0
      launch-container/lc

+ 35
- 0
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

+ 47
- 0
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

Loading…
Cancel
Save