Created
September 1, 2022 20:20
-
-
Save BrutalSimplicity/882af1d343b7530fc7e005284523d38d to your computer and use it in GitHub Desktop.
Dockerfile with asdf + docker install bits
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM debian:latest | |
# Install basic dev packages | |
RUN apt-get clean && apt-get update && apt-get -y install --no-install-recommends \ | |
apt-utils \ | |
openssh-client \ | |
git \ | |
gnupg2 \ | |
dirmngr \ | |
iproute2 \ | |
procps \ | |
lsof \ | |
htop \ | |
net-tools \ | |
psmisc \ | |
curl \ | |
wget \ | |
rsync \ | |
ca-certificates \ | |
unzip \ | |
zip \ | |
nano \ | |
vim \ | |
neovim \ | |
less \ | |
jq \ | |
lsb-release \ | |
apt-transport-https \ | |
dialog \ | |
libc6 \ | |
libgcc1 \ | |
libkrb5-3 \ | |
libgssapi-krb5-2 \ | |
libicu[0-9][0-9] \ | |
liblttng-ust0 \ | |
libstdc++6 \ | |
zlib1g \ | |
locales \ | |
sudo \ | |
ncdu \ | |
man-db \ | |
strace \ | |
manpages \ | |
manpages-dev \ | |
init-system-helpers \ | |
make \ | |
build-essential \ | |
# python runtime dependencies | |
openssl \ | |
bzip2 \ | |
libreadline8 \ | |
sqlite3 \ | |
tk \ | |
xz-utils \ | |
libxml2 \ | |
llvm \ | |
# python build dependencies | |
build-essential \ | |
libssl-dev \ | |
zlib1g-dev \ | |
libbz2-dev \ | |
libreadline-dev \ | |
libsqlite3-dev \ | |
libncursesw5-dev \ | |
tk-dev \ | |
libxml2-dev \ | |
libxmlsec1-dev \ | |
libffi-dev \ | |
liblzma-dev \ | |
# some useful dev utils | |
fd-find \ | |
bat \ | |
tree \ | |
zsh && \ | |
ln -s $(which fdfind) /usr/local/bin/fd && \ | |
ln -s $(which batcat) /usr/local/bin/bat && \ | |
rm -rf /var/lib/apt/lists/* | |
# ensure we use bash for all RUN commands | |
# use -l to use interactive login shell | |
# and ensure modifications to bashrc are properly sourced | |
SHELL ["/bin/bash", "-lc"] | |
# install asdf to manage all the thingz!!! | |
RUN git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.8.1 && \ | |
echo ". $HOME/.asdf/asdf.sh" >> /root/.bashrc && \ | |
echo ". $HOME/.asdf/asdf.sh" >> /root/.zshrc | |
# install plugins | |
RUN asdf plugin add nodejs && \ | |
asdf plugin add python && \ | |
asdf plugin add golang && \ | |
asdf plugin add awscli && \ | |
asdf plugin add aws-sam-cli | |
# install python build dependencies since asdf | |
# builds from the source | |
RUN asdf install python 3.9.6 && \ | |
asdf install nodejs 14.18.2 && \ | |
asdf install golang 1.18.2 | |
# set global versions | |
RUN asdf global python 3.9.6 && \ | |
asdf global nodejs 14.18.2 && \ | |
asdf global golang 1.18.2 | |
# setup AWS tools separately since many depend on python | |
RUN asdf install awscli 2.7.28 && \ | |
asdf install aws-sam-cli 1.56.0 && \ | |
asdf global awscli 2.7.28 && \ | |
asdf global aws-sam-cli 1.56.0 | |
# upgrade python and node package managers and install nx workspace manager | |
RUN pip install --upgrade pip && npm i -g npm@latest && \ | |
pip install pipenv==v2021.11.23 && npm i -g [email protected] | |
# install docker | |
RUN curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg && \ | |
echo \ | |
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | \ | |
tee /etc/apt/sources.list.d/docker.list > /dev/null && \ | |
apt-get update && \ | |
apt-get -y --no-install-recommends install docker-ce=5:20.10.12~3-0~debian-bullseye docker-ce-cli=5:20.10.12~3-0~debian-bullseye containerd.io && \ | |
rm -rf /var/lib/apt/lists/* | |
# easy docker compose and buildx install | |
COPY --from=docker:20.10 /usr/libexec/docker/cli-plugins /usr/libexec/docker/cli-plugins | |
RUN dockerd --version && \ | |
docker --version && \ | |
docker buildx version && \ | |
docker compose version | |
# install boto3 | |
RUN pip install boto3 | |
# set all the things to be sure bash is always used as the default shell | |
RUN cd /bin && ln -sf bash sh && chsh -s /bin/bash | |
ENV SHELL=bash | |
ENV PATH=$PATH:/root/.bin | |
WORKDIR /root | |
ENTRYPOINT [ "/bin/bash", "-lc" ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Apparently, unlike
bash -l -c
,bash -c
just does not load the system-wide and user-specific profiles / bashrc files.I can see it by comparing
strace -e openat bash -c true
andstrace -e openat bash -lc true
.To force
bash -c
to load a specific file, it can also be started likeBASH_ENV=$ASDF_DIR/asdf.sh bash -c python3 -c 'print("hello")'
.