Skip to content

Commit a9cc273

Browse files
author
Steve Jeong
committed
workspace v3.0.0 beta
Signed-off-by: Steve Jeong <[email protected]>
1 parent 4d6d223 commit a9cc273

File tree

15 files changed

+191
-96
lines changed

15 files changed

+191
-96
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ $ ./set --help
2727

2828
pull & run image
2929
```
30-
$ docker pull how2flow/workspace:base
31-
$ docker run -it how2flow/workspace:base
30+
$ docker pull how2flow/workspace:latest
31+
$ docker run -it how2flow/workspace:latest
3232
```

docker/base/.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Dockerfile.tags
33

44
# fixups
5-
fixups/pkg
5+
fixups/*.txt
66

77
# etc
88
*.swp

docker/base/Dockerfile

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,6 @@ USER root
1919
WORKDIR /root
2020
COPY fixups fixups
2121
RUN chmod -R +x fixups
22-
RUN ./fixups/preinst
23-
RUN ./fixups/ssh
24-
RUN ./fixups/id
25-
RUN ./fixups/sudo
2622

27-
USER ${ID}
28-
WORKDIR /home/${ID}
29-
RUN mkdir -p .vim/colors .vim/bundle
30-
RUN wget -O .gitconfig $WGET_FLAG "https://raw.githubusercontent.com/how2flow/config/master/ubuntu/gitconfig"
31-
RUN wget -O .tmux.conf $WGET_FLAG "https://raw.githubusercontent.com/how2flow/config/master/ubuntu/tmux.conf"
32-
RUN wget -O .vimrc $WGET_FLAG "https://raw.githubusercontent.com/how2flow/config/master/ubuntu/vimrc"
33-
RUN wget -O .vim/colors/gruvbox.vim $WGET_FLAG "https://raw.githubusercontent.com/morhetz/gruvbox/master/colors/gruvbox.vim"
34-
RUN git clone "https://github.com/VundleVim/Vundle.vim.git" .vim/bundle/Vundle.vim
35-
RUN vim +PluginInstall +qall
36-
RUN echo "alias tmux='tmux -2'" >> .bashrc
37-
RUN echo "set -o vi" >> .bashrc
23+
WORKDIR /root/fixups
24+
RUN ./prefix

docker/base/Dockerfile.tags

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,30 @@
11
# Dockerfile
2+
3+
# ===== No Edit =====
24
FROM how2flow/workspace:base
5+
# ===================
36

47
ENV ID="tags"
58

9+
# ===== No Edit =====
610
USER root
711
WORKDIR /root
812
COPY fixups fixups
913
RUN chmod -R +x fixups
10-
RUN ./fixups/pkg
11-
RUN ./fixups/chid $ID
12-
# RUN ./fixups/..
14+
# ===================
15+
16+
# ===== No Edit =====
17+
WORKDIR /root/fixups
18+
RUN ./postfix $ID
19+
# ===================
20+
# TODO ...
21+
#
22+
# ===== No Edit =====
1323
RUN rm -rf fixups
24+
# ===================
1425

26+
# ===== No Edit =====
1527
USER ${ID}
1628
WORKDIR /home/${ID}
17-
# user fixups ...
29+
# ===================
30+
# TODO ...

docker/base/fixups/chid

Lines changed: 0 additions & 14 deletions
This file was deleted.

docker/base/fixups/global

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
CONFDIR="/root/conf"

docker/base/fixups/id

Lines changed: 0 additions & 24 deletions
This file was deleted.
File renamed without changes.

docker/base/fixups/postfix

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/bin/bash
2+
3+
# configs after preinst.
4+
# written by how2flow(Steve Jeong).
5+
6+
ID="${1:-user}"
7+
GROUP="${2:-user}"
8+
PASSWORD="${3:-docker}"
9+
10+
ROOT="$(cd $(dirname $0); pwd -P )"
11+
. "${ROOT}"/global
12+
13+
get_app_configs() {
14+
local home="/home/"${ID}""
15+
16+
# move configs
17+
if [[ -d "${CONFDIR}" && -d "${home}" ]]; then
18+
mv "${CONFDIR}"/* "${home}"
19+
fi
20+
21+
rm -rf "${CONFDIR}"
22+
23+
echo "Finish Download app configs"
24+
}
25+
26+
id_config() {
27+
# set root password
28+
echo "root:${PASSWORD}" | chpasswd
29+
30+
# set user groups
31+
groupadd --gid 1000 "${GROUP}"
32+
33+
# set user ID
34+
useradd --system --create-home --home-dir /home/"${ID}" \
35+
--shell /bin/bash --gid "${GROUP}" --uid 1001 "${ID}"
36+
37+
# set user password
38+
echo "$ID:${PASSWORD}" | chpasswd
39+
40+
echo "Finish ID config"
41+
}
42+
43+
rc_config() {
44+
local bashrc="/home/"${ID}"/.bashrc"
45+
46+
# bashrc user confs
47+
if [ -f "${bashrc}" ]; then
48+
echo "alias tmux='tmux -2'" >> "${bashrc}" /dev/null 2>&1
49+
echo "set -o vi" >> "${bashrc}" /dev/null 2>&1
50+
fi
51+
52+
echo "Finish rc config"
53+
}
54+
55+
sudo_config() {
56+
local sudoers_conf="/etc/sudoers"
57+
58+
# remove sudo warning message
59+
if [ -x "$(command -v sudo)" ]; then
60+
usermod -aG sudo "${ID}"
61+
touch /home/"${ID}"/.sudo_as_admin_successful
62+
fi
63+
64+
# sudoers config
65+
echo "%$id ALL=(ALL) ALL" >> "${sudoers_conf}"
66+
67+
echo "Finish sudo config"
68+
}
69+
70+
main() {
71+
id_config
72+
rc_config
73+
sudo_config
74+
get_app_configs
75+
}
76+
77+
main

docker/base/fixups/prefix

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/bash
2+
3+
# configs after preinst.
4+
# written by how2flow(Steve Jeong).
5+
6+
ROOT="$(cd $(dirname $0); pwd -P )"
7+
8+
. "${ROOT}"/global
9+
10+
downlaod_app_configs() {
11+
# download configs
12+
if [ -x "$(command -v wget)" ]; then
13+
mkdir -p "${CONFDIR}"
14+
wget -O "${CONFDIR}"/.gitconfig $WGET_FLAG "https://raw.githubusercontent.com/how2flow/config/master/ubuntu/gitconfig"
15+
wget -O "${CONFDIR}"/.tmux.conf $WGET_FLAG "https://raw.githubusercontent.com/how2flow/config/master/ubuntu/tmux.conf"
16+
git clone "https://github.com/VundleVim/Vundle.vim.git" "${prefix}"/.vim/bundle/Vundle.vim
17+
18+
# download configs for vim
19+
mkdir -p "${CONFDIR}"/.vim/colors "${CONFDIR}"/.vim/bundle
20+
wget -O "${CONFDIR}"/.vimrc $WGET_FLAG "https://raw.githubusercontent.com/how2flow/config/master/ubuntu/vimrc"
21+
wget -O "${CONFDIR}"/.vim/colors/gruvbox.vim $WGET_FLAG "https://raw.githubusercontent.com/morhetz/gruvbox/master/colors/gruvbox.vim"
22+
fi
23+
}
24+
25+
install_packages() {
26+
# prefix pacakges: git sudo ssh tmux vim wget
27+
apt-get update && apt-get install -y --no-install-recommends git sudo ssh tmux vim wget
28+
29+
if [ -x "$(command -v brltty)" ]; then
30+
apt-get remove brltty
31+
fi
32+
33+
echo "Finish install base pacakges"
34+
}
35+
36+
ssh_config() {
37+
local ssh_config="/etc/ssh/ssh_config"
38+
39+
if [ -x "$(command -v ssh)" ]; then
40+
echo " HostKeyAlgorithms +ssh-rsa" >> "${ssh_config}"
41+
echo " PubkeyAcceptedKeyTypes +ssh-rsa" >> "${ssh_config}"
42+
fi
43+
44+
echo "Finish ssh config"
45+
}
46+
47+
main() {
48+
install_packages
49+
ssh_config
50+
downlaod_app_configs
51+
}
52+
53+
main

0 commit comments

Comments
 (0)