-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
210 lines (185 loc) · 7.63 KB
/
Dockerfile
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
FROM buildpack-deps:jammy@sha256:f94d4ac32b86b5e47c8309b8bde444d2b1ac185c515ee28ff4ebad588b0f21a5
ARG NODE_VERSION
ARG GO_VERSION
ARG RELEASE_TAG
### base ###
RUN apt-get update && apt-get install -y --no-install-recommends \
cmake \
zip \
unzip \
bash-completion \
build-essential \
ninja-build \
htop \
iputils-ping \
jq \
less \
locales \
man-db \
nano \
ripgrep \
software-properties-common \
sudo \
stow \
time \
tree \
emacs-nox \
vim \
multitail \
lsof \
ssl-cert \
fish \
zsh \
libatomic1 \
git \
python3-pip \
poppler-utils \
openssh-client \
openssh-server \
mysql-server \
mysql-client \
postgresql-client \
sqlite3 \
net-tools \
dnsutils \
tzdata \
ca-certificates \
protobuf-compiler \
llvm-dev \
libclang-dev \
clang \
cargo \
kmod \
net-tools \
iproute2 \
libssl-dev \
zlib1g-dev \
libbz2-dev \
libreadline-dev \
libsqlite3-dev \
libncursesw5-dev \
xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev \
pkg-config \
awscli \
rlwrap \
&& locale-gen en_US.UTF-8
# ENV LANG=en_US.UTF-8
ARG RELEASE_ORG="gitpod-io"
ARG OPENVSCODE_SERVER_ROOT="/home/.openvscode-server"
### Update and upgrade the base image ###
RUN apt upgrade -y
### Git ###
RUN add-apt-repository -y ppa:git-core/ppa
# https://github.com/git-lfs/git-lfs/blob/main/INSTALLING.md
RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash
RUN apt-get update && apt-get install -y --no-install-recommends git git-lfs
### Python 3.11 ###
RUN add-apt-repository ppa:deadsnakes/ppa
RUN apt-get update && apt-get install -y python3.11-full
# Downloading the latest VSC Server release and extracting the release archive
# Rename `openvscode-server` cli tool to `code` for convenience
RUN if [ -z "${RELEASE_TAG}" ]; then \
echo "The RELEASE_TAG build arg must be set." >&2 && \
exit 1; \
fi && \
arch=$(uname -m) && \
if [ "${arch}" = "x86_64" ]; then \
arch="x64"; \
elif [ "${arch}" = "aarch64" ]; then \
arch="arm64"; \
elif [ "${arch}" = "armv7l" ]; then \
arch="armhf"; \
fi && \
wget https://github.com/${RELEASE_ORG}/openvscode-server/releases/download/${RELEASE_TAG}/${RELEASE_TAG}-linux-${arch}.tar.gz && \
tar -xzf ${RELEASE_TAG}-linux-${arch}.tar.gz && \
mv -f ${RELEASE_TAG}-linux-${arch} ${OPENVSCODE_SERVER_ROOT} && \
cp ${OPENVSCODE_SERVER_ROOT}/bin/remote-cli/openvscode-server ${OPENVSCODE_SERVER_ROOT}/bin/remote-cli/code && \
rm -f ${RELEASE_TAG}-linux-${arch}.tar.gz
ARG USERNAME=gleez
ARG USER_UID=1000
ARG USER_GID=$USER_UID
### Gleez user ###
# '-l': see https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#user
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd -l -u 1000 -G sudo --gid $USERNAME -md /home/gleez -s /bin/bash -p $USERNAME $USERNAME \
# 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 \
# To emulate the workspace-session behavior within dazzle build env
&& mkdir /workspace && chown -hR gleez:gleez /workspace
RUN chmod g+rw /home && \
mkdir -p /home/workspace && \
chown -R $USERNAME:$USERNAME /home/workspace && \
chown -R $USERNAME:$USERNAME /home/gleez && \
chown -R $USERNAME:$USERNAME ${OPENVSCODE_SERVER_ROOT}
ENV HOME=/home/gleez
WORKDIR $HOME
# custom Bash prompt
RUN { echo && echo "PS1='\[\033[01;32m\]\u\[\033[00m\] \[\033[01;34m\]\w\[\033[00m\]\$(__git_ps1 \" (%s)\") $ '" ; } >> .bashrc
COPY default.gitconfig /etc/gitconfig
COPY --chown=gleez:gleez default.gitconfig /home/gleez/.gitconfig
# Configure SSH to use Bash with colors by default.
RUN mkdir -p /home/gleez/.ssh \
&& chown -R gleez:gleez /home/gleez/.ssh \
&& touch /home/gleez/.ssh/authorized_keys \
&& touch /home/gleez/.ssh/config \
&& echo "SHELL=/bin/bash\nTERM=xterm-256color" >> /home/gleez/.ssh/environment \
&& chmod 700 /home/gleez/.ssh \
&& chmod 600 /home/gleez/.ssh/* \
&& chown -R gleez:gleez /workspace \
&& mkdir -p /var/run/watchman/gleez-state \
&& chown -R gleez:gleez /var/run/watchman/gleez-state
# configure git-lfs
RUN git lfs install --system --skip-repo
### Gleez user (2) ###
USER gleez
# use sudo so that user does not get sudo usage info on (the first) login
RUN sudo echo "Running 'sudo' for Gleez: success" \
# create .bashrc.d folder and source it in the bashrc
&& mkdir -p /home/gleez/.bashrc.d \
&& (echo; echo "for i in \$(ls -A \$HOME/.bashrc.d/); do source \$HOME/.bashrc.d/\$i; done"; echo) >> /home/gleez/.bashrc \
# create a completions dir for gleez user
&& mkdir -p /home/gleez/.local/share/bash-completion/completions \
&& git config --global user.email "[email protected]" \
&& git config --global user.name "Gleez Technologies"
ENV NODE_VERSION=${NODE_VERSION}
ENV PNPM_HOME=/home/gleez/.pnpm
ENV PATH=/home/gleez/.nvm/versions/node/v${NODE_VERSION}/bin:/home/gleez/.yarn/bin:${PNPM_HOME}:$PATH
RUN curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | PROFILE=/dev/null bash \
&& bash -c ". .nvm/nvm.sh \
&& nvm install v${NODE_VERSION} \
&& nvm alias default v${NODE_VERSION} \
&& npm install -g typescript yarn pnpm node-gyp" \
&& echo ". ~/.nvm/nvm-lazy.sh" >> /home/gleez/.bashrc.d/50-node
# above, we are adding the lazy nvm init to .bashrc, because one is executed on interactive shells, the other for non-interactive shells (e.g. plugin-host)
COPY --chown=gleez:gleez nvm-lazy.sh /home/gleez/.nvm/nvm-lazy.sh
ENV GO_VERSION=${GO_VERSION}
ENV GOPATH=$HOME/go-packages
ENV GOROOT=$HOME/go
ENV PATH=$GOROOT/bin:$GOPATH/bin:/home/gleez/bin:$PATH
RUN curl -fsSL https://dl.google.com/go/go$GO_VERSION.linux-amd64.tar.gz | tar xzs && \
# install VS Code Go tools for use with gopls as per https://github.com/golang/vscode-go/blob/master/docs/tools.md
# also https://github.com/golang/vscode-go/blob/27bbf42a1523cadb19fad21e0f9d7c316b625684/src/goTools.ts#L139
go install -v github.com/uudashr/gopkgs/cmd/gopkgs@v2 && \
go install -v github.com/ramya-rao-a/go-outline@latest && \
go install -v github.com/cweill/gotests/gotests@latest && \
go install -v github.com/fatih/gomodifytags@latest && \
go install -v github.com/josharian/impl@latest && \
go install -v github.com/haya14busa/goplay/cmd/goplay@latest && \
go install -v github.com/go-delve/delve/cmd/dlv@latest && \
go install -v github.com/golangci/golangci-lint/cmd/golangci-lint@latest && \
go install -v golang.org/x/tools/gopls@latest && \
go install -v honnef.co/go/tools/cmd/staticcheck@latest && \
sudo rm -rf $GOPATH/src $GOPATH/pkg $HOME/.cache/go $HOME/.cache/go-build && \
printf '%s\n' 'export GOPATH=/workspace/go' \
'export PATH=$GOPATH/bin:$PATH' > $HOME/.bashrc.d/300-go
WORKDIR /home/workspace/
ENV LANG=C.UTF-8 \
LC_ALL=C.UTF-8 \
EDITOR=code \
VISUAL=code \
GIT_EDITOR="code --wait" \
OPENVSCODE_SERVER_ROOT=${OPENVSCODE_SERVER_ROOT} \
PATH=$HOME/.local/bin:/usr/games:/home/workspace/bin:/home/gleez/.deno/bin:$PATH
# Default exposed port if none is specified
EXPOSE 3000 8080 8081 8082 8083 8084 8085 8086 8087
ENTRYPOINT [ "/bin/sh", "-c", "exec ${OPENVSCODE_SERVER_ROOT}/bin/openvscode-server --host 0.0.0.0 \"${@}\"", "--" ]