Spaces:
Sleeping
Sleeping
Commit ·
9317a2b
0
Parent(s):
Production release: compile secure streamlined interface platform
Browse files- .dockerignore +6 -0
- .github/workflows/deploy.yml +58 -0
- .gitignore +6 -0
- Dockerfile +39 -0
- README.md +13 -0
- app.py +20 -0
- requirements.txt +1 -0
- start.sh +18 -0
.dockerignore
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.git
|
| 2 |
+
.github
|
| 3 |
+
Dockerfile
|
| 4 |
+
.dockerignore
|
| 5 |
+
.gitignore
|
| 6 |
+
README.md
|
.github/workflows/deploy.yml
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Sync to Hugging Face Hub
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
push:
|
| 5 |
+
branches: [main]
|
| 6 |
+
workflow_dispatch:
|
| 7 |
+
|
| 8 |
+
jobs:
|
| 9 |
+
deploy:
|
| 10 |
+
runs-on: ubuntu-latest
|
| 11 |
+
steps:
|
| 12 |
+
- name: Checkout Code Architecture
|
| 13 |
+
uses: actions/checkout@v4
|
| 14 |
+
with:
|
| 15 |
+
fetch-depth: 0
|
| 16 |
+
lfs: true
|
| 17 |
+
|
| 18 |
+
- name: Initialize Deployment Pipeline
|
| 19 |
+
env:
|
| 20 |
+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 21 |
+
run: |
|
| 22 |
+
set -euo pipefail
|
| 23 |
+
git config --global user.email "shahzain4455.com@gmail.com"
|
| 24 |
+
git config --global user.name "shahzaibkhan7788"
|
| 25 |
+
|
| 26 |
+
TMPDIR=$(mktemp -d)
|
| 27 |
+
git archive --format=tar HEAD | tar -x -C "$TMPDIR"
|
| 28 |
+
cd "$TMPDIR"
|
| 29 |
+
|
| 30 |
+
git init
|
| 31 |
+
git checkout -b main
|
| 32 |
+
git add .
|
| 33 |
+
git commit -m "Production release: compile secure streamlined interface platform"
|
| 34 |
+
|
| 35 |
+
sudo apt-get update && sudo apt-get install -y git-lfs
|
| 36 |
+
git lfs install --skip-repo
|
| 37 |
+
|
| 38 |
+
REMOTE_URL="https://shahzaib7788:${HF_TOKEN}@huggingface.co/spaces/shahzaib7788/streamlit_interface.git"
|
| 39 |
+
git remote add hf "$REMOTE_URL"
|
| 40 |
+
|
| 41 |
+
MAX_ATTEMPTS=5
|
| 42 |
+
for attempt in $(seq 1 $MAX_ATTEMPTS); do
|
| 43 |
+
echo "[PUSH] Deploy attempt $attempt of $MAX_ATTEMPTS..."
|
| 44 |
+
if git push --force hf main; then
|
| 45 |
+
echo "[PUSH] Deployment complete!"
|
| 46 |
+
break
|
| 47 |
+
else
|
| 48 |
+
rc=$?
|
| 49 |
+
echo "[PUSH] Caught transmission roadblock. Retrying tracking streams..."
|
| 50 |
+
if [ $attempt -lt $MAX_ATTEMPTS ]; then
|
| 51 |
+
sleep_time=$((attempt * 15))
|
| 52 |
+
sleep $sleep_time
|
| 53 |
+
else
|
| 54 |
+
echo "[PUSH] Deployment failed due to continuous network constraints." >&2
|
| 55 |
+
exit $rc
|
| 56 |
+
fi
|
| 57 |
+
fi
|
| 58 |
+
done
|
.gitignore
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.streamlit/config.toml
|
| 2 |
+
__pycache__/
|
| 3 |
+
*.pyc
|
| 4 |
+
.env
|
| 5 |
+
.venv/
|
| 6 |
+
venv/
|
Dockerfile
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.10-slim
|
| 2 |
+
|
| 3 |
+
WORKDIR /app
|
| 4 |
+
|
| 5 |
+
ENV DEBIAN_FRONTEND=noninteractive
|
| 6 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 7 |
+
build-essential \
|
| 8 |
+
curl \
|
| 9 |
+
ca-certificates \
|
| 10 |
+
git \
|
| 11 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 12 |
+
|
| 13 |
+
# Create a non-root user (we'll switch to it at runtime)
|
| 14 |
+
RUN useradd -m -u 1000 user
|
| 15 |
+
|
| 16 |
+
# Copy app files and install dependencies as root to avoid permission problems
|
| 17 |
+
COPY requirements.txt ./
|
| 18 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 19 |
+
|
| 20 |
+
COPY . /app
|
| 21 |
+
RUN chown -R user:user /app
|
| 22 |
+
COPY start.sh /app/start.sh
|
| 23 |
+
RUN chown user:user /app/start.sh && chmod +x /app/start.sh
|
| 24 |
+
|
| 25 |
+
ENV HOME=/home/user \
|
| 26 |
+
PATH=/home/user/.local/bin:$PATH
|
| 27 |
+
|
| 28 |
+
USER user
|
| 29 |
+
WORKDIR /app
|
| 30 |
+
|
| 31 |
+
EXPOSE 7860
|
| 32 |
+
|
| 33 |
+
# Use PORT env var if provided by the platform, otherwise default to 7860
|
| 34 |
+
HEALTHCHECK CMD curl --fail http://localhost:${PORT:-7860}/_stcore/health || exit 1
|
| 35 |
+
|
| 36 |
+
# Use launcher so logs include environment and file listing for debugging
|
| 37 |
+
USER user
|
| 38 |
+
WORKDIR /app
|
| 39 |
+
CMD ["./start.sh"]
|
README.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Test Space
|
| 3 |
+
emoji: ⚡
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: green
|
| 6 |
+
sdk: docker
|
| 7 |
+
app_port: 7860
|
| 8 |
+
pinned: false
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
# Isolated Streamlit Space Test
|
| 12 |
+
|
| 13 |
+
This repository contains a clean, isolated Streamlit deployment running inside a custom Docker container. It automatically syncs from GitHub via GitHub Actions.
|
app.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import os
|
| 3 |
+
import sys
|
| 4 |
+
|
| 5 |
+
st.set_page_config(page_title="Pristine Space Isolation Test", page_icon="⚡", layout="wide")
|
| 6 |
+
|
| 7 |
+
st.title("⚡ Pristine Isolated Streamlit Deployment")
|
| 8 |
+
st.write("If you see this interface, your GitHub Actions, Docker binding layer, and network proxy routing are synchronized perfectly!")
|
| 9 |
+
|
| 10 |
+
st.markdown("---")
|
| 11 |
+
st.subheader("System Diagnostic Environment Snapshots")
|
| 12 |
+
|
| 13 |
+
col1, col2 = st.columns(2)
|
| 14 |
+
with col1:
|
| 15 |
+
st.info("📂 Working Files Layout")
|
| 16 |
+
st.json({"Current Directory": os.getcwd(), "Root File Array": os.listdir('.')})
|
| 17 |
+
|
| 18 |
+
with col2:
|
| 19 |
+
st.success("🌐 Network Bind Layer Status")
|
| 20 |
+
st.json({"Target Exposed Port": os.environ.get("PORT", "7860"), "Python Runtime System": sys.version})
|
requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
streamlit>=1.35.0
|
start.sh
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
set -euo pipefail
|
| 3 |
+
echo "==== start.sh: container startup ===="
|
| 4 |
+
date
|
| 5 |
+
echo "Working dir: $(pwd)"
|
| 6 |
+
echo "User: $(whoami)"
|
| 7 |
+
echo "PORT=${PORT:-not-set}"
|
| 8 |
+
echo "Listing /app contents:"
|
| 9 |
+
ls -la /app || true
|
| 10 |
+
echo "Contents of app directory (top):"
|
| 11 |
+
ls -la . || true
|
| 12 |
+
echo "Starting Streamlit with port ${PORT:-7860}"
|
| 13 |
+
exec streamlit run app.py \
|
| 14 |
+
--server.address=0.0.0.0 \
|
| 15 |
+
--server.port=${PORT:-7860} \
|
| 16 |
+
--server.headless=true \
|
| 17 |
+
--server.enableCORS=false \
|
| 18 |
+
--server.enableXsrfProtection=false
|