-
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.
fix: update Docker environment configuration
fix: update Docker environment configuration - Replace ENV with ARG for user credentials - Update Python virtual environment path to /opt/venv - Fix RETICULATE_PYTHON path configuration
- Loading branch information
1 parent
dc6f523
commit a47b172
Showing
2 changed files
with
115 additions
and
91 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,94 @@ | ||
FROM rocker/r-ver:latest | ||
|
||
# Install system dependencies | ||
RUN apt-get update && apt-get install -y \ | ||
python3-minimal \ | ||
python3-pip \ | ||
python3-venv \ | ||
libssl-dev \ | ||
gdebi-core \ | ||
wget \ | ||
sudo \ | ||
curl | ||
|
||
# Create rstudio user | ||
ARG USER=rstudio | ||
ARG 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 | ||
|
||
# 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 && \ | ||
echo "options(reticulate.prompt = FALSE)" >> /usr/local/lib/R/etc/Rprofile.site | ||
|
||
# Install Python packages | ||
RUN /opt/venv/bin/pip install --no-cache-dir \ | ||
numpy==1.26.4 \ | ||
scipy==1.12.0 \ | ||
transformers \ | ||
torch \ | ||
flair | ||
|
||
# Install R packages with proper setup | ||
RUN R -e 'install.packages("reticulate", repos="https://cloud.r-project.org/", dependencies=TRUE)' && \ | ||
R -e 'if(require(reticulate)) { \ | ||
Sys.setenv(RETICULATE_PYTHON="/opt/venv/bin/python"); \ | ||
reticulate::use_python("/opt/venv/bin/python", required=TRUE); \ | ||
install.packages("remotes", repos="https://cloud.r-project.org/", dependencies=TRUE); \ | ||
remotes::install_github("davidycliao/flaiR", dependencies=TRUE) \ | ||
}' | ||
|
||
WORKDIR /home/$USER | ||
USER $USER | ||
EXPOSE 8787 | ||
|
||
CMD ["/usr/lib/rstudio-server/bin/rserver", "--server-daemonize=0"] | ||
name: flaiR-Docker | ||
on: | ||
push: | ||
branches: [main, master] | ||
pull_request: | ||
branches: [main, master] | ||
|
||
|
||
jobs: | ||
R-CMD-check: | ||
runs-on: ubuntu-latest | ||
name: R-CMD-check | ||
env: | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
R_KEEP_PKG_SOURCE: yes | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: r-lib/actions/setup-r@v2 | ||
with: | ||
use-public-rspm: true | ||
- uses: r-lib/actions/setup-pandoc@v2 | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.9' | ||
|
||
- name: Install Python dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install flair | ||
- name: Install R dependencies | ||
run: | | ||
install.packages('remotes') | ||
remotes::install_github("davidycliao/flaiR", force = TRUE) | ||
shell: Rscript {0} | ||
|
||
- uses: r-lib/actions/setup-r-dependencies@v2 | ||
with: | ||
extra-packages: rcmdcheck | ||
|
||
docker: | ||
needs: R-CMD-check | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
- name: Log in to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
with: | ||
buildkitd-flags: --debug | ||
|
||
- name: Extract metadata for Docker | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: ghcr.io/${{ github.repository_owner }}/flair-rstudio | ||
tags: | | ||
type=ref,event=branch | ||
type=ref,event=pr | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=sha | ||
type=raw,value=latest,enable={{is_default_branch}} | ||
- name: Build and push RStudio image | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
platforms: linux/amd64 | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
build-args: | | ||
DEFAULT_USER=rstudio | ||
secrets: | | ||
PASSWORD=${{ secrets.RSTUDIO_PASSWORD }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
provenance: false |
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