-
-
Notifications
You must be signed in to change notification settings - Fork 25
/
Dockerfile
43 lines (33 loc) · 1.31 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
# Use an official PyTorch image with CUDA 11.8 as the base image
FROM pytorch/pytorch:2.3.0-cuda12.1-cudnn8-runtime
# Create a user to run the app (for better security)
RUN useradd -ms /bin/bash appuser
# Set the working directory in the container
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
gcc \
g++ \
redis \
libgl1-mesa-glx \
libglib2.0-0 \
tzdata \
&& rm -rf /var/lib/apt/lists/*
# Set the timezone to Asia/Taipei
ENV TZ=Asia/Taipei
# Install any needed packages specified in requirements.txt
# Note: Copy only requirements.txt first to leverage Docker cache
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
# Copy the current directory contents into the container at /app
# Use --chown to change the ownership of the copied files to the non-root user
COPY --chown=appuser:appuser . /app
# Copy the init script into the container
COPY scripts/init_db.sh /docker-entrypoint-initdb.d/
# Switch to non-root user for better security
USER appuser
# Expose the ports used by the Gunicorn servers
EXPOSE 8000 8001
# The CMD directive is used to run the script.
# Since we are using docker-compose to override this command, it can be left blank or set as a placeholder.
CMD ["echo", "Please use docker-compose to run this container."]