-
Notifications
You must be signed in to change notification settings - Fork 5
/
Dockerfile
158 lines (140 loc) · 4.9 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
# To set up our environment, we start from Micromamba's base image. The latest tags
# can be found here: <https://hub.docker.com/r/mambaorg/micromamba/tags>
# For reproducibility, we should pin to a particular Git tag (not a micromamba version).
# For more info, about micromamba, see:
# <https://github.com/mamba-org/micromamba-docker>.
ARG BASE_IMAGE=mambaorg/micromamba:git-9a46999
# The folder to use as a workspace. The project should be mounted here.
ARG DEV_WORK_DIR=/work
FROM ${BASE_IMAGE}
# Grab Docker, buildx, and Docker Compose
COPY --from=docker:dind /usr/local/bin/docker /usr/local/bin/docker
COPY --from=docker/buildx-bin /buildx /usr/libexec/docker/cli-plugins/docker-buildx
COPY --from=docker/compose /usr/local/bin/docker-compose /usr/local/bin/docker-compose
USER root
# Reallow installing manpages <https://unix.stackexchange.com/a/480460>
# (The Docker image is minified so manpages aren't included.)
RUN : \
&& sed -i '/path-exclude \/usr\/share\/man/d' /etc/dpkg/dpkg.cfg.d/docker \
&& sed -i '/path-exclude \/usr\/share\/groff/d' /etc/dpkg/dpkg.cfg.d/docker \
;
# Install some useful OS packages
RUN apt-get update && apt-get install -y --no-install-recommends --reinstall \
#
# manpages
man-db \
#
# reinstall coreutils to get manpages for the standard commands (e.g. cp)
coreutils \
#
# runs commands as superuser
sudo \
#
# tab autocompletion for bash
bash-completion \
#
# pagination
less \
#
# version control
git \
patch \
#
# Git Large File Storage
git-lfs \
#
# simple text editor
nano \
#
# parses JSON on the bash command line
jq \
#
# GNU Privacy Guard
gnupg2 \
#
# ssh
openssh-client \
#
# determines file types
file \
#
# process monitor
htop \
#
# compression
zip \
unzip \
p7zip-full \
#
# downloads files
curl \
wget \
#
# lists open files
lsof \
#
# ping and ip utilities
iputils-ping \
iproute2 \
#
# ifconfig, netstat, etc.
net-tools \
#
# nslookup and dig (for looking up hostnames)
dnsutils \
#
# socket cat for bidirectional byte streams
socat \
#
# TCP terminal
telnet \
#
# used by VS Code LiveShare extension
libicu67 \
#
&& rm -rf /var/lib/apt/lists/*
# Grant sudo to the user.
RUN usermod -aG sudo "${MAMBA_USER}" \
&& echo "%sudo ALL=(ALL:ALL) NOPASSWD:ALL" > /etc/sudoers.d/grant-to-sudo-group
# Install docker-compose
RUN : \
&& COMPOSE_VERSION=$(git ls-remote https://github.com/docker/compose | grep refs/tags | grep -oE "v[0-9]+\.[0-9]+\.[0-9]+$" | sort --version-sort | tail -n 1) \
&& sh -c "curl -L https://github.com/docker/compose/releases/download/${COMPOSE_VERSION}/docker-compose-$(uname -s)-$(uname -m) > /usr/local/bin/docker-compose" \
&& chmod +x /usr/local/bin/docker-compose \
&& COMPOSE_SWITCH_VERSION=$(git ls-remote https://github.com/docker/compose-switch | grep refs/tags | grep -oE "v[0-9]+\.[0-9]+\.[0-9]+$" | sort --version-sort | tail -n 1) \
&& sh -c "curl -L https://github.com/docker/compose/releases/download/${COMPOSE_SWITCH_VERSION}/docker-compose-$(uname -s)-$(uname -m) > /usr/local/bin/compose-switch" \
&& chmod +x /usr/local/bin/compose-switch \
;
# Install bash completions
RUN : \
&& mkdir -p /etc/bash_completion.d \
&& sh -c "curl -L https://raw.githubusercontent.com/docker/compose/1.29.2/contrib/completion/bash/docker-compose > /etc/bash_completion.d/docker-compose" \
&& sh -c "curl -L https://raw.githubusercontent.com/docker/cli/v20.10.13/contrib/completion/bash/docker > /etc/bash_completion.d/docker" \
&& sh -c "curl -L https://raw.githubusercontent.com/git/git/v2.35.1/contrib/completion/git-completion.bash > /etc/bash_completion.d/git" \
;
# Make sure we own the working directory.
ARG DEV_WORK_DIR
RUN : \
&& mkdir -p "${DEV_WORK_DIR}" \
&& chown "$MAMBA_USER:$MAMBA_USER" "${DEV_WORK_DIR}"
# Set the working directory.
ENV DEV_WORK_DIR="${DEV_WORK_DIR}"
WORKDIR "${DEV_WORK_DIR}"
USER $MAMBA_USER
# Sane defaults for Git
RUN : \
# Switch default editor from vim to nano
&& git config --global core.editor nano \
# Prevent unintentional merges
# <https://blog.sffc.xyz/post/185195398930/why-you-should-use-git-pull-ff-only-git-is-a>
&& git config --global pull.ff only \
# Use default branch name "main" instead of "master"
&& git config --global init.defaultBranch main \
# Initialize Git LFS
&& git lfs install --skip-repo \
;
# Symlink the .vscode-server directory to the user's home directory.
RUN ln -s "/mnt/.vscode-server" "/home/${MAMBA_USER}/.vscode-server"
# Stack a development entrypoint after the default micromamba-docker entrypoint.
COPY dev-entrypoint.sh /usr/local/bin/_dev-entrypoint.sh
ENTRYPOINT ["/usr/local/bin/_entrypoint.sh", "/usr/local/bin/_dev-entrypoint.sh"]