Skip to content

Commit 421f73c

Browse files
authored
Merge pull request #284 from davidycliao/0.1.7
Update .onAttach to prevent reticulate prompt
2 parents 5e29223 + b96fca9 commit 421f73c

File tree

2 files changed

+275
-122
lines changed

2 files changed

+275
-122
lines changed

Dockerfile

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ RUN apt-get update && apt-get install -y \
99
gdebi-core \
1010
wget \
1111
sudo \
12-
curl
12+
curl \
13+
virtualenv # 添加virtualenv
1314

1415
# Create rstudio user
15-
# default accout 'rstudio'; password: rstudio123
1616
ENV USER=rstudio
1717
ENV PASSWORD=rstudio123
1818
RUN useradd -m $USER && \
@@ -25,21 +25,23 @@ RUN wget https://download2.rstudio.org/server/jammy/amd64/rstudio-server-2023.12
2525
gdebi -n rstudio-server-2023.12.1-402-amd64.deb && \
2626
rm rstudio-server-*.deb
2727

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
3132

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"
3436

3537
# Setup R environment config
3638
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 && \
3840
chown -R $USER:$USER /usr/local/lib/R/etc/Renviron.site && \
3941
chmod 644 /usr/local/lib/R/etc/Renviron.site
4042

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 \
4345
numpy==1.26.4 \
4446
scipy==1.12.0 \
4547
transformers \
@@ -49,7 +51,7 @@ RUN /opt/venv/bin/pip install --no-cache-dir \
4951
# Install R packages
5052
RUN R -e "install.packages('reticulate', repos='https://cloud.r-project.org/', dependencies=TRUE)" && \
5153
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)"
5355

5456
# Set working directory
5557
WORKDIR /home/$USER
@@ -65,4 +67,3 @@ EXPOSE 8787
6567
# Run service as rstudio user
6668
USER $USER
6769
CMD ["/usr/lib/rstudio-server/bin/rserver", "--server-daemonize=0"]
68-

0 commit comments

Comments
 (0)