-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
216 lines (179 loc) · 8.62 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
211
212
213
214
215
216
# syntax = docker/dockerfile:1
FROM debian:stable-slim AS tmux-builder
# Prepare environment
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get upgrade --yes --show-upgraded \
&& apt-get install --yes \
locales automake build-essential pkg-config libssl-dev libtool \
libutf8proc-dev bison byacc imagemagick ca-certificates curl file \
&& apt-get purge --yes manpages manpages-dev \
&& apt-get autoremove --yes \
&& rm -rf /var/lib/apt/lists/*
ENV BUILD_DIR=/opt/tmux
ENV PATH=$BUILD_DIR/bin:$PATH
ENV LANGUAGE=en_US.UTF-8
ENV LC_ALL=en_US.UTF-8
ENV LANG=en_US.UTF-8
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
CMD ["bash"]
WORKDIR /tmp
# Setup locales and terminfo
RUN localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
COPY ./.files/.config/terminfo /etc/terminfo
# libevent
ENV libevent_version=2.1.12
ENV libevent_name=libevent-${libevent_version}-stable
ENV libevent_url=https://github.com/libevent/libevent/releases/download/release-${libevent_version}-stable/${libevent_name}.tar.gz
RUN curl --retry 5 -LO "$libevent_url" && \
tar xvzf "$libevent_name.tar.gz" && \
cd "$libevent_name" && \
autoupdate && \
sh autogen.sh && \
./configure --prefix="$BUILD_DIR" --enable-shared && \
make -j4 && \
make install && \
cd .. && \
rm -fr "$libevent_name.tar.gz" "$libevent_name"
# ncurses
ENV ncurses_version=6.5
ENV ncurses_name=ncurses-${ncurses_version}
ENV ncurses_url=https://ftp.gnu.org/pub/gnu/ncurses/${ncurses_name}.tar.gz
RUN curl --retry 5 -LO "$ncurses_url" && \
tar xvzof "${ncurses_name}.tar.gz" && \
cd "$ncurses_name" && \
./configure --prefix="$BUILD_DIR" \
--enable-pc-files \
--with-shared \
--with-termlib \
--with-default-terminfo-dir=/usr/share/terminfo \
--with-terminfo-dirs="/etc/terminfo:/lib/terminfo:/usr/share/terminfo" \
--with-pkg-config-libdir="$BUILD_DIR/lib/pkgconfig" && \
make -j4 && \
make install && \
cd .. && \
rm -fr "${ncurses_name}.tar.gz" "$ncurses_name"
# tmux
ENV tmux_version=3.5a
ENV tmux_name=tmux-${tmux_version}
ENV tmux_url=https://github.com/tmux/tmux/releases/download/$tmux_version/$tmux_name.tar.gz
RUN curl --retry 5 -LO "$tmux_url" && \
tar xvzof "$tmux_name.tar.gz" && \
cd "$tmux_name" && \
export LDFLAGS="-L$BUILD_DIR/lib" && \
export CPPFLAGS="-I$BUILD_DIR/include -I$BUILD_DIR/include/ncurses -I$BUILD_DIR/include/event2" && \
export PKG_CONFIG_PATH="$BUILD_DIR/lib/pkgconfig" && \
./configure --enable-utf8proc --prefix="$BUILD_DIR" --enable-static && \
make -j4 && \
make install && \
cd .. && \
rm -fr "$tmux_name.tar.gz" "$tmux_name"
RUN "$BUILD_DIR/bin/tmux" -V
# --------------------------------------------------------------------------
# Build fish-shell from source from faho fork with `fish-installer` branch:
# https://github.com/faho/fish-shell/tree/fish-installer
# Use Debian 10.x "buster" for older glib versions.
FROM rust:slim-buster AS fish-builder
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install --no-install-recommends --yes git \
&& rm -rf /var/lib/apt/lists/* /var/cache/* /var/log/* /var/lib/*
WORKDIR /root
ARG BUILD_REVISION=132
LABEL io.rafi.revision="$BUILD_REVISION"
RUN git clone https://github.com/fish-shell/fish-shell.git && \
cd fish-shell && \
FISH_BUILD_DOCS=0 cargo build --release && \
rm -rf /usr/local/cargo/registry /usr/local/cargo/git
# --------------------------------------------------------------------------
FROM alpine:edge AS nvim-plugins
WORKDIR /root
RUN apk add curl git alpine-sdk neovim --update --no-cache
COPY .files/.config/nvim .config/nvim
RUN nvim --headless "+Lazy! sync" +qa \
&& rm -rf ~/.cache /tmp/nvim.root \
&& rm -rf ~/.local/state/nvim/log ~/.local/state/nvim/shada
# --------------------------------------------------------------------------
FROM debian:stable-slim AS downloader
ARG BUILD_REVISION=132
LABEL io.rafi.source="https://github.com/rafi/awesome-cli-binaries"
LABEL io.rafi.revision="$BUILD_REVISION"
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get upgrade --yes --show-upgraded \
&& apt-get install --yes bash wget \
&& apt-get purge --yes manpages manpages-dev \
&& apt-get autoremove --yes \
&& rm -rf /var/lib/apt/lists/* /var/cache/* /var/log/*
WORKDIR /usr/local/bin
# Pre-defined build arguments
# See https://docs.docker.com/build/building/variables/#pre-defined-build-arguments
ARG TARGETARCH
# dra (Download Release Assets from GitHub)
RUN arch="$(uname -m)" \
&& dra_name="${arch}-unknown-linux-$([ "$arch" = x86_64 ] && echo musl || echo gnu)" \
&& dra_version="$(wget -qO- --no-hsts https://api.github.com/repos/devmatteini/dra/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')" \
&& dra_url="https://github.com/devmatteini/dra/releases/download/$dra_version/dra-$dra_version-$dra_name.tar.gz" \
&& wget -qO- --no-hsts "$dra_url" | tar -xzo --strip-components 1 "dra-$dra_version-$dra_name/dra" \
&& chmod 770 dra \
&& dra --version
RUN --mount=type=secret,id=token \
GITHUB_TOKEN="$(cat /run/secrets/token)" && export GITHUB_TOKEN \
&& dra download -ai upx/upx && upx --version \
&& dra download -ai imsnif/bandwhich && bandwhich --version \
&& dra download -ai sharkdp/bat && bat --version \
&& dra download -ai aristocratos/btop && btop --version \
&& dra download -aI crane google/go-containerregistry && upx crane && crane version \
&& dra download -ai dandavison/delta && delta --version \
&& dra download -s diff-so-fancy so-fancy/diff-so-fancy && chmod ug+x diff-so-fancy \
&& dra download -ai Byron/dua-cli && dua --version \
&& dra download -ai muesli/duf && duf -version \
&& dra download -ai bootandy/dust && dust --version \
&& dra download -ai homeport/dyff && dyff version
RUN --mount=type=secret,id=token \
GITHUB_TOKEN="$(cat /run/secrets/token)" && export GITHUB_TOKEN \
&& dra download -ai solidiquis/erdtree && erd --version \
&& dra download -ai eza-community/eza && eza --version \
&& dra download -ai sharkdp/fd && fd --version \
&& dra download -aio fx antonmedv/fx && upx fx && fx --version \
&& dra download -ai junegunn/fzf && fzf --version && (fzf --bash > fzf.bash && fzf --zsh > fzf.zsh && fzf --fish > fzf.fish) \
&& dra download -ai charmbracelet/glow && upx glow && glow --version && rm -rf ~/.cache ~/.config \
&& dra download -ai mrjackwills/havn && havn --version \
&& dra download -ai sharkdp/hexyl && hexyl --version \
&& dra download -ai sharkdp/hyperfine && hyperfine --version \
&& dra download -aio jq stedolan/jq && jq --version \
&& dra download -ai casey/just && just --version
RUN --mount=type=secret,id=token \
GITHUB_TOKEN="$(cat /run/secrets/token)" && export GITHUB_TOKEN \
&& dra download -ai lsd-rs/lsd && lsd --version \
&& dra download -aio mkcert FiloSottile/mkcert && mkcert --version \
&& dra download -ai MilesCranmer/rip2 && rip --version \
&& dra download -ai BurntSushi/ripgrep && rg --version \
&& dra download -ai starship/starship && starship -V && rm -rf ~/.cache \
&& dra download -ai stern/stern && upx stern && stern --version \
&& dra download -ai ducaale/xh && xh --version \
&& dra download -ai sxyazi/yazi && yazi --version && rm -rf ~/.local /tmp/yazi* \
&& dra download -aI yq_linux_${TARGETARCH} -o yq mikefarah/yq && yq --version \
&& dra download -ai ajeetdsouza/zoxide && zoxide --version
# Chafa
ARG chafa_version=1.14.5
RUN wget -qO- --no-hsts \
https://hpjansson.org/chafa/releases/static/chafa-${chafa_version}-1-x86_64-linux-gnu.tar.gz | tar -xzo --strip-components 1
# Neovim repositories
# - github.com/neovim/neovim - official releases
# - github.com/neovim/neovim-releases - best-effort builds with glibc 2.17
RUN wget -q --no-hsts \
https://github.com/neovim/neovim-releases/releases/download/stable/nvim-linux64.tar.gz
# Copy compiled tmux
COPY --from=tmux-builder /opt/tmux/bin/tmux .
# Copy compiled fish-shell
COPY --from=fish-builder /root/fish-shell/target/release/fish .
COPY --from=fish-builder /root/fish-shell/target/release/fish_indent .
COPY --from=fish-builder /root/fish-shell/target/release/fish_key_reader .
# Copy downloaded neovim plugins
COPY --from=nvim-plugins /root/.local/share/nvim /root/.local/share/nvim
COPY --from=nvim-plugins /root/.local/state/nvim /root/.local/state/nvim
COPY --from=nvim-plugins /root/.config/nvim/lazy-lock.json /root/.config/nvim/lazy-lock.json
# Pre-made dotfiles
COPY .files/.config /root/.config
# --------------------------------------------------------------------------