@@ -9,10 +9,10 @@ RUN apt-get update && apt-get install -y \
9
9
gdebi-core \
10
10
wget \
11
11
sudo \
12
- curl
12
+ curl \
13
+ virtualenv # 添加virtualenv
13
14
14
15
# Create rstudio user
15
- # default accout 'rstudio'; password: rstudio123
16
16
ENV USER=rstudio
17
17
ENV PASSWORD=rstudio123
18
18
RUN useradd -m $USER && \
@@ -25,21 +25,23 @@ RUN wget https://download2.rstudio.org/server/jammy/amd64/rstudio-server-2023.12
25
25
gdebi -n rstudio-server-2023.12.1-402-amd64.deb && \
26
26
rm rstudio-server-*.deb
27
27
28
- # Create and configure Python virtual environment
29
- RUN python3 -m venv /opt/venv && \
30
- 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
31
32
32
- ENV PATH="/opt/venv/bin:$PATH"
33
- ENV RETICULATE_PYTHON="/opt/venv/bin/python"
33
+ # 更新环境变量
34
+ ENV PATH="$VENV_PATH/bin:$PATH"
35
+ ENV RETICULATE_PYTHON="$VENV_PATH/bin/python"
34
36
35
37
# Setup R environment config
36
38
RUN mkdir -p /usr/local/lib/R/etc && \
37
- 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 && \
38
40
chown -R $USER:$USER /usr/local/lib/R/etc/Renviron.site && \
39
41
chmod 644 /usr/local/lib/R/etc/Renviron.site
40
42
41
- # Install Python packages
42
- 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 \
43
45
numpy==1.26.4 \
44
46
scipy==1.12.0 \
45
47
transformers \
@@ -49,7 +51,7 @@ RUN /opt/venv/bin/pip install --no-cache-dir \
49
51
# Install R packages
50
52
RUN R -e "install.packages('reticulate', repos='https://cloud.r-project.org/', dependencies=TRUE)" && \
51
53
R -e "install.packages('remotes', repos='https://cloud.r-project.org/', dependencies=TRUE)" && \
52
- 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)"
53
55
54
56
# Set working directory
55
57
WORKDIR /home/$USER
@@ -65,4 +67,3 @@ EXPOSE 8787
65
67
# Run service as rstudio user
66
68
USER $USER
67
69
CMD ["/usr/lib/rstudio-server/bin/rserver" , "--server-daemonize=0" ]
68
-
0 commit comments