-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
52 lines (39 loc) · 1.24 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
#####################
# 1 STAGE - BUILDER #
#####################
# Pull official Python image
FROM python:3.11.6-slim AS builder
# Set work directory
WORKDIR /code
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
# Install PDM
RUN pip install pdm==2.10.0
# Copy PDM files and install project dependencies
COPY pyproject.toml pdm.lock ./
RUN pdm sync -p . --global --dev
###################
# 2 STAGE - FINAL #
###################
# Pull NVIDIA CUDA runtime image
FROM nvidia/cuda:12.2.2-cudnn8-runtime-ubuntu22.04 AS final
# Set work directory
WORKDIR /home/app
# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive \
ENVIRONMENT=dev \
TESTING=0
# Create the app user and install system dependencies
RUN addgroup --system app && \
adduser --system --group app && \
echo "deb http://archive.ubuntu.com/ubuntu/ mantic main multiverse" >> /etc/apt/sources.list && \
apt-get update && \
apt-get install -y --no-install-recommends libcupti12=12.0.* && \
rm -rf /var/lib/apt/lists/*
# Copy packages and executables from the builder stage
COPY --from=builder /usr/local /usr/local
# Add app and chown all the files to the app user
COPY --chown=app:app . .
# Change to the app user
USER app