-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdockerfile.erb
More file actions
executable file
·128 lines (113 loc) · 4.48 KB
/
dockerfile.erb
File metadata and controls
executable file
·128 lines (113 loc) · 4.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# vi:set filetype=dockerfile :
# NEVER PUBLISH THE DOCKER IMAGE
# ssh private keys are saved
FROM ubuntu:17.10
<%
require "yaml"
config = YAML.load_file("./config.yml")
-%>
ENV SERVE_HTTP_ADDRESS <%= config["http"]["address"] %>
ENV SERVE_HTTP_PORT <%= config["http"]["port"] %>
ENV BASIC_USERNAME <%= config["auth"]["user"] %>
ENV BASIC_PASSWORD <%= config["auth"]["password"] %>
ENV BUILD_URL http://$BASIC_USERNAME:$BASIC_PASSWORD@$SERVE_HTTP_ADDRESS:$SERVE_HTTP_PORT
ENV USER dev
ENV HOME /home/$USER
ENV LANG en_US.utf8
ENV DEBIAN_FRONTEND noninteractive
RUN echo "debconf debconf/frontend select Noninteractive" | debconf-set-selections
RUN apt-get update \
&& apt-get install -y vim sudo software-properties-common python-software-properties apt-utils \
wget curl \
manpages manpages-dev freebsd-manpages man2html manpages-posix manpages-posix-dev \
locales tzdata \
&& localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 \
&& update-locale LC_ALL=en_US.UTF-8 \
&& echo "$USER ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers \
&& useradd -m $USER && echo "$USER:$USER" | chpasswd \
&& adduser $USER sudo \
&& echo "Europe/Berlin" > /etc/timezone \
&& echo "set term=ansi" >> $HOME/.vimrc \
&& ln -sf /usr/share/zoneinfo/Europe/Berlin /etc/localtime \
&& apt-get autoremove -y
# SSH config
RUN apt-get update -y\
&& apt-get install -y openssh-client \
&& mkdir $HOME/.ssh \
<% for key in config["ssh"] -%>
&& curl $BUILD_URL/.ssh/<%= key %> -o $HOME/.ssh/<%= key %> \
&& chmod 400 $HOME/.ssh/<%= key %> \
&& chown $USER $HOME/.ssh/<%= key %> \
<% end -%>
&& apt-get autoremove -y
COPY ssh_config /etc/ssh/ssh_config
# GIT config
RUN apt-get update \
<% for key in config["git"] -%>
&& curl $BUILD_URL/<%= key %> -o $HOME/<%= key %> \
&& chmod a+rwx $HOME/<%= key %> \
<% end -%>
&& apt-get -y install git git-flow \
&& chown $USER: $HOME/.ssh/<%= config['ssh'].first %>\
&& eval $(ssh-agent -s) \
&& ssh-add $HOME/.ssh/<%= config['ssh'].first %>\
&& git clone git@github.com:avarteqgmbh/git_flow_hooks.git $HOME/git_flow_hooks \
&& git config --global gitflow.path.hooks $HOME/git_flow_hooks/hooks \
&& git config --global gitflow.prefix.versiontag v \
&& apt-get autoremove -y
# ZSH config
RUN apt-get update \
&& ln -s /store/zsh/zsh_history $HOME/.zsh_history \
&& apt-get -y install zsh \
&& git clone git://github.com/robbyrussell/oh-my-zsh.git $HOME/.oh-my-zsh \
&& chsh -s /bin/zsh $USER \
&& apt-get autoremove -y
# general tools and dependencies
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6 \
&& echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | tee \
/etc/apt/sources.list.d/mongodb-org-3.4.list \
&& apt-get update -y \
&& apt-get install -y \
mysql-client postgresql-client mongodb-org-shell redis-tools \
jq net-tools netcat telnet dnsutils inetutils-traceroute iputils-ping \
apt-transport-https \
bzip2 g++ gcc make libc6-dev zlib1g-dev libyaml-dev libsqlite3-dev sqlite3 \
autoconf libgmp-dev libgdbm-dev libncurses5-dev automake libtool bison pkg-config \
libreadline6 libreadline6-dev \
libffi-dev libgmp-dev libreadline6-dev libssl-dev libpq-dev \
libmysqlclient-dev \
libxslt-dev libxml2-dev libnss3-dev libxss1 libasound2 libsasl2-dev\
libmagickwand-dev imagemagick \
python-pip python-dev build-essential \
&& apt-get autoremove -y
RUN mkdir -p $HOME/.cache \
&& chmod -R a+rwx $HOME/.cache \
&& pip install --upgrade pip==9.0.3 \
&& pip install --upgrade virtualenv
COPY modules/_helper.sh /tmp
RUN su -c /tmp/_helper.sh - $USER
<%
require "erb"
for m in config["modules"]
origin = "modules/#{m}.sh"
target = ".build/#{m}.sh"
File.open target, "w+" do |file|
file.write ERB.new(File.read(origin), nil, "-").result
end
-%>
COPY <%= target %> /tmp
RUN su -c /tmp/<%= m %>.sh - $USER \
&& rm /tmp/<%= m %>.sh
<% end -%>
RUN rm /tmp/_helper.sh
# Configs that might change often should be added last
COPY zshrc $HOME/.zshrc.tmp
RUN mv $HOME/.zshrc $HOME/.zshrc.orig \
&& cat $HOME/.zshrc.tmp $HOME/.zshrc.orig > $HOME/.zshrc \
&& rm $HOME/.zshrc.tmp $HOME/.zshrc.orig
COPY inputrc $HOME/.inputrc
COPY rvmrc $HOME/.rvmrc
RUN chown $USER: $HOME/.zshrc $HOME/.inputrc
WORKDIR /work
USER $USER
CMD /bin/zsh