-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdockerfile
More file actions
75 lines (63 loc) · 2.57 KB
/
dockerfile
File metadata and controls
75 lines (63 loc) · 2.57 KB
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
# Start from a lightweight base image with a specific Python version
FROM python:3.11-slim
# Install essential packages for pyenv and Python builds
RUN apt-get update && apt-get install -y \
curl \
git \
build-essential \
libssl-dev \
zlib1g-dev \
libbz2-dev \
libreadline-dev \
libsqlite3-dev \
wget \
llvm \
libncurses5-dev \
libncursesw5-dev \
xz-utils \
tk-dev \
libffi-dev \
liblzma-dev \
libgdbm-dev \
&& rm -rf /var/lib/apt/lists/*
# Set architecture-specific Quarto URL
# This runs at build time to determine the architecture and download the correct Quarto package.
RUN ARCH=$(uname -m) && \
if [ "$(uname -m)" = "x86_64" ]; then \
ARCH="amd64"; \
elif [ "$(uname -m)" = "arm64" ] || [ "$(uname -m)" = "aarch64" ]; then \
ARCH="arm64"; \
else \
echo "Unsupported architecture"; exit 1; \
fi && \
curl -fsSL https://github.com/quarto-dev/quarto-cli/releases/download/v1.7.6/quarto-1.7.6-linux-${ARCH}.tar.gz | tar -xz -C /opt \
&& ln -s /opt/quarto-1.7.6/bin/quarto /usr/local/bin/quarto
# Verify Quarto installation
RUN quarto --version
# Install pyenv for Python version management
ENV PYENV_ROOT="/root/.pyenv"
ENV PATH="$PYENV_ROOT/bin:$PYENV_ROOT/shims:$PATH"
RUN curl https://pyenv.run | bash
# Install pipx and use it to install poetry
ENV PIPX_BIN_DIR="/root/.local/bin"
ENV PATH="$PIPX_BIN_DIR:$PATH"
RUN pip install --no-cache-dir pipx && \
pipx install poetry
# Install commonly used Python versions with pyenv for flexibility
RUN pyenv install 3.9.13 && pyenv install 3.11.6
# Set a default global Python version (can be overridden by individual projects)
RUN pyenv global 3.11.6
# Configure poetry to create virtual environments within each project directory
RUN poetry config virtualenvs.in-project true
# Install ipython and configure default IPython profile
RUN pip install ipython && \
ipython profile create && \
echo "c.InteractiveShellApp.extensions = ['autoreload']" >> /root/.ipython/profile_default/ipython_config.py && \
echo "c.InteractiveShellApp.exec_lines = ['%autoreload 2']" >> /root/.ipython/profile_default/ipython_config.py && \
echo "c.TerminalInteractiveShell.editing_mode = 'vi'" >> /root/.ipython/profile_default/ipython_config.py
# Set work directory (to be replaced in downstream images by project-specific directories)
WORKDIR /app
# Expose poetry and pyenv paths for downstream images
ENV PATH="$PYENV_ROOT/shims:$PIPX_BIN_DIR:$PATH"
# Optionally add an entrypoint to make poetry commands easier to run in derived images
ENTRYPOINT ["poetry"]