Skip to content

Commit 6a990cd

Browse files
committed
Update Dockerfile
1 parent 5e0373b commit 6a990cd

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

Dockerfile

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
FROM rocker/r-ver:latest
2+
13
# Install system dependencies
24
RUN apt-get update && apt-get install -y \
35
python3-minimal \
@@ -7,10 +9,10 @@ RUN apt-get update && apt-get install -y \
79
gdebi-core \
810
wget \
911
sudo \
10-
curl
12+
curl \
13+
virtualenv # 添加virtualenv
1114

1215
# Create rstudio user
13-
# default accout 'rstudio'; password: rstudio123
1416
ENV USER=rstudio
1517
ENV PASSWORD=rstudio123
1618
RUN useradd -m $USER && \
@@ -23,21 +25,23 @@ RUN wget https://download2.rstudio.org/server/jammy/amd64/rstudio-server-2023.12
2325
gdebi -n rstudio-server-2023.12.1-402-amd64.deb && \
2426
rm rstudio-server-*.deb
2527

26-
# Create and configure Python virtual environment
27-
RUN python3 -m venv /opt/venv && \
28-
chown -R $USER:$USER /opt/venv
28+
# 修改虚拟环境路径到用户目录
29+
ENV VENV_PATH=/home/$USER/flair_env
30+
RUN python3 -m venv $VENV_PATH && \
31+
chown -R $USER:$USER $VENV_PATH
2932

30-
ENV PATH="/opt/venv/bin:$PATH"
31-
ENV RETICULATE_PYTHON="/opt/venv/bin/python"
33+
# 更新环境变量
34+
ENV PATH="$VENV_PATH/bin:$PATH"
35+
ENV RETICULATE_PYTHON="$VENV_PATH/bin/python"
3236

3337
# Setup R environment config
3438
RUN mkdir -p /usr/local/lib/R/etc && \
35-
echo "RETICULATE_PYTHON=/opt/venv/bin/python" >> /usr/local/lib/R/etc/Renviron.site && \
39+
echo "RETICULATE_PYTHON=$VENV_PATH/bin/python" >> /usr/local/lib/R/etc/Renviron.site && \
3640
chown -R $USER:$USER /usr/local/lib/R/etc/Renviron.site && \
3741
chmod 644 /usr/local/lib/R/etc/Renviron.site
3842

39-
# Install Python packages
40-
RUN /opt/venv/bin/pip install --no-cache-dir \
43+
# Install Python packages in the virtual environment
44+
RUN $VENV_PATH/bin/pip install --no-cache-dir \
4145
numpy==1.26.4 \
4246
scipy==1.12.0 \
4347
transformers \
@@ -47,7 +51,7 @@ RUN /opt/venv/bin/pip install --no-cache-dir \
4751
# Install R packages
4852
RUN R -e "install.packages('reticulate', repos='https://cloud.r-project.org/', dependencies=TRUE)" && \
4953
R -e "install.packages('remotes', repos='https://cloud.r-project.org/', dependencies=TRUE)" && \
50-
R -e "remotes::install_github('davidycliao/flaiR', dependencies=TRUE)"
54+
R -e "options(timeout=600); Sys.setenv(RETICULATE_PYTHON='$VENV_PATH/bin/python'); library(reticulate); use_virtualenv('$VENV_PATH', required = TRUE); remotes::install_github('davidycliao/flaiR', dependencies=TRUE)"
5155

5256
# Set working directory
5357
WORKDIR /home/$USER
@@ -63,3 +67,4 @@ EXPOSE 8787
6367
# Run service as rstudio user
6468
USER $USER
6569
CMD ["/usr/lib/rstudio-server/bin/rserver", "--server-daemonize=0"]
70+
CMD ["/usr/lib/rstudio-server/bin/rserver", "--server-daemonize=0"]

0 commit comments

Comments
 (0)