-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
124 lines (105 loc) · 4.55 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
FROM bitnami/minideb:bookworm AS builder
ARG ZSH_VERSION=5.9
WORKDIR /tmp/zsh-build
RUN install_packages curl \
ca-certificates \
autoconf \
make \
icu-devtools \
libtool \
libcap-dev \
libtinfo5 \
libncursesw5-dev \
libpcre3-dev \
libgdbm-dev \
yodl \
groff \
man-db \
texinfo \
patch
RUN curl -sSL https://api.github.com/repos/zsh-users/zsh/tarball/$ZSH_VERSION | tar xz --strip=1
COPY *.patch ./
RUN for p in *.patch; do patch -s -p1 -r /dev/null -i "$p" || true; done
RUN ./Util/preconfig
RUN build_platform=x86_64; \
case "$(dpkg --print-architecture)" in \
arm64) \
build_platform="aarch64" \
;; \
esac; \
./configure --build=${build_platform}-unknown-linux-gnu \
--prefix /usr \
--enable-pcre \
--enable-cap \
--enable-multibyte \
--with-term-lib='ncursesw tinfo' \
--with-tcsetpgrp
RUN make
RUN make -C Etc all FAQ FAQ.html
RUN if test $ZSH_VERSION = "master" ; then install_packages cm-super-minimal texlive-fonts-recommended texlive-latex-base texlive-latex-recommended ghostscript bsdmainutils ; fi
RUN if test $ZSH_VERSION = "master" ; then make -C Doc everything ; fi
RUN make install DESTDIR=/tmp/zsh-install
RUN make install.info DESTDIR=/tmp/zsh-install || true
RUN yes '' | adduser --shell /bin/sh --home /tmp/zsh-build --disabled-login --disabled-password zshtest
RUN chown -R zshtest /tmp/zsh-build
RUN su - zshtest -c 'timeout 120 make test' || true
FROM bitnami/minideb:bookworm
# Build arguments
ARG LSD_VERSION=0.21.0
ARG GLOW_VERSION=1.4.1
# Image metadata
LABEL maintainer="Andrew Jo <andrew@verdigris.co>"
# Copy the compiled zsh binaries
COPY --from=builder /tmp/zsh-install /
# Add zsh as one of the shells
RUN echo "/usr/bin/zsh" >> /etc/shells
# Install packages required to run zsh and dev tools.
RUN install_packages libcap2 \
libtinfo5 \
libncursesw5 \
libpcre3 \
libgdbm6 \
build-essential \
ca-certificates \
curl \
git \
gnupg \
less \
sudo \
bat \
openssh-client
# Set pipefail so the entire piped commands fail
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# Use UTF-8 locale as default
ENV LANG=C.UTF-8
# Install enhanced toolset
WORKDIR /tmp
RUN LSD_PACKAGE_NAME="lsd_${LSD_VERSION}_$(dpkg --print-architecture).deb" \
&& curl -sSLO "https://github.com/Peltoche/lsd/releases/download/${LSD_VERSION}/${LSD_PACKAGE_NAME}" \
&& dpkg -i "${LSD_PACKAGE_NAME}" \
&& rm "${LSD_PACKAGE_NAME}"
RUN GLOW_PACKAGE_NAME="glow_${GLOW_VERSION}_linux_$(dpkg --print-architecture).deb" \
&& curl -sSLO "https://github.com/charmbracelet/glow/releases/download/v${GLOW_VERSION}/${GLOW_PACKAGE_NAME}" \
&& dpkg -i "${GLOW_PACKAGE_NAME}" \
&& rm "${GLOW_PACKAGE_NAME}"
# Create a non-root user
ARG USERNAME=verdigrisian
RUN adduser ${USERNAME} --shell /usr/bin/zsh && echo "${USERNAME} ALL=(ALL) NOPASSWD:ALL" | tee /etc/sudoers.d/${USERNAME}
USER ${USERNAME}
# Install oh-my-zsh for the default user
RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
# Add ZSH enhancements
RUN git clone --depth 1 -- https://github.com/marlonrichert/zsh-autocomplete.git "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-autocomplete" \
&& git clone https://github.com/zsh-users/zsh-autosuggestions "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-autosuggestions" \
&& git clone https://github.com/z-shell/F-Sy-H.git "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/F-Sy-H"
# Install Homebrew to keep the container environment similar to macOS local dev environment
# RUN NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Configure shell
RUN git clone --depth=1 https://github.com/romkatv/powerlevel10k.git "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k"
# Copy over dotfiles
COPY dotfiles/* /home/${USERNAME}/
USER root
RUN chown -R ${USERNAME}:${USERNAME} /home/${USERNAME}
USER ${USERNAME}
WORKDIR /home/${USERNAME}
ENTRYPOINT ["/usr/bin/zsh", "-l"]