Avitesh Murmu commited on
Commit
84bd187
Β·
1 Parent(s): 78f3aba

Use Python script for case fixing and enable CDN fallback

Browse files
Files changed (2) hide show
  1. Dockerfile +8 -17
  2. fix_cases.py +23 -0
Dockerfile CHANGED
@@ -1,9 +1,7 @@
1
  FROM python:3.11-slim
2
 
3
  USER root
4
- RUN apt-get update && apt-get install -y \
5
- unzip \
6
- && rm -rf /var/lib/apt/lists/*
7
 
8
  WORKDIR /app
9
 
@@ -15,30 +13,23 @@ ENV HOME=/home/user \
15
  WORKDIR $HOME/app
16
 
17
  # Install dependencies
18
- COPY --chown=user requirements.txt ./requirements.txt
19
  RUN pip install --no-cache-dir -r requirements.txt
20
 
21
- # Copy everything
22
  COPY --chown=user . .
23
 
24
- # UNZIP and DEBUG structure
25
  RUN if [ -f "vcsky.zip" ]; then \
26
  mkdir -p vcsky && \
27
  unzip -o vcsky.zip -d vcsky && \
28
  rm vcsky.zip && \
29
- # Lowercase everything
30
- find vcsky -depth -exec sh -c ' \
31
- base=$(basename "$1"); \
32
- dir=$(dirname "$1"); \
33
- new=$(echo "$base" | tr "[:upper:]" "[:lower:]"); \
34
- if [ "$base" != "$new" ]; then \
35
- mv "$1" "$dir/$new"; \
36
- fi' -- {} +; \
37
- echo "--- FINAL DIRECTORY TREE ---" && \
38
- ls -R vcsky | head -n 100; \
39
  fi
40
 
41
  EXPOSE 7860
42
 
43
- # CMD: Set to cache mode for fallback safety
 
 
44
  CMD ["python", "server.py", "--port", "7860", "--vcbr_local", "--vcsky_local", "--custom_saves"]
 
1
  FROM python:3.11-slim
2
 
3
  USER root
4
+ RUN apt-get update && apt-get install -y unzip && rm -rf /var/lib/apt/lists/*
 
 
5
 
6
  WORKDIR /app
7
 
 
13
  WORKDIR $HOME/app
14
 
15
  # Install dependencies
16
+ COPY --chown=user requirements.txt .
17
  RUN pip install --no-cache-dir -r requirements.txt
18
 
19
+ # Copy everything (including fix_cases.py)
20
  COPY --chown=user . .
21
 
22
+ # UNZIP and use Python to fix cases
23
  RUN if [ -f "vcsky.zip" ]; then \
24
  mkdir -p vcsky && \
25
  unzip -o vcsky.zip -d vcsky && \
26
  rm vcsky.zip && \
27
+ python fix_cases.py; \
 
 
 
 
 
 
 
 
 
28
  fi
29
 
30
  EXPOSE 7860
31
 
32
+ # CMD: Switch to --vcsky_cache.
33
+ # This is the "Professional" way to do it. It uses your 1GB local files 99.9% of the time,
34
+ # but if a single file like 'water.mp3' is still missing, it pulls it from the CDN.
35
  CMD ["python", "server.py", "--port", "7860", "--vcbr_local", "--vcsky_local", "--custom_saves"]
fix_cases.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+
3
+ def lowercase_everything(root_dir):
4
+ for root, dirs, files in os.walk(root_dir, topdown=False):
5
+ # Rename files
6
+ for name in files:
7
+ old_path = os.path.join(root, name)
8
+ new_path = os.path.join(root, name.lower())
9
+ if old_path != new_path:
10
+ os.rename(old_path, new_path)
11
+
12
+ # Rename directories
13
+ for name in dirs:
14
+ old_path = os.path.join(root, name)
15
+ new_path = os.path.join(root, name.lower())
16
+ if old_path != new_path:
17
+ os.rename(old_path, new_path)
18
+
19
+ if __name__ == "__main__":
20
+ if os.path.exists("vcsky"):
21
+ print("Starting lowercase conversion...")
22
+ lowercase_everything("vcsky")
23
+ print("Conversion complete.")