-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockerfile
194 lines (155 loc) · 7.74 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
################################################################################
#
# Spacemacs Docker Container
# ==========================
#
# Ed Liversidge, Harmonic Software Systems Ltd harmonicss.co.uk
#
# Installs a spacemacs docker continer with development environment for C and
# Rust development.
#
# build using : (dont forget the .)
# ===========
#
# docker build -t harmonicss/spacemacs --build-arg XAUTHORITY=$XAUTHORITY --build-arg USERNAME=$USER .
#
# Run using :
# ===========
#
# docker run -it --rm -e DISPLAY --net=host -v ~/Projects:/home/$USER/Projects harmonicss/spacemacs
#
#
################################################################################
################################################################################
# Change this to use fast emacs-native-comp, needs to be
# built from docker beforehand. Not on dockerhub yet, but on
# github here : https://github.com/harmonicss/docker-emacs-native
################################################################################
FROM ubuntu:latest
#FROM emacs-native-comp
################################################################################
# Install emacs and git
################################################################################
RUN apt update && \
apt install -y software-properties-common
RUN add-apt-repository ppa:kelleyk/emacs
RUN apt update
RUN apt install -y git
RUN apt install -y emacs28
RUN apt install -y global
# Sometimes emacs is bust!
# not working on pve-desktop-4
#RUN apt install -y vim
################################################################################
# Install lsp clangd-13 (C language LSP server for code completion)
# and gcc for syntax checking
################################################################################
RUN apt install -y gcc
RUN apt update
RUN apt install -y pip
RUN apt install -y clangd-13
RUN apt install -y cppcheck
RUN apt install -y curl
RUN pip install python-lsp-server
################################################################################
# To Remove emacs loading warnings
################################################################################
RUN apt install -y libcanberra-gtk-module libcanberra-gtk3-module
################################################################################
# XAUTHORITY and USERNAME is passsed in via cmd line
# eg docker build -t spacemacs --build-arg XAUTHORITY=$XAUTHORITY \
# --build-arg USERNAME=$USERNAME .
################################################################################
ARG XAUTHORITY
ARG USERNAME
################################################################################
# Add a new user with the USERID of XAUTHORITY thats parsed
# from the string passed in and also give it group privileges
################################################################################
RUN useradd -d /home/"$USERNAME" -u $(echo $XAUTHORITY | awk -F/ '{print $4}') -ms /bin/bash "$USERNAME" && usermod -aG "$USERNAME" "$USERNAME"
################################################################################
# Configure file system properties
################################################################################
USER root
RUN mkdir /home/$USERNAME || echo "Skip over build error"
RUN chown -R $USERNAME /home/$USERNAME
################################################################################
# Install source code pro font
# https://askubuntu.com/questions/193072/how-to-use-the-adobe-source-code-pro-font
################################################################################
RUN apt update
RUN apt install -y wget
RUN wget --content-disposition -P /usr/share/fonts/opentype/source-code-pro https://github.com/adobe-fonts/source-code-pro/blob/29fdb884c6e9dc2a312f4a5e2bb3b2dad2350777/OTF/SourceCodePro-Regular.otf?raw=true
################################################################################
# Setup the environment
################################################################################
USER $USERNAME
WORKDIR /home/$USERNAME
ENV UNAME $USERNAME
ENV GNAME $USERNAME
################################################################################
# Mounting the XAUTHORITY file allow the x11 graphics to work
################################################################################
VOLUME $XAUTHORITY
################################################################################
# Configure .bashrc properties
################################################################################
RUN echo 'alias ll="ls -hal --color"' >> ~/.bashrc
################################################################################
# Set the prompt for the bash shell
################################################################################
RUN echo 'export PS1="\[\033[01;31m\]\u@docker\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ "' >> /home/$USERNAME/.bashrc
################################################################################
# get .spacemacs
################################################################################
RUN git clone https://github.com/syl20bnr/spacemacs ~/.emacs.d
################################################################################
# get the last good spacemacs version we use as hss
################################################################################
#RUN cd .emacs.d && git checkout 387d16545573517524a60dbebf0c6e71be58eab6
################################################################################
# lock spacemacs at latest as of Nov 13 2022
################################################################################
RUN cd .emacs.d && git checkout bdc9d0bec554c363417c04b674fda021398fbe4f
RUN cd ~
RUN git init
RUN git remote add origin https://github.com/harmonicss/spacemacs.git
RUN git pull origin master
RUN cp .spacemacs.linux .spacemacs
RUN mkdir ~/.emacs.d/backup
RUN mkdir ~/.emacs.d/undo
################################################################################
# Install all the .spacemacs packages, twice as there as always stragglers to update
################################################################################
RUN emacs -nw -batch -u "$USERNAME" -q -kill
RUN emacs -nw -batch -u "$USERNAME" -q -kill
################################################################################
# Fix for issue spacemacs bug - #15896
# Fixes for emacs version 28.1 and 28.2.
# https://github.com/syl20bnr/spacemacs/issues/15896
################################################################################
RUN rm -rf ~/.emacs.d/elpa/28.1/develop/org-9*
RUN rm -rf ~/.emacs.d/elpa/28.2/develop/org-9*
RUN emacs -nw -batch -u "$USERNAME" -q -kill
################################################################################
# Configure git
################################################################################
RUN git config --global user.name $USERNAME \
&& git config --global user.email [email protected]
################################################################################
# Install rust, problem getting a yes to install silently
#
# https://github.com/rust-lang/rustup/issues/297
# -s Runs the stdin of sh as the script.
# -- is used to tell the shell that further arguments are not options:
################################################################################
RUN curl -sSf https://sh.rustup.rs | sh -s -- -y
################################################################################
# install rust-analyser
################################################################################
RUN git clone https://github.com/rust-analyzer/rust-analyzer.git
# needs to be in the same directory
# cargo not in the /bin/sh path, for some reason
RUN cd rust-analyzer && /home/$USERNAME/.cargo/bin/cargo xtask install --server
#ENTRYPOINT ["emacs"]
CMD ["emacs"]