Skip to content

Commit

Permalink
feat: 🐳 add Dockerfile for HuggingFace space
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
davidgasquez committed Nov 8, 2024
1 parent 1ee1d75 commit 5fe668d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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" ]
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
1 change: 1 addition & 0 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ <h1>Datadex</h1>
<a href="https://huggingface.co/datonic" class="custom-link">Get the Data</a>
<a href="https://github.com/datonic/datadex" class="custom-link">Contribute</a>
<a href="https://github.com/datonic/datadex/issues/new" class="custom-link">Request Dataset</a>
<a href="https://datonic-datadex.hf.space" class="custom-link">Data Assets</a>
</div>

<br>
Expand Down

0 comments on commit 5fe668d

Please sign in to comment.