-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathDockerfile
More file actions
162 lines (142 loc) · 6.24 KB
/
Dockerfile
File metadata and controls
162 lines (142 loc) · 6.24 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
FROM buildpack-deps:focal
### base ###
RUN yes | unminimize \
&& apt-get install -yq \
zip \
unzip \
bash-completion \
build-essential \
htop \
jq \
less \
locales \
man-db \
nano \
software-properties-common \
sudo \
time \
vim \
multitail \
lsof \
&& locale-gen en_US.UTF-8 \
&& mkdir /var/lib/apt/dazzle-marks \
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/*
ENV LANG=en_US.UTF-8
### Git ###
RUN add-apt-repository -y ppa:git-core/ppa \
&& apt-get install -yq git \
&& rm -rf /var/lib/apt/lists/*
### Gitpod user ###
# '-l': see https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#user
RUN useradd -l -u 33333 -G sudo -md /home/gitpod -s /bin/bash -p gitpod gitpod \
# passwordless sudo for users in the 'sudo' group
&& sed -i.bkp -e 's/%sudo\s\+ALL=(ALL\(:ALL\)\?)\s\+ALL/%sudo ALL=NOPASSWD:ALL/g' /etc/sudoers
ENV HOME=/home/gitpod
WORKDIR $HOME
# custom Bash prompt
RUN { echo && echo "PS1='\[\e]0;\u \w\a\]\[\033[01;32m\]\u\[\033[00m\] \[\033[01;34m\]\w\[\033[00m\] \\\$ '" ; } >> .bashrc
### Gitpod user (2) ###
USER gitpod
# use sudo so that user does not get sudo usage info on (the first) login
RUN sudo echo "Running 'sudo' for Gitpod: success" && \
# create .bashrc.d folder and source it in the bashrc
mkdir /home/gitpod/.bashrc.d && \
(echo; echo "for i in \$(ls \$HOME/.bashrc.d/*); do source \$i; done"; echo) >> /home/gitpod/.bashrc
### Ruby ###
LABEL dazzle/layer=lang-ruby
LABEL dazzle/test=tests/lang-ruby.yaml
USER gitpod
RUN curl -sSL https://rvm.io/mpapis.asc | gpg --import - \
&& curl -sSL https://rvm.io/pkuczynski.asc | gpg --import - \
&& curl -fsSL https://get.rvm.io | bash -s stable \
&& bash -lc " \
rvm requirements \
&& rvm install 3.1.2 \
&& rvm use 3.1.2 --default \
&& rvm rubygems current \
&& gem install bundler --no-document" \
&& echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*' >> /home/gitpod/.bashrc.d/70-ruby
RUN echo "rvm_gems_path=/home/gitpod/.rvm" > ~/.rvmrc
USER gitpod
# AppDev stuff
WORKDIR /base-rails
# # Install Google Chrome
# RUN sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" | \
# tee -a /etc/apt/sources.list.d/google.list' && \
# wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | \
# sudo apt-key add - && \
# sudo apt-get update && \
# sudo apt-get install -y google-chrome-stable libxss1
# # Install Chromedriver (compatable with Google Chrome version)
# # See https://gerg.dev/2021/06/making-chromedriver-and-chrome-versions-match-in-a-docker-image/
# RUN BROWSER_MAJOR=$(google-chrome --version | sed 's/Google Chrome \([0-9]*\).*/\1/g') && \
# wget https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${BROWSER_MAJOR} -O chrome_version && \
# wget https://chromedriver.storage.googleapis.com/`cat chrome_version`/chromedriver_linux64.zip && \
# unzip chromedriver_linux64.zip && \
# sudo mv chromedriver /usr/local/bin/ && \
# DRIVER_MAJOR=$(chromedriver --version | sed 's/ChromeDriver \([0-9]*\).*/\1/g') && \
# echo "chrome version: $BROWSER_MAJOR" && \
# echo "chromedriver version: $DRIVER_MAJOR" && \
# if [ $BROWSER_MAJOR != $DRIVER_MAJOR ]; then echo "VERSION MISMATCH"; exit 1; fi
# Install Google Chrome
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
RUN sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
RUN sudo apt-get -y update
RUN sudo apt-get -y install google-chrome-stable
# Install Chromedriver
# RUN sudo apt-get -y install google-chrome-stable
RUN wget https://chromedriver.storage.googleapis.com/2.41/chromedriver_linux64.zip
RUN unzip chromedriver_linux64.zip
RUN sudo mv chromedriver /usr/bin/chromedriver
RUN sudo chown root:root /usr/bin/chromedriver
RUN sudo chmod +x /usr/bin/chromedriver
# Pre-install gems into /base-rails/gems/
COPY Gemfile /base-rails/Gemfile
COPY --chown=gitpod:gitpod Gemfile.lock /base-rails/Gemfile.lock
RUN /bin/bash -l -c "gem install bundler:2.2.16"
RUN /bin/bash -l -c "mkdir gems && bundle config set --local path 'gems'"
RUN /bin/bash -l -c "bundle install"
# Install fuser (bin/server) and expect (web_git)
RUN sudo apt install -y libpq-dev psmisc lsof expect
# Install heroku-cli
RUN /bin/bash -l -c "curl https://cli-assets.heroku.com/install.sh | sh"
# Install Node and npm
RUN curl -fsSL https://deb.nodesource.com/setup_15.x | sudo -E bash - \
&& sudo apt-get install -y nodejs
# Install Yarn
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - \
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list \
&& sudo apt-get update \
&& sudo apt-get install -y yarn \
&& sudo npm install -g n \
&& sudo n 18.13.0 \
&& hash -r
# Git global configuration
RUN git config --global push.default upstream \
&& git config --global merge.ff only \
&& git config --global alias.aa '!git add -A' \
&& git config --global alias.cm '!f(){ git commit -m "${*}"; };f' \
&& git config --global alias.acm '!f(){ git add -A && git commit -am "${*}"; };f' \
&& git config --global alias.as '!git add -A && git stash' \
&& git config --global alias.p 'push' \
&& git config --global alias.sla 'log --oneline --decorate --graph --all' \
&& git config --global alias.co 'checkout' \
&& git config --global alias.cob 'checkout -b' \
&& git config --global --add --bool push.autoSetupRemote true
# Alias 'git' to 'g'
RUN echo 'export PATH="$PATH:$GITPOD_REPO_ROOT/bin"' >> ~/.bashrc
RUN echo "# No arguments: 'git status'\n\
# With arguments: acts like 'git'\n\
g() {\n\
if [[ \$# > 0 ]]; then\n\
git \$@\n\
else\n\
git status\n\
fi\n\
}\n# Complete g like git\n\
source /usr/share/bash-completion/completions/git\n\
__git_complete g __git_main" >> ~/.bash_aliases
# Alias bundle exec to be
RUN echo "alias be='bundle exec'" >> ~/.bash_aliases
RUN echo 'gem: --no-document' >> ~/.gemrc
RUN /bin/bash -l -c "gem install htmlbeautifier rufo -N"