Skip to content

Commit

Permalink
Added Dockerfile for HF space deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
andreped authored Sep 23, 2023
1 parent 1b021be commit 5f16d7a
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
# you will also find guides on how best to write your Dockerfile
FROM tensorflow/tensorflow:2.4.2-gpu

# fix for broken keys in Ubuntu-18.04
RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/3bf863cc.pub

# install Python 3.7
RUN apt-get update && apt-get install -y --no-install-recommends software-properties-common \
libsm6 libxext6 libxrender-dev curl \
&& rm -rf /var/lib/apt/lists/*

RUN echo "**** Installing Python ****" && \
add-apt-repository ppa:deadsnakes/ppa && \
apt-get install -y build-essential python3.7 python3.7-dev python3-pip && \
curl -O https://bootstrap.pypa.io/get-pip.py && \
python3.7 get-pip.py && \
rm -rf /var/lib/apt/lists/*

WORKDIR /code

RUN apt-get update -y
RUN apt install git --fix-missing -y

# install dependencies
COPY ./demo/requirements.txt /code/demo/requirements.txt
RUN python3.7 -m pip install --no-cache-dir --upgrade -r /code/demo/requirements.txt

# Install wget
RUN apt install wget -y

# Set up a new user named "user" with user ID 1000
RUN useradd -m -u 1000 user

# Switch to the "user" user
USER user

# Set home to the user's home directory
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH

# Set the working directory to the user's home directory
WORKDIR $HOME/app

# Copy the current directory contents into the container at $HOME/app setting the owner to the user
COPY --chown=user . $HOME/app

# Download pretrained parenchyma model
#RUN wget "https://github.com/andreped/livermask/releases/download/trained-models-v1/model.h5"

# Download test sample
RUN wget https://github.com/VemundFredriksen/LungTumorMask/releases/download/0.0.1/lung_001.nii.gz

CMD ["python3.7", "demo/app.py"]

0 comments on commit 5f16d7a

Please sign in to comment.