From 5fe668de6e61fba140a4a85bc6390f1a31ab023c Mon Sep 17 00:00:00 2001 From: David Gasquez Date: Fri, 8 Nov 2024 16:08:37 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=90=B3=20add=20Dockerfile=20for?= =?UTF-8?q?=20HuggingFace=20space?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduce Dockerfile for creating a standardized runtime environment using Python 3.12. Integrate UV tools for dependency management and running the Dagster server. Create new 'space' target in Makefile for uploading Dockerfile to Hugging Face. Update web page with new 'Data Assets' link pointing to hosted dataset workspace. --- Dockerfile | 25 +++++++++++++++++++++++++ Makefile | 5 ++++- web/index.html | 1 + 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0e720f9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +FROM python:3.12 + +COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv + +RUN useradd -m -u 1000 user +USER user +ENV HOME=/home/user \ + PATH=/home/user/.local/bin:$PATH + +# Copy the datadex project and dependencies +RUN git clone https://github.com/datonic/datadex.git $HOME/app && \ + cd $HOME/app && \ + chown -R user:user . + +# Create a data directory and set ownership +RUN mkdir -p $HOME/app/data && chown -R user:user $HOME/app/data + +# Set the working directory +WORKDIR $HOME/app + +# Sync the dependencies +RUN [ "uv", "sync" ] + +# Run the Dagster server +CMD [ "uv", "run", "dagster-webserver", "--read-only", "-h", "0.0.0.0", "-p", "7860" ] diff --git a/Makefile b/Makefile index 26a536d..2d3b4bb 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ .DEFAULT_GOAL := run -.PHONY: web run dev clean api +.PHONY: run dev setup web api space clean run: uv run dagster asset materialize --select \* -m datadex.definitions @@ -17,5 +17,8 @@ web: api: uv run huggingface-cli upload --token=${HUGGINGFACE_TOKEN} datonic/api --repo-type=space --delete "*" ./api . +space: + uv run huggingface-cli upload --token=${HUGGINGFACE_TOKEN} datonic/datadex --delete '*' --repo-type=space "Dockerfile" + clean: rm -rf data/*.parquet data/*.duckdb diff --git a/web/index.html b/web/index.html index 799aca8..dc728ac 100644 --- a/web/index.html +++ b/web/index.html @@ -68,6 +68,7 @@

Datadex

Get the Data Contribute Request Dataset + Data Assets