-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile.dev
More file actions
82 lines (63 loc) · 2.87 KB
/
Dockerfile.dev
File metadata and controls
82 lines (63 loc) · 2.87 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
76
77
78
79
80
81
82
# syntax=docker/dockerfile:1
FROM python:3.11
# General environment settings
ENV PYTHONFAULTHANDLER=1 \
# print output immediately in stdout
PYTHONUNBUFFERED=1 \
# Skips writing `__pycache__/` directories and `.pyc` files
# PYTHONDONTWRITEBYTECODE=1 \
# Doesn't save packages downloaded by pip in cache
PIP_NO_CACHE_DIR=1 \
# Skip check for pip upgrade (use base image version)
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_DEFAULT_TIMEOUT=90 \
POETRY_VERSION=1.8.0 \
POETRY_NO_INTERACTION=1
# Project settings
ENV user=alab \
SATRAP_FOLDER=satrap-dl
# Keep separate to allow for the $user variable to be set before
ENV PROJECT_HOME=/home/${user}/${SATRAP_FOLDER}/
# Update base image's (Debian) package list, install required packages and clean up the list
RUN apt-get update && \
apt-get install -y --no-install-recommends graphviz curl && \
rm -rf /var/lib/apt/lists/*
# Install Node.js 20.x (required by Mermaid CLI / mmdc)
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
apt-get install -y --no-install-recommends nodejs
# Install Chromium (headless browser backend for Mermaid CLI)
# RUN apt-get install -y chromium || apt-get install -y chromium-browser || true
RUN apt-get update && \
(apt-get install -y --no-install-recommends chromium || \
apt-get install -y --no-install-recommends chromium-browser || true) && \
rm -rf /var/lib/apt/lists/*
# Install Mermaid CLI for rendering Mermaid diagrams in specs
RUN npm install -g @mermaid-js/mermaid-cli && \
npm cache clean --force
# Install pipx and add the installation folder to the PATH
RUN python3 -m pip install pipx && python3 -m pipx ensurepath
# Create a non-root user and set it as the current user
RUN useradd -ms /bin/bash ${user}
USER ${user}
# Add pipx installation folder to the PATH variable
ENV PATH="/home/${user}/.local/bin:${PATH}"
# Install poetry
RUN pipx install "poetry==$POETRY_VERSION" \
&& poetry completions bash >> ~/.bash_completion
# Install Doorstop
RUN pipx install doorstop==3.0b10
# Create and set the working directory in the container
WORKDIR ${PROJECT_HOME}
# Copy dependency files from the host into the image's filesystem with non-root user as owner
COPY --chown=${user}:${user} poetry.lock pyproject.toml ${PROJECT_HOME}
# Install dependencies (cached until poetry.lock changes)
RUN poetry install --no-root --no-ansi
# Copy the project files ensuring they are owned by the non-root user (separately for build cache optimization)
COPY --chown=${user}:${user} . ${PROJECT_HOME}
# Install the project itself --'s dependencies and create virtual env.
RUN poetry install --only-root --no-ansi
# when a container is started...
# loading the virtual environment with 'CMD ["poetry", "shell"]' does not work
# here as the command requires an interactive shell already running;
# this is an alternative way to launch a bash shell inside the venv
ENTRYPOINT ["poetry", "run", "bash"]