-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathDockerfile
More file actions
60 lines (43 loc) · 1.65 KB
/
Dockerfile
File metadata and controls
60 lines (43 loc) · 1.65 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
# To build a production image:
# docker build -t <image_name> --target production .
#
# To build a development image:
# docker build -t <image_name> --target development --build-arg USERNAME=$(whoami) --build-arg USER_UID=$(id -u) --build-arg USER_GID=$(id -g) .
ARG FROM_IMAGE_NAME=nvcr.io/nvidia/pytorch:24.10-py3
FROM ${FROM_IMAGE_NAME} AS base
ENV CUDA_HOME=/usr/local/cuda
ENV PATH=$CUDA_HOME/bin:$PATH
ENV LD_LIBRARY_PATH=$CUDA_HOME/lib64:$LD_LIBRARY_PATH
WORKDIR /workspace/
# Copy requirements first for better layer caching
COPY ./requirements.txt .
# Install dependencies
RUN pip install -r requirements.txt \
&& apt-get update \
&& apt-get install -y libsndfile1 ffmpeg \
&& pip install -U flash-attn
# ----------------- Production Stage -----------------
FROM base AS production
WORKDIR /workspace/
COPY . .
# Add a CMD for production if you have a main script to run
# e.g., CMD ["python", "app.py"]
# ----------------- Development Stage -----------------
FROM base AS development
WORKDIR /workspace/
# Install development specific packages
RUN apt-get update && apt-get install -y htop
# Create a non-root user for development
ARG USERNAME
ARG USER_UID
ARG USER_GID
# Ensure build arguments are provided for development builds
RUN if [ -z "$USERNAME" ] || [ -z "$USER_UID" ] || [ -z "$USER_GID" ]; then \
echo "Error: For development builds, you must provide USERNAME, USER_UID, and USER_GID build arguments." >&2; \
exit 1; \
fi
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd -l --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& chown -R $USERNAME:$USERNAME /workspace
# Switch to the non-root user
USER $USERNAME