generated from ministryofjustice/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
116 lines (87 loc) · 3.67 KB
/
Dockerfile
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#checkov:skip=CKV_DOCKER_2: HEALTHCHECK not required - Health checks are implemented downstream of this image
FROM public.ecr.aws/ubuntu/ubuntu@sha256:da20fb875cfefd317c49e7aaf3998d3e5ad42c5b20f34a0eec6dca2fe4fbb8f4
LABEL org.opencontainers.image.vendor="Ministry of Justice" \
org.opencontainers.image.authors="Analytical Platform ([email protected])" \
org.opencontainers.image.title="Airflow Python Base" \
org.opencontainers.image.description="Airflow Python base image for Analytical Platform" \
org.opencontainers.image.url="https://github.com/ministryofjustice/analytical-platform-airflow-python-base"
ENV CONTAINER_USER="analyticalplatform" \
CONTAINER_UID="1000" \
CONTAINER_GROUP="analyticalplatform" \
CONTAINER_GID="1000" \
ANALYTICAL_PLATFORM_DIRECTORY="/opt/analyticalplatform" \
DEBIAN_FRONTEND="noninteractive" \
PIP_BREAK_SYSTEM_PACKAGES="1" \
AWS_CLI_VERSION="2.23.3" \
CUDA_VERSION="12.6.3" \
NVIDIA_DISABLE_REQUIRE="true" \
NVIDIA_CUDA_CUDART_VERSION="12.6.77-1" \
NVIDIA_CUDA_COMPAT_VERSION="560.35.05-0ubuntu1" \
NVIDIA_VISIBLE_DEVICES="all" \
NVIDIA_DRIVER_CAPABILITIES="compute,utility" \
LD_LIBRARY_PATH="/usr/local/nvidia/lib:/usr/local/nvidia/lib64" \
PATH="/usr/local/nvidia/bin:/usr/local/cuda/bin:/home/analyticalplatform/.local/bin:${PATH}"
SHELL ["/bin/bash", "-e", "-u", "-o", "pipefail", "-c"]
# User Configuration
RUN <<EOF
userdel --remove --force ubuntu
groupadd \
--gid ${CONTAINER_GID} \
${CONTAINER_GROUP}
useradd \
--uid ${CONTAINER_UID} \
--gid ${CONTAINER_GROUP} \
--create-home \
--shell /bin/bash \
${CONTAINER_USER}
EOF
# Base Configuration
RUN <<EOF
apt-get update --yes
apt-get install --yes \
"apt-transport-https=2.7.14build2" \
"ca-certificates=20240203" \
"curl=8.5.0-2ubuntu10.6" \
"git=1:2.43.0-1ubuntu7.2" \
"jq=1.7.1-3build1" \
"python3.12=3.12.3-1ubuntu0.4" \
"python3-pip=24.0+dfsg-1ubuntu1.1" \
"unzip=6.0-28ubuntu4.1"
apt-get clean --yes
rm --force --recursive /var/lib/apt/lists/*
install --directory --owner "${CONTAINER_USER}" --group "${CONTAINER_GROUP}" --mode 0755 "${ANALYTICAL_PLATFORM_DIRECTORY}"
EOF
# AWS CLI
COPY --chown=nobody:nogroup --chmod=0644 src/opt/aws-cli/[email protected] /opt/aws-cli/[email protected]
RUN <<EOF
gpg --import /opt/aws-cli/[email protected]
curl --location --fail-with-body \
"https://awscli.amazonaws.com/awscli-exe-linux-x86_64-${AWS_CLI_VERSION}.zip.sig" \
--output "awscliv2.sig"
curl --location --fail-with-body \
"https://awscli.amazonaws.com/awscli-exe-linux-x86_64-${AWS_CLI_VERSION}.zip" \
--output "awscliv2.zip"
gpg --verify awscliv2.sig awscliv2.zip
unzip awscliv2.zip
./aws/install
rm --force --recursive awscliv2.sig awscliv2.zip aws
EOF
# NVIDIA CUDA
RUN <<EOF
curl --location --fail-with-body \
"https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/3bf863cc.pub" \
--output "3bf863cc.pub"
cat 3bf863cc.pub | gpg --dearmor --output nvidia.gpg
install -D --owner root --group root --mode 644 nvidia.gpg /etc/apt/keyrings/nvidia.gpg
echo "deb [signed-by=/etc/apt/keyrings/nvidia.gpg] https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64 /" > /etc/apt/sources.list.d/cuda.list
apt-get update --yes
apt-get install --yes \
"cuda-cudart-12-6=${NVIDIA_CUDA_CUDART_VERSION}" \
"cuda-compat-12-6=${NVIDIA_CUDA_COMPAT_VERSION}"
echo "/usr/local/nvidia/lib" >> /etc/ld.so.conf.d/nvidia.conf
echo "/usr/local/nvidia/lib64" >> /etc/ld.so.conf.d/nvidia.conf
apt-get clean --yes
rm --force --recursive /var/lib/apt/lists/* 3bf863cc.pub nvidia.gpg
EOF
USER ${CONTAINER_UID}
WORKDIR ${ANALYTICAL_PLATFORM_DIRECTORY}