-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemacs.Dockerfile
76 lines (60 loc) · 2.83 KB
/
emacs.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
# docker build --build-arg WSL_DISTRO_NAME=$WSL_DISTRO_NAME --build-arg USER=$USER --build-arg VERSION=30.0.93 -f emacs.Dockerfile -t emacs .
# https://www.masteringemacs.org/article/speed-up-emacs-libjansson-native-elisp-compilation
ARG ICONS_DIR=all-the-icons
################################## Build environment ##################################
FROM ubuntu:22.04 AS build
ARG VERSION
ARG ICONS_DIR
ARG EMACS_BRANCH="emacs-${VERSION}"
WORKDIR /opt
ENV DEBIAN_FRONTEND=noninteractive
RUN apt update && \
apt install -y git libjansson4 libjansson-dev apt-transport-https ca-certificates \
curl gnupg-agent software-properties-common libtree-sitter-dev && \
add-apt-repository ppa:ubuntu-toolchain-r/ppa && \
apt install -y gcc-10 libgccjit0 libgccjit-10-dev
RUN git clone --depth 1 --branch $EMACS_BRANCH https://git.savannah.gnu.org/git/emacs.git . && \
git clone --depth 1 https://github.com/domtronn/all-the-icons.el $ICONS_DIR
RUN sed -i 's/# deb-src/deb-src/' /etc/apt/sources.list && apt update && apt-get build-dep -y emacs
ENV CC="gcc-10"
RUN git config --global --add safe.directory /opt && \
./autogen.sh && \
./configure --with-native-compilation=aot --with-tree-sitter && \
make -j 2 && \
make install prefix=/opt/build
################################## Run environment ##################################
FROM ubuntu:22.04
ARG VERSION
ARG USER
ARG ICONS_DIR
ARG HOST_MOUNT=/host
ARG INST_PATH=/usr/local/share
WORKDIR /opt
COPY --from=build /opt/build /usr/local
COPY --from=build "/opt/${ICONS_DIR}/fonts" "${INST_PATH}/fonts/${ICONS_DIR}"
# Silence dbind-WARNING
ENV NO_AT_BRIDGE=1
# Set emacs home dir
ENV HOME=/home/share
# Add home to path
ENV PATH="/home/${USER}:${PATH}"
ENV EMACSLOADPATH=\
"${INST_PATH}/emacs/${VERSION}/lisp/":\
"${INST_PATH}/emacs/${VERSION}/lisp/emacs-lisp/":\
"${HOME}/.emacs.d/":\
"${HOST_MOUNT}/home/${USER}/.emacs.d/"
# So apt doesn't ask for user input
ENV DEBIAN_FRONTEND=noninteractive
RUN apt update && \
apt install -y libtree-sitter0 libjpeg62 libtiff5 libpng16-16 libgif7 libgtk-3-0 libsm6 \
libasound2 libgpm2 libotf1 libm17n-0 libjansson4 libgccjit0 dbus-x11 sudo openssh-client
# Set up user, configure environment (this needs to match your group on the host)
#gsettings set org.gnome.desktop.wm.keybindings activate-window-menu "[]"
RUN adduser --gecos "" --uid 1000 --disabled-password $USER && \
echo "${USER} ALL=(ALL:ALL) NOPASSWD: ALL" > "/etc/sudoers.d/${USER}" && \
echo " IdentityFile ${HOST_MOUNT}/home/${USER}/.ssh/id_rsa" >> /etc/ssh/ssh_config && \
echo " UserKnownHostsFile ${HOST_MOUNT}/home/${USER}/.ssh/known_hosts" >> /etc/ssh/ssh_config
# Install dependencies and other nice-to-haves
RUN apt install -o DPkg::Options::="--force-confnew" -y python3 \
ispell fonts-hack-ttf ripgrep markdown tree && \
fc-cache -f