Skip to content

Commit 58bc371

Browse files
authored
Merge pull request #13 from John-Appleseed/main
COPY --chown to reduce docker build time and image storage size
2 parents e20c4ea + c3a3d86 commit 58bc371

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

‎Dockerfile‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ RUN echo "Building DeepSpeed with flags: DS_BUILD_TRANSFORMER=${DS_BUILD_TRANSFO
5151
|| (echo "DeepSpeed install failed. Check build logs above." && exit 1)
5252

5353
# Copy requirements file first to leverage Docker cache
54-
COPY requirements.txt .
54+
COPY --chown=1001:1001 requirements.txt .
5555

5656
# Install remaining Python dependencies from requirements.txt
5757
RUN pip install --no-cache-dir --prefer-binary -r requirements.txt \
@@ -61,7 +61,7 @@ RUN pip install --no-cache-dir --prefer-binary -r requirements.txt \
6161
RUN pip install --no-cache-dir "ctranslate2<4.5.0"
6262

6363
# Copy the application code
64-
COPY code/ ./code/
64+
COPY --chown=1001:1001 code/ ./code/
6565

6666
# --- Stage 2: Runtime Stage ---
6767
# Base image still needs CUDA toolkit for PyTorch/DeepSpeed/etc in the app
@@ -97,10 +97,10 @@ WORKDIR /app/code
9797

9898
# Copy installed Python packages from the builder stage
9999
RUN mkdir -p /usr/local/lib/python3.10/dist-packages
100-
COPY --from=builder /usr/local/lib/python3.10/dist-packages /usr/local/lib/python3.10/dist-packages
100+
COPY --chown=1001:1001 --from=builder /usr/local/lib/python3.10/dist-packages /usr/local/lib/python3.10/dist-packages
101101

102102
# Copy the application code from the builder stage
103-
COPY --from=builder /app/code /app/code
103+
COPY --chown=1001:1001 --from=builder /app/code /app/code
104104

105105
# <<<--- Keep other model pre-downloads --->>>
106106
# <<<--- Silero VAD Pre-download --->>>
@@ -154,13 +154,12 @@ RUN groupadd --gid 1001 appgroup && \
154154
# The entrypoint will handle runtime permissions for volumes/cache
155155
RUN mkdir -p /home/appuser/.cache && \
156156
chown -R appuser:appgroup /app && \
157-
chown -R appuser:appgroup /usr/local/lib/python3.10/dist-packages && \
158157
chown -R appuser:appgroup /home/appuser && \
159158
# Also chown the caches potentially populated by root during build
160159
if [ -d /root/.cache ]; then chown -R appuser:appgroup /root/.cache; fi
161160

162161
# Copy and set permissions for entrypoint script
163-
COPY entrypoint.sh /entrypoint.sh
162+
COPY --chown=1001:1001 entrypoint.sh /entrypoint.sh
164163
RUN chmod +x /entrypoint.sh
165164

166165
# --- REMOVED USER appuser --- The container will start as root.
@@ -190,4 +189,4 @@ EXPOSE 8000
190189
# Set the entrypoint script - This runs as root
191190
ENTRYPOINT ["/entrypoint.sh"]
192191
# Define the default command - This is passed as "$@" to the entrypoint script
193-
CMD ["python", "-m", "uvicorn", "server:app", "--host", "0.0.0.0", "--port", "8000"]
192+
CMD ["python", "-m", "uvicorn", "server:app", "--host", "0.0.0.0", "--port", "8000"]

0 commit comments

Comments
 (0)