github-actions[bot] commited on
Commit
c3f412e
·
0 Parent(s):

Auto deploy Tools

Browse files
Files changed (5) hide show
  1. .gitattributes +1 -0
  2. Dockerfile +63 -0
  3. README.md +9 -0
  4. setup.sh +3 -0
  5. start.sh +45 -0
.gitattributes ADDED
@@ -0,0 +1 @@
 
 
1
+ * text=auto
Dockerfile ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11-slim
2
+
3
+ # -----------------------
4
+ # System deps
5
+ # -----------------------
6
+ WORKDIR /app
7
+
8
+ RUN apt-get update && apt-get install -y \
9
+ curl \
10
+ gnupg \
11
+ git \
12
+ libgl1 \
13
+ libglib2.0-0 \
14
+ && curl -sL https://deb.nodesource.com/setup_20.x | bash - \
15
+ && apt-get install -y nodejs \
16
+ && apt-get clean \
17
+ && rm -rf /var/lib/apt/lists/*
18
+
19
+ # -----------------------
20
+ # Install gh CLI
21
+ # -----------------------
22
+ RUN mkdir -p -m 755 /etc/apt/keyrings \
23
+ && curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/etc/apt/keyrings/githubcli-archive-keyring.gpg \
24
+ && chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
25
+ && echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
26
+ && apt-get update \
27
+ && apt-get install -y gh \
28
+ && apt-get clean \
29
+ && rm -rf /var/lib/apt/lists/*
30
+
31
+ # -----------------------
32
+ # Git stability fixes (CRITICAL)
33
+ # -----------------------
34
+ RUN git config --global http.version HTTP/1.1 \
35
+ && git config --global core.compression 0
36
+
37
+ # -----------------------
38
+ # Create HF user
39
+ # -----------------------
40
+ RUN useradd -m -u 1000 user
41
+ USER user
42
+ ENV PATH="/home/user/.local/bin:$PATH"
43
+
44
+ # -----------------------
45
+ # App code
46
+ # -----------------------
47
+ WORKDIR /home/user/app
48
+ COPY --chown=user . .
49
+
50
+ # -----------------------
51
+ # Frontend build
52
+ # -----------------------
53
+ WORKDIR /home/user/app
54
+ RUN chmod +x ./start.sh
55
+
56
+ WORKDIR /home/user/app
57
+
58
+ # -----------------------
59
+ # Runtime
60
+ # -----------------------
61
+ EXPOSE 7860
62
+
63
+ CMD ["./start.sh"]
README.md ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Tools
3
+ emoji: 🔗
4
+ colorFrom: blue
5
+ colorTo: green
6
+ sdk: docker
7
+ pinned: false
8
+ app_port: 7860
9
+ ---
setup.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/bin/bash
2
+ export SERVICE_NAME=Tools
3
+ export APP_MODULE=services.app:app
start.sh ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ set -e
3
+
4
+ if [ -f "./setup.sh" ]; then
5
+ source ./setup.sh
6
+ fi
7
+
8
+ BRANCH="feature/video-revamp"
9
+
10
+ if [ -z "${GITHUB_TOKEN}" ]; then
11
+ echo "ERROR: GITHUB_TOKEN is not set"
12
+ exit 1
13
+ fi
14
+
15
+ echo "Starting ${SERVICE_NAME}..."
16
+
17
+ REPO_URL="https://${GITHUB_TOKEN}@github.com/ElvoroLtd/Elvoro.git"
18
+
19
+ # Backup ephemeral files that we want to preserve
20
+ if [ -f "links.csv" ]; then cp links.csv /tmp/links.csv.bak; fi
21
+ if [ -f "stats.csv" ]; then cp stats.csv /tmp/stats.csv.bak; fi
22
+
23
+ if [ ! -d ".git" ]; then
24
+ echo "Cloning repo..."
25
+ git clone --single-branch --branch "${BRANCH}" "${REPO_URL}" /tmp/repo
26
+ cp -rf /tmp/repo/. .
27
+ rm -rf /tmp/repo
28
+ else
29
+ echo "Updating repo..."
30
+ git remote set-url origin "${REPO_URL}"
31
+ git fetch origin "${BRANCH}"
32
+ git reset --hard FETCH_HEAD
33
+ fi
34
+
35
+ # Restore preserved files
36
+ if [ -f "/tmp/links.csv.bak" ]; then mv /tmp/links.csv.bak links.csv; fi
37
+ if [ -f "/tmp/stats.csv.bak" ]; then mv /tmp/stats.csv.bak stats.csv; fi
38
+
39
+ pip install --no-cache-dir -e .
40
+
41
+ if [ -f "./scripts/build.sh" ]; then
42
+ source ./scripts/build.sh
43
+ fi
44
+
45
+ exec uvicorn "${APP_MODULE}" --host 0.0.0.0 --port 7860