Spaces:
Running
Running
add dockerfile, deploy gh actions
Browse files- .github/workflows/hf_deploy.yml +31 -0
- .github/workflows/ping_hf.yml +20 -0
- Dockerfile +24 -0
.github/workflows/hf_deploy.yml
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Deploy to Hugging Face Spaces
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
push:
|
| 5 |
+
branches:
|
| 6 |
+
- main
|
| 7 |
+
workflow_dispatch:
|
| 8 |
+
|
| 9 |
+
jobs:
|
| 10 |
+
deploy:
|
| 11 |
+
runs-on: ubuntu-latest
|
| 12 |
+
steps:
|
| 13 |
+
- name: Checkout code
|
| 14 |
+
uses: actions/checkout@v4
|
| 15 |
+
with:
|
| 16 |
+
fetch-depth: 0
|
| 17 |
+
|
| 18 |
+
- name: Push to Hugging Face Spaces
|
| 19 |
+
env:
|
| 20 |
+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 21 |
+
HF_SPACE_URL: "https://huggingface.co/spaces/yezdata/EmCoder_API_UI"
|
| 22 |
+
run: |
|
| 23 |
+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
| 24 |
+
git config --global user.name "github-actions[bot]"
|
| 25 |
+
|
| 26 |
+
AUTHENTICATED_URL=$(echo "$HF_SPACE_URL" | sed "s|https://|https://yezdata:$HF_TOKEN@|")
|
| 27 |
+
|
| 28 |
+
git remote add hf "$AUTHENTICATED_URL"
|
| 29 |
+
|
| 30 |
+
echo "Pushing code to Hugging Face Spaces..."
|
| 31 |
+
git push --force hf main:main
|
.github/workflows/ping_hf.yml
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: HF Space Ping - EmCoder API & UI
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
schedule:
|
| 5 |
+
- cron: '0 0 * * *'
|
| 6 |
+
workflow_dispatch:
|
| 7 |
+
|
| 8 |
+
jobs:
|
| 9 |
+
ping:
|
| 10 |
+
runs-on: ubuntu-latest
|
| 11 |
+
steps:
|
| 12 |
+
- name: Wake up EmCoder Model API
|
| 13 |
+
run: |
|
| 14 |
+
STATUS=$(curl -L -s -o /dev/null -w "%{http_code}" \
|
| 15 |
+
--retry 5 \
|
| 16 |
+
--retry-delay 15 \
|
| 17 |
+
--retry-all-errors \
|
| 18 |
+
"https://yezdata-EmCoder_API_UI.hf.space/health")
|
| 19 |
+
echo "EmCoder Status: $STATUS"
|
| 20 |
+
if [ "$STATUS" -ne 200 ]; then exit 1; fi
|
Dockerfile
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.11-slim
|
| 2 |
+
|
| 3 |
+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
|
| 4 |
+
|
| 5 |
+
WORKDIR /code
|
| 6 |
+
|
| 7 |
+
RUN apt-get update && apt-get install -y curl git && rm -rf /var/lib/apt/lists/*
|
| 8 |
+
|
| 9 |
+
RUN useradd -m -u 1000 user
|
| 10 |
+
USER user
|
| 11 |
+
ENV HOME=/home/user \
|
| 12 |
+
PATH=/home/user/.local/bin:$PATH
|
| 13 |
+
|
| 14 |
+
WORKDIR $HOME/app
|
| 15 |
+
|
| 16 |
+
COPY --chown=user pyproject.toml uv.lock ./
|
| 17 |
+
|
| 18 |
+
RUN uv sync --frozen --system --no-cache
|
| 19 |
+
|
| 20 |
+
COPY --chown=user . $HOME/app
|
| 21 |
+
|
| 22 |
+
EXPOSE 7860
|
| 23 |
+
|
| 24 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|