Spaces:
Paused
Paused
Timothy S. Phan commited on
Commit ·
4fac651
1
Parent(s): dcc81ee
Label Studio with S3 backup and signup disabled
Browse files- Dockerfile +15 -13
- entrypoint.sh +6 -8
Dockerfile
CHANGED
|
@@ -1,17 +1,19 @@
|
|
| 1 |
-
FROM heartexlabs/label-studio
|
| 2 |
|
|
|
|
| 3 |
USER root
|
| 4 |
|
| 5 |
RUN apt-get update && \
|
| 6 |
-
apt-get install -y --no-install-recommends \
|
| 7 |
-
curl \
|
| 8 |
-
unzip \
|
| 9 |
-
sqlite3 && \
|
| 10 |
# AWS CLI v2
|
| 11 |
curl -Lo /tmp/awscliv2.zip https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip && \
|
| 12 |
unzip -q /tmp/awscliv2.zip -d /tmp && \
|
| 13 |
/tmp/aws/install && \
|
| 14 |
rm -rf /tmp/aws /tmp/awscliv2.zip && \
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
apt-get clean && \
|
| 16 |
rm -rf /var/lib/apt/lists/*
|
| 17 |
|
|
@@ -19,16 +21,16 @@ RUN apt-get update && \
|
|
| 19 |
COPY entrypoint.sh /entrypoint.sh
|
| 20 |
RUN chmod +x /entrypoint.sh
|
| 21 |
|
| 22 |
-
# ----------
|
| 23 |
-
RUN mkdir -p /data && chown 1001:1001 /data
|
| 24 |
-
|
| 25 |
-
# ---------- switch back to the non-root LS user ----------
|
| 26 |
USER 1001
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
# ---------- tell Label Studio where its data lives ----------
|
| 29 |
ENV LABEL_STUDIO_BASE_DATA_DIR=/data
|
| 30 |
|
| 31 |
-
# ----------
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
ENTRYPOINT ["/entrypoint.sh"]
|
|
|
|
| 1 |
+
FROM heartexlabs/label-studio:hf-latest
|
| 2 |
|
| 3 |
+
# ---------- install aws-cli + sqlite3 (run as root) ----------
|
| 4 |
USER root
|
| 5 |
|
| 6 |
RUN apt-get update && \
|
| 7 |
+
apt-get install -y --no-install-recommends curl unzip sqlite3 && \
|
|
|
|
|
|
|
|
|
|
| 8 |
# AWS CLI v2
|
| 9 |
curl -Lo /tmp/awscliv2.zip https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip && \
|
| 10 |
unzip -q /tmp/awscliv2.zip -d /tmp && \
|
| 11 |
/tmp/aws/install && \
|
| 12 |
rm -rf /tmp/aws /tmp/awscliv2.zip && \
|
| 13 |
+
# Create /data and hand ownership to the LS user before switching
|
| 14 |
+
mkdir -p /data && \
|
| 15 |
+
chown -R 1001:0 /data && \
|
| 16 |
+
chmod -R 775 /data && \
|
| 17 |
apt-get clean && \
|
| 18 |
rm -rf /var/lib/apt/lists/*
|
| 19 |
|
|
|
|
| 21 |
COPY entrypoint.sh /entrypoint.sh
|
| 22 |
RUN chmod +x /entrypoint.sh
|
| 23 |
|
| 24 |
+
# ---------- switch back to the non-root LS user (matches official image) ----------
|
|
|
|
|
|
|
|
|
|
| 25 |
USER 1001
|
| 26 |
|
| 27 |
+
# ---------- signup disabled by default: only admin-invited users can log in ----------
|
| 28 |
+
# Protects a Public HF Space — strangers reach the login screen but cannot
|
| 29 |
+
# self-register. Remove or set to "false" only if you want open registration.
|
| 30 |
+
ENV LABEL_STUDIO_DISABLE_SIGNUP_WITHOUT_LINK=true
|
| 31 |
+
|
| 32 |
# ---------- tell Label Studio where its data lives ----------
|
| 33 |
ENV LABEL_STUDIO_BASE_DATA_DIR=/data
|
| 34 |
|
| 35 |
+
# ---------- run our backup-wrapper instead of the default CMD ----------
|
| 36 |
+
CMD ["/entrypoint.sh"]
|
|
|
|
|
|
entrypoint.sh
CHANGED
|
@@ -19,7 +19,6 @@
|
|
| 19 |
# AWS_DEFAULT_REGION – us-east-1
|
| 20 |
# AWS_ENDPOINT_URL – https://s3.amazonaws.com (change for R2/MinIO)
|
| 21 |
# SYNC_INTERVAL_SECONDS – 60
|
| 22 |
-
# LABEL_STUDIO_PORT – 7860
|
| 23 |
# =============================================================================
|
| 24 |
|
| 25 |
set -euo pipefail
|
|
@@ -30,10 +29,10 @@ PREFIX="${BACKUP_S3_PREFIX:-labelstudio}"
|
|
| 30 |
REGION="${AWS_DEFAULT_REGION:-us-east-1}"
|
| 31 |
ENDPOINT="${AWS_ENDPOINT_URL:-https://s3.amazonaws.com}"
|
| 32 |
SYNC_INTERVAL="${SYNC_INTERVAL_SECONDS:-60}"
|
| 33 |
-
LS_PORT="${LABEL_STUDIO_PORT:-7860}"
|
| 34 |
|
| 35 |
DATA_DIR=/data
|
| 36 |
-
|
|
|
|
| 37 |
S3_PATH="s3://${BUCKET}/${PREFIX}"
|
| 38 |
|
| 39 |
export AWS_DEFAULT_REGION="$REGION"
|
|
@@ -112,11 +111,10 @@ label-studio user create \
|
|
| 112 |
--preserve-case 2>/dev/null || true
|
| 113 |
|
| 114 |
# ------------- 4. start Label Studio in the background --------------------
|
| 115 |
-
#
|
| 116 |
-
#
|
| 117 |
-
echo "[start] Starting Label Studio
|
| 118 |
-
|
| 119 |
-
label-studio --host="0.0.0.0" --port="$LS_PORT" &
|
| 120 |
LS_PID=$!
|
| 121 |
echo "[start] Label Studio PID: $LS_PID"
|
| 122 |
|
|
|
|
| 19 |
# AWS_DEFAULT_REGION – us-east-1
|
| 20 |
# AWS_ENDPOINT_URL – https://s3.amazonaws.com (change for R2/MinIO)
|
| 21 |
# SYNC_INTERVAL_SECONDS – 60
|
|
|
|
| 22 |
# =============================================================================
|
| 23 |
|
| 24 |
set -euo pipefail
|
|
|
|
| 29 |
REGION="${AWS_DEFAULT_REGION:-us-east-1}"
|
| 30 |
ENDPOINT="${AWS_ENDPOINT_URL:-https://s3.amazonaws.com}"
|
| 31 |
SYNC_INTERVAL="${SYNC_INTERVAL_SECONDS:-60}"
|
|
|
|
| 32 |
|
| 33 |
DATA_DIR=/data
|
| 34 |
+
# Label Studio uses label_studio.sqlite3 (not .db) — confirmed from live logs
|
| 35 |
+
DB_FILE="$DATA_DIR/label_studio.sqlite3"
|
| 36 |
S3_PATH="s3://${BUCKET}/${PREFIX}"
|
| 37 |
|
| 38 |
export AWS_DEFAULT_REGION="$REGION"
|
|
|
|
| 111 |
--preserve-case 2>/dev/null || true
|
| 112 |
|
| 113 |
# ------------- 4. start Label Studio in the background --------------------
|
| 114 |
+
# Use $SPACE_HOST exactly as the official HF Dockerfile does — this is what
|
| 115 |
+
# makes HF's reverse proxy route traffic correctly to the container.
|
| 116 |
+
echo "[start] Starting Label Studio ..."
|
| 117 |
+
label-studio --host="$SPACE_HOST" &
|
|
|
|
| 118 |
LS_PID=$!
|
| 119 |
echo "[start] Label Studio PID: $LS_PID"
|
| 120 |
|