-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #266 from davidycliao/0.1.7
0.1.7
- Loading branch information
Showing
3 changed files
with
153 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,67 @@ | ||
FROM rocker/r-ver:latest | ||
|
||
# 系統更新和安裝安全性修補 | ||
RUN apt-get update && \ | ||
apt-get upgrade -y && \ | ||
apt-get install -y --no-install-recommends \ | ||
# Install system dependencies | ||
RUN apt-get update && apt-get install -y \ | ||
python3-minimal \ | ||
python3-pip \ | ||
python3-venv \ | ||
python3-full \ | ||
libcurl4-openssl-dev \ | ||
libssl-dev \ | ||
gdebi-core \ | ||
wget \ | ||
sudo && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
sudo \ | ||
curl | ||
|
||
# 安裝 RStudio Server | ||
RUN wget --progress=dot:giga https://download2.rstudio.org/server/jammy/amd64/rstudio-server-2023.12.1-402-amd64.deb && \ | ||
# Create rstudio user | ||
ENV USER=rstudio | ||
ENV PASSWORD=rstudio123 | ||
RUN useradd -m $USER && \ | ||
echo "$USER:$PASSWORD" | chpasswd && \ | ||
adduser $USER sudo && \ | ||
echo "$USER ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers | ||
|
||
# Install RStudio Server | ||
RUN wget https://download2.rstudio.org/server/jammy/amd64/rstudio-server-2023.12.1-402-amd64.deb && \ | ||
gdebi -n rstudio-server-2023.12.1-402-amd64.deb && \ | ||
rm rstudio-server-*.deb | ||
|
||
# Python 虛擬環境設置 | ||
RUN python3 -m venv /opt/venv | ||
# Create and configure Python virtual environment | ||
RUN python3 -m venv /opt/venv && \ | ||
chown -R $USER:$USER /opt/venv | ||
|
||
ENV PATH="/opt/venv/bin:$PATH" | ||
ENV RETICULATE_PYTHON="/opt/venv/bin/python" | ||
|
||
# Setup R environment config | ||
RUN mkdir -p /usr/local/lib/R/etc && \ | ||
echo "RETICULATE_PYTHON=/opt/venv/bin/python" >> /usr/local/lib/R/etc/Renviron.site && \ | ||
chown -R $USER:$USER /usr/local/lib/R/etc/Renviron.site && \ | ||
chmod 644 /usr/local/lib/R/etc/Renviron.site | ||
|
||
# R env | ||
RUN echo "RETICULATE_PYTHON=/opt/venv/bin/python" >> /usr/local/lib/R/etc/Renviron.site | ||
|
||
# 安裝更新的 Python 包 | ||
RUN /opt/venv/bin/pip install --no-cache-dir --upgrade pip && \ | ||
/opt/venv/bin/pip install --no-cache-dir \ | ||
numpy>=1.26.4 \ | ||
scipy>=1.12.0 \ | ||
# Install Python packages | ||
RUN /opt/venv/bin/pip install --no-cache-dir \ | ||
numpy==1.26.4 \ | ||
scipy==1.12.0 \ | ||
transformers \ | ||
torch \ | ||
flair | ||
|
||
# 安裝 R 包 | ||
RUN install2.r --error --deps TRUE \ | ||
reticulate \ | ||
remotes && \ | ||
# Install R packages | ||
RUN R -e "install.packages('reticulate', repos='https://cloud.r-project.org/', dependencies=TRUE)" && \ | ||
R -e "install.packages('remotes', repos='https://cloud.r-project.org/', dependencies=TRUE)" && \ | ||
R -e "remotes::install_github('davidycliao/flaiR', dependencies=TRUE)" | ||
|
||
# 使用者設置(使用 ARG 而不是 ENV 來處理敏感資訊) | ||
ARG USER=rstudio | ||
ARG PASSWORD=rstudio123 | ||
RUN useradd -m $USER && \ | ||
echo "$USER:$PASSWORD" | chpasswd && \ | ||
adduser $USER sudo | ||
# Set working directory | ||
WORKDIR /home/$USER | ||
RUN chown -R $USER:$USER /home/$USER | ||
|
||
# Add healthcheck | ||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ | ||
CMD curl -f http://localhost:8787/ || exit 1 | ||
|
||
# 設置權限 | ||
RUN mkdir -p /home/$USER && \ | ||
chown -R $USER:$USER /home/$USER && \ | ||
chown -R $USER:$USER /opt/venv && \ | ||
chown -R $USER:$USER /usr/local/lib/R/etc/Renviron.site && \ | ||
chmod 644 /usr/local/lib/R/etc/Renviron.site | ||
|
||
# 清理 | ||
RUN apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | ||
|
||
# Expose port | ||
EXPOSE 8787 | ||
|
||
# Run service as rstudio user | ||
USER $USER | ||
CMD ["/usr/lib/rstudio-server/bin/rserver", "--server-daemonize=0"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters