-
Notifications
You must be signed in to change notification settings - Fork 80
/
Dockerfile
60 lines (46 loc) · 2.13 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
FROM ubuntu:24.04
ARG USERNAME=ubuntu
ARG USER_UID=1000
ARG USER_GID=$USER_UID
# Ensure apt is in non-interactive to avoid prompts
ENV DEBIAN_FRONTEND=noninteractive
# Create the user
RUN apt-get update \
&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME
RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
# Install dependencies.
RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt \
apt-get update && apt-get -y install --no-install-recommends \
build-essential make libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev curl llvm libncursesw5-dev \
xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev \
wget ca-certificates apt-utils locales git openssh-client && \
locale-gen en_US.UTF-8
ENV DEBIAN_FRONTEND=dialog
USER $USERNAME
# Install pyenv to manage multiple python installations
RUN curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash && \
echo 'export PATH="$HOME/.pyenv/bin:$PATH"' >> ~/.bashrc && \
echo 'eval "$(pyenv init --path)"' >> ~/.bashrc && \
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc
# Not sure this is needed
SHELL ["/bin/bash","--login", "-c"]
# Stuff needed to make pyenv work correctly since the login shell
# above doesnt seem to run bachrc
ENV PYENV_ROOT="/home/ubuntu/.pyenv"
ENV PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH
# Install the required python versions (this takes a bit usually) so we do lots of cacheing
RUN --mount=type=cache,target=/home/ubuntu/.pyenv/cache,uid=1000 \
pyenv install -s 3.8.18 && \
pyenv install -s 3.9.18 && \
pyenv install -s 3.10.13 && \
pyenv install -s 3.11.6 && \
pyenv install -s 3.12.0 && \
pyenv global 3.11.6 && \
pyenv rehash
# Install poetry to manage our python project
RUN curl -sSL https://install.python-poetry.org | python3 -
# Install nox and pre-commit to automate CI stuff
RUN pip install --user --upgrade nox nox_poetry pre-commit