-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.dev
59 lines (48 loc) · 2.18 KB
/
Dockerfile.dev
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
FROM python:3.11-slim-buster
# Use Docker BuildKit for better caching and faster builds
ARG DOCKER_BUILDKIT=1
ARG BUILDKIT_INLINE_CACHE=1
# Enable BuildKit for Docker-Compose
ARG COMPOSE_DOCKER_CLI_BUILD=1
# Configure apt and install packages
RUN apt-get update && \
apt-get install -y --no-install-recommends apt-utils libcairo2-dev zlib1g-dev libjpeg-dev gcc build-essential python3-dev curl sudo git libwebp-dev && \
# Clean up
apt-get autoremove -y && \
apt-get clean -y && \
rm -rf /var/lib/apt/lists/*
# ARG USER_UID_NEW=1000
# ARG USER_GID_NEW=$USER_UID_NEW
# ARG USERNAME_NEW=user
WORKDIR /workspace
# # Add a new non-root user
# RUN groupadd --system --gid $USER_GID_NEW $USERNAME_NEW && \
# useradd --system --uid $USER_UID_NEW --gid $USER_GID_NEW --home /home/$USERNAME_NEW -m $USERNAME_NEW
# RUN chown -R $USER_UID_NEW:root /workspace && \
# chown -R $USER_UID_NEW:root /home/$USERNAME_NEW && \
# echo $USERNAME_NEW ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME_NEW && \
# chmod 0440 /etc/sudoers.d/$USERNAME_NEW
# Set Poetry installation location (i.e. $POETRY_HOME/venv)
ENV POETRY_HOME=/usr/local
# Install Poetry
RUN pip install --upgrade pip setuptools wheel packaging poetry poetry-plugin-export && \
# Install Poetry
# curl -sSL https://install.python-poetry.org | POETRY_HOME=/opt/poetry python && \
# cd /usr/local/bin && \
# ln -s /opt/poetry/bin/poetry && \
poetry config virtualenvs.create false && \
# Clean up
apt-get autoremove -y && \
apt-get clean -y && \
rm -rf /var/lib/apt/lists/*
# Set the user so nobody can run as root on the Docker host (security)
USER $USER_UID_NEW
COPY poetry.lock pyproject.toml ./
# RUN poetry config virtualenvs.create false && \
# poetry install --no-interaction --no-ansi
RUN poetry config virtualenvs.create false && \
# Export the requirements to stdout, and install them in the virtual environment
poetry export --with dev --no-interaction --no-ansi --without-hashes --format requirements.txt \
| pip install -r /dev/stdin --no-cache-dir
# Copy my preferred .bashrc to /root/ so that it's automatically "sourced" when the container starts
COPY .bashrc /root/