-
Notifications
You must be signed in to change notification settings - Fork 115
Expand file tree
/
Copy pathDockerfile
More file actions
67 lines (58 loc) · 3.25 KB
/
Dockerfile
File metadata and controls
67 lines (58 loc) · 3.25 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
# Define the base image dynamically using build argument
ARG DISTRO=ubuntu:latest
FROM ${DISTRO} AS base
# Install dependencies based on the distribution
RUN \
# For Debian/Ubuntu
if [ -f /etc/debian_version ]; then \
apt-get update && \
apt-get install -y python3 python3-pip python3-dev build-essential clang libclang-rt-dev git flake8 pylint python3-pytest python3-pexpect python3-setuptools python3-pyparsing vim procps sudo && \
apt-get clean; \
groupadd -f testuser; \
useradd -m -d /home/testuser -s /bin/bash -g testuser testuser; \
echo 'root:password' | chpasswd; \
echo 'testuser:password' | chpasswd; \
echo 'testuser ALL=(ALL:ALL) ALL' > /etc/sudoers.d/testuser && chmod 0440 /etc/sudoers.d/testuser; \
# For Fedora
elif [ -f /etc/fedora-release ]; then \
dnf install -y python3 python3-pip python3-pytest git flake8 pylint python3-pexpect python3-setuptools python3-pyparsing vim sudo; \
groupadd -f testuser; \
useradd -m -d /home/testuser -s /bin/bash -g testuser testuser; \
echo 'root:password' | chpasswd; \
echo 'testuser:password' | chpasswd; \
echo 'testuser ALL=(ALL:ALL) ALL' > /etc/sudoers.d/testuser && chmod 0440 /etc/sudoers.d/testuser; \
# For CentOS
elif [ -f /etc/centos-release ]; then \
# Update CentOS repository to use vault.centos.org
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* && \
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-* && \
yum install -y python3 python3-pip python3-pytest git vim sudo && \
yum install -y python3-devel gcc && \
python3 -m pip install flake8 pylint pexpect setuptools pyparsing; \
yum clean all; \
groupadd -f testuser; \
useradd -m -d /home/testuser -s /bin/bash -g testuser testuser; \
echo 'root:password' | chpasswd; \
echo 'testuser:password' | chpasswd; \
echo 'testuser ALL=(ALL:ALL) ALL' > /etc/sudoers.d/testuser && chmod 0440 /etc/sudoers.d/testuser; \
fi
# Set permissions for the user to access /app
RUN mkdir /home/testuser/lshell && chown -R testuser:testuser /home/testuser/lshell
# Set working directory to /home/testuser
WORKDIR /home/testuser/lshell
# Set PYTHONPATH to the current working directory
ENV PYTHONPATH=/home/testuser/lshell
# Copy the code and requirements
COPY . /home/testuser/lshell
# Install test/runtime Python dependencies from the repository requirements.
# Debian/Ubuntu images may require --break-system-packages (PEP 668).
RUN python3 -m pip install --no-cache-dir -r /home/testuser/lshell/requirements.txt \
|| python3 -m pip install --break-system-packages --no-cache-dir -r /home/testuser/lshell/requirements.txt
# Install lshell from source via PEP 517/pyproject.toml.
# Debian/Ubuntu images may require --break-system-packages (PEP 668).
RUN python3 -m pip install --no-cache-dir --no-deps --no-build-isolation /home/testuser/lshell \
|| python3 -m pip install --break-system-packages --no-cache-dir --no-deps --no-build-isolation /home/testuser/lshell
# Switch to `testuser`
USER testuser
# Entry point for interactive lshell (overridden in Docker Compose for tests)
CMD ["lshell"]