Spaces:
Running
on
Zero
Running
on
Zero
Dockerfile
Browse files- Dockerfile +22 -17
Dockerfile
CHANGED
@@ -1,40 +1,45 @@
|
|
1 |
# CUDA 12.1ベースのUbuntuイメージを使用
|
2 |
FROM nvidia/cuda:12.1.0-cudnn8-devel-ubuntu20.04
|
3 |
|
4 |
-
|
|
|
|
|
5 |
|
6 |
-
#
|
7 |
-
RUN apt-get update && apt-get install -y \
|
8 |
software-properties-common \
|
|
|
|
|
9 |
&& add-apt-repository ppa:deadsnakes/ppa \
|
10 |
-
&& apt-get update && apt-get install -y \
|
11 |
python3.10 \
|
12 |
python3.10-dev \
|
13 |
python3.10-distutils \
|
14 |
-
|
|
|
15 |
&& rm -rf /var/lib/apt/lists/*
|
16 |
-
|
|
|
17 |
RUN wget https://bootstrap.pypa.io/get-pip.py \
|
18 |
&& python3.10 get-pip.py \
|
19 |
-
&& rm get-pip.py
|
20 |
-
|
21 |
-
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.10 1 \
|
22 |
&& update-alternatives --install /usr/bin/pip pip /usr/local/bin/pip3.10 1
|
23 |
|
24 |
WORKDIR /app
|
25 |
|
26 |
-
RUN useradd -m -u 1000 user
|
27 |
-
USER user
|
28 |
-
|
29 |
# 依存関係をインストール
|
30 |
COPY requirements.txt /app/
|
31 |
-
RUN
|
32 |
-
|
33 |
-
apt-get clean && \
|
34 |
-
rm -rf /var/lib/apt/lists/*
|
35 |
|
|
|
36 |
COPY . /app
|
37 |
|
|
|
|
|
|
|
|
|
38 |
EXPOSE 80
|
39 |
|
40 |
-
CMD ["python", "app.py", "--use_gpu"]
|
|
|
1 |
# CUDA 12.1ベースのUbuntuイメージを使用
|
2 |
FROM nvidia/cuda:12.1.0-cudnn8-devel-ubuntu20.04
|
3 |
|
4 |
+
# 環境変数の設定
|
5 |
+
ENV DEBIAN_FRONTEND=noninteractive
|
6 |
+
ENV TZ=Asia/Tokyo
|
7 |
|
8 |
+
# システムの更新とPython 3.10のインストール
|
9 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
10 |
software-properties-common \
|
11 |
+
wget \
|
12 |
+
libopencv-dev \
|
13 |
&& add-apt-repository ppa:deadsnakes/ppa \
|
14 |
+
&& apt-get update && apt-get install -y --no-install-recommends \
|
15 |
python3.10 \
|
16 |
python3.10-dev \
|
17 |
python3.10-distutils \
|
18 |
+
&& ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime \
|
19 |
+
&& apt-get clean \
|
20 |
&& rm -rf /var/lib/apt/lists/*
|
21 |
+
|
22 |
+
# pipのインストールとPythonのセットアップ
|
23 |
RUN wget https://bootstrap.pypa.io/get-pip.py \
|
24 |
&& python3.10 get-pip.py \
|
25 |
+
&& rm get-pip.py \
|
26 |
+
&& update-alternatives --install /usr/bin/python python /usr/bin/python3.10 1 \
|
|
|
27 |
&& update-alternatives --install /usr/bin/pip pip /usr/local/bin/pip3.10 1
|
28 |
|
29 |
WORKDIR /app
|
30 |
|
|
|
|
|
|
|
31 |
# 依存関係をインストール
|
32 |
COPY requirements.txt /app/
|
33 |
+
RUN pip install --no-cache-dir -r requirements.txt \
|
34 |
+
&& pip install --no-cache-dir --no-dependencies transformers
|
|
|
|
|
35 |
|
36 |
+
# アプリケーションのコピー
|
37 |
COPY . /app
|
38 |
|
39 |
+
# 非rootユーザーの作成と切り替え
|
40 |
+
RUN useradd -m appuser && chown -R appuser:appuser /app
|
41 |
+
USER appuser
|
42 |
+
|
43 |
EXPOSE 80
|
44 |
|
45 |
+
CMD ["python", "app.py", "--use_gpu"]
|