1
+ FROM rocker/r-ver:latest
2
+
1
3
# Install system dependencies
2
4
RUN apt-get update && apt-get install -y \
3
5
python3-minimal \
@@ -7,10 +9,10 @@ RUN apt-get update && apt-get install -y \
7
9
gdebi-core \
8
10
wget \
9
11
sudo \
10
- curl
12
+ curl \
13
+ virtualenv # 添加virtualenv
11
14
12
15
# Create rstudio user
13
- # default accout 'rstudio'; password: rstudio123
14
16
ENV USER=rstudio
15
17
ENV PASSWORD=rstudio123
16
18
RUN useradd -m $USER && \
@@ -23,21 +25,23 @@ RUN wget https://download2.rstudio.org/server/jammy/amd64/rstudio-server-2023.12
23
25
gdebi -n rstudio-server-2023.12.1-402-amd64.deb && \
24
26
rm rstudio-server-*.deb
25
27
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
29
32
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"
32
36
33
37
# Setup R environment config
34
38
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 && \
36
40
chown -R $USER:$USER /usr/local/lib/R/etc/Renviron.site && \
37
41
chmod 644 /usr/local/lib/R/etc/Renviron.site
38
42
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 \
41
45
numpy==1.26.4 \
42
46
scipy==1.12.0 \
43
47
transformers \
@@ -47,7 +51,7 @@ RUN /opt/venv/bin/pip install --no-cache-dir \
47
51
# Install R packages
48
52
RUN R -e "install.packages('reticulate', repos='https://cloud.r-project.org/', dependencies=TRUE)" && \
49
53
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)"
51
55
52
56
# Set working directory
53
57
WORKDIR /home/$USER
@@ -63,3 +67,4 @@ EXPOSE 8787
63
67
# Run service as rstudio user
64
68
USER $USER
65
69
CMD ["/usr/lib/rstudio-server/bin/rserver" , "--server-daemonize=0" ]
70
+ CMD ["/usr/lib/rstudio-server/bin/rserver" , "--server-daemonize=0" ]
0 commit comments