Skip to content

Commit eb7a066

Browse files
committed
avoiding container to create root owned files in mapped volumes. also adding a helper run.sh
1 parent 199b179 commit eb7a066

File tree

4 files changed

+31
-12
lines changed

4 files changed

+31
-12
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
hf_download
22
outputs
3+
.aider*

Dockerfile

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
2727
libxrender1 \
2828
libxext6 \
2929
ninja-build \
30-
&& rm -rf /var/lib/apt/lists/*
30+
sudo \
31+
&& rm -rf /var/lib/apt/lists/* \
32+
&& echo "appuser ALL=(ALL) NOPASSWD: /bin/chown" >> /etc/sudoers
3133

3234
# Create and configure directories before switching user
3335
RUN mkdir -p /app && \
@@ -63,19 +65,20 @@ RUN pip install --no-cache-dir \
6365
RUN mkdir -p /app/outputs && \
6466
chown -R $UID:$GID /app/outputs && \
6567
mkdir -p $VIRTUAL_ENV && \
66-
chown -R $UID:$GID $VIRTUAL_ENV
68+
chown -R $UID:$GID $VIRTUAL_ENV && \
69+
mkdir -p /app/hf_download && \
70+
chown -R $UID:$GID /app/hf_download
6771

68-
# Model directory setup
69-
RUN mkdir -p /app/hf_download && \
70-
chmod -R 777 /app/hf_download
72+
# Copy entrypoint script
73+
COPY entrypoint.sh /entrypoint.sh
74+
RUN chmod +x /entrypoint.sh && \
75+
chown $UID:$GID /entrypoint.sh
7176

72-
# Expose output directory
73-
RUN mkdir -p /app/outputs && \
74-
chmod -R 777 /app/outputs
77+
EXPOSE 7860
7578

76-
# Configure directories
79+
# Configure volumes
7780
VOLUME /app/hf_download
7881
VOLUME /app/outputs
7982

80-
EXPOSE 7860
81-
CMD ["python", "demo_gradio.py", "--share"]
83+
ENTRYPOINT ["/entrypoint.sh"]
84+
CMD ["python", "demo_gradio.py", "--share", "--server-name", "0.0.0.0"]

entrypoint.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
#!/bin/bash
22
set -e
33

4+
# Ensure directories have correct ownership
5+
if [ "$(stat -c '%u' /app/outputs)" != "$UID" ]; then
6+
echo "Fixing permissions for /app/outputs"
7+
sudo chown -R $UID:$GID /app/outputs
8+
fi
9+
10+
if [ "$(stat -c '%u' /app/hf_download)" != "$UID" ]; then
11+
echo "Fixing permissions for /app/hf_download"
12+
sudo chown -R $UID:$GID /app/hf_download
13+
fi
14+
415
# Check for required models
516
MODEL_CHECKLIST=(
617
"/app/models/checkpoints/sd_xl_base_1.0.safetensors"
@@ -15,4 +26,4 @@ for model in "${MODEL_CHECKLIST[@]}"; do
1526
fi
1627
done
1728

18-
exec python demo_gradio.py --share --server-name 0.0.0.0
29+
exec "$@"

run.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
docker run -it --rm --gpus all -p 7860:7860 \
2+
-v ./outputs:/app/outputs \
3+
-v ./hf_download:/app/hf_download \
4+
framepack-torch26-cu124:latest

0 commit comments

Comments
 (0)