-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.dev
More file actions
85 lines (71 loc) · 2.55 KB
/
Copy pathDockerfile.dev
File metadata and controls
85 lines (71 loc) · 2.55 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
83
84
85
# Use Red Hat Universal Base Image 8 as base image
FROM registry.access.redhat.com/ubi8/ubi:latest
# Add HashiCorp and Kubernetes repositories
RUN microdnf install -y dnf-plugins-core && \
microdnf config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
COPY kubernetes.repo /etc/yum.repos.d/kubernetes.repo
# Install development tools and required packages
RUN microdnf update -y && \
microdnf install -y \
gcc \
gcc-c++ \
git \
curl \
wget \
make \
zlib-devel \
bzip2-devel \
openssl-devel \
libffi-devel \
vault-agent \
kubectl \
shadow-utils \
&& microdnf clean all \
&& rm -rf /var/cache/yum/*
# Install Python 3.12 from source
RUN curl -O https://www.python.org/ftp/python/3.12.1/Python-3.12.1.tgz && \
tar -xzf Python-3.12.1.tgz && \
cd Python-3.12.1 && \
./configure --enable-optimizations && \
make altinstall && \
cd .. && \
rm -rf Python-3.12.1* && \
ln -sf /usr/local/bin/python3.12 /usr/local/bin/python3 && \
ln -sf /usr/local/bin/python3 /usr/local/bin/python && \
ln -sf /usr/local/bin/pip3.12 /usr/local/bin/pip3 && \
ln -sf /usr/local/bin/pip3 /usr/local/bin/pip
# Install Helm
RUN curl -fsSL https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
# Create non-root user
RUN useradd -m -d /src -s /bin/bash developer && \
chown -R developer:developer /src
# Set the working directory in the container
WORKDIR /src
# Create required directories
RUN mkdir -p /src/logs /src/config /src/utils /src/tests /src/docs /src/tmp /src/cache && \
chown -R developer:developer /src/logs /src/config /src/utils /src/tests /src/docs /src/tmp /src/cache
# Copy requirements files
COPY requirements*.txt ./
RUN chown developer:developer requirements*.txt
# Copy the application code
COPY . .
RUN chown -R developer:developer .
# Switch to non-root user
USER developer
# Install dependencies
RUN python -m pip install --upgrade pip setuptools wheel && \
python -m pip install --no-cache-dir --user -r requirements.txt && \
if [ -f requirements-dev.txt ]; then \
python -m pip install --no-cache-dir --user -r requirements-dev.txt; \
fi
# Set environment variables
ENV PYTHONPATH=/src
ENV PYTHONUNBUFFERED=1
ENV PATH="/src/.local/bin:/usr/local/bin:${PATH}"
ENV HOME=/src
ENV LANG=C.UTF-8
ENV LC_ALL=C.UTF-8
# Create volume mount points for logs, config, tmp, and cache
VOLUME ["/src/logs", "/src/config", "/src/tmp", "/src/cache"]
# Default command for development (can be overridden)
CMD ["python", "-m", "pytest"]