|
1 |
| -FROM rocker/r-ver:latest |
2 |
| - |
3 |
| -# Install system dependencies |
4 |
| -RUN apt-get update && apt-get install -y \ |
5 |
| - python3-minimal \ |
6 |
| - python3-pip \ |
7 |
| - python3-venv \ |
8 |
| - libssl-dev \ |
9 |
| - gdebi-core \ |
10 |
| - wget \ |
11 |
| - sudo \ |
12 |
| - curl |
13 |
| - |
14 |
| -# Create rstudio user |
15 |
| -ARG USER=rstudio |
16 |
| -ARG PASSWORD=rstudio123 |
17 |
| -RUN useradd -m $USER && \ |
18 |
| - echo "$USER:$PASSWORD" | chpasswd && \ |
19 |
| - adduser $USER sudo && \ |
20 |
| - echo "$USER ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers |
21 |
| - |
22 |
| -# Install RStudio Server |
23 |
| -RUN wget https://download2.rstudio.org/server/jammy/amd64/rstudio-server-2023.12.1-402-amd64.deb && \ |
24 |
| - gdebi -n rstudio-server-2023.12.1-402-amd64.deb && \ |
25 |
| - rm rstudio-server-*.deb |
26 |
| - |
27 |
| -# Create and configure Python virtual environment |
28 |
| -RUN python3 -m venv /opt/venv && \ |
29 |
| - chown -R $USER:$USER /opt/venv |
30 |
| - |
31 |
| -ENV PATH="/opt/venv/bin:$PATH" |
32 |
| -ENV RETICULATE_PYTHON="/opt/venv/bin/python" |
33 |
| - |
34 |
| -# Setup R environment config |
35 |
| -RUN mkdir -p /usr/local/lib/R/etc && \ |
36 |
| - echo "RETICULATE_PYTHON=/opt/venv/bin/python" >> /usr/local/lib/R/etc/Renviron.site && \ |
37 |
| - echo "options(reticulate.prompt = FALSE)" >> /usr/local/lib/R/etc/Rprofile.site |
38 |
| - |
39 |
| -# Install Python packages |
40 |
| -RUN /opt/venv/bin/pip install --no-cache-dir \ |
41 |
| - numpy==1.26.4 \ |
42 |
| - scipy==1.12.0 \ |
43 |
| - transformers \ |
44 |
| - torch \ |
45 |
| - flair |
46 |
| - |
47 |
| -# Install R packages with proper setup |
48 |
| -RUN R -e 'install.packages("reticulate", repos="https://cloud.r-project.org/", dependencies=TRUE)' && \ |
49 |
| - R -e 'if(require(reticulate)) { \ |
50 |
| - Sys.setenv(RETICULATE_PYTHON="/opt/venv/bin/python"); \ |
51 |
| - reticulate::use_python("/opt/venv/bin/python", required=TRUE); \ |
52 |
| - install.packages("remotes", repos="https://cloud.r-project.org/", dependencies=TRUE); \ |
53 |
| - remotes::install_github("davidycliao/flaiR", dependencies=TRUE) \ |
54 |
| - }' |
55 |
| - |
56 |
| -WORKDIR /home/$USER |
57 |
| -USER $USER |
58 |
| -EXPOSE 8787 |
59 |
| - |
60 |
| -CMD ["/usr/lib/rstudio-server/bin/rserver", "--server-daemonize=0"] |
| 1 | +name: flaiR-Docker |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: [main, master] |
| 5 | + pull_request: |
| 6 | + branches: [main, master] |
| 7 | + |
| 8 | + |
| 9 | +jobs: |
| 10 | + R-CMD-check: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + name: R-CMD-check |
| 13 | + env: |
| 14 | + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} |
| 15 | + R_KEEP_PKG_SOURCE: yes |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v3 |
| 18 | + - uses: r-lib/actions/setup-r@v2 |
| 19 | + with: |
| 20 | + use-public-rspm: true |
| 21 | + - uses: r-lib/actions/setup-pandoc@v2 |
| 22 | + |
| 23 | + - name: Setup Python |
| 24 | + uses: actions/setup-python@v2 |
| 25 | + with: |
| 26 | + python-version: '3.9' |
| 27 | + |
| 28 | + - name: Install Python dependencies |
| 29 | + run: | |
| 30 | + python -m pip install --upgrade pip |
| 31 | + pip install flair |
| 32 | + - name: Install R dependencies |
| 33 | + run: | |
| 34 | + install.packages('remotes') |
| 35 | + remotes::install_github("davidycliao/flaiR", force = TRUE) |
| 36 | + shell: Rscript {0} |
| 37 | + |
| 38 | + - uses: r-lib/actions/setup-r-dependencies@v2 |
| 39 | + with: |
| 40 | + extra-packages: rcmdcheck |
| 41 | + |
| 42 | + docker: |
| 43 | + needs: R-CMD-check |
| 44 | + runs-on: ubuntu-latest |
| 45 | + permissions: |
| 46 | + contents: read |
| 47 | + packages: write |
| 48 | + |
| 49 | + steps: |
| 50 | + - name: Checkout repository |
| 51 | + uses: actions/checkout@v3 |
| 52 | + |
| 53 | + - name: Set up QEMU |
| 54 | + uses: docker/setup-qemu-action@v2 |
| 55 | + |
| 56 | + - name: Log in to GitHub Container Registry |
| 57 | + uses: docker/login-action@v2 |
| 58 | + with: |
| 59 | + registry: ghcr.io |
| 60 | + username: ${{ github.actor }} |
| 61 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 62 | + |
| 63 | + - name: Set up Docker Buildx |
| 64 | + uses: docker/setup-buildx-action@v2 |
| 65 | + with: |
| 66 | + buildkitd-flags: --debug |
| 67 | + |
| 68 | + - name: Extract metadata for Docker |
| 69 | + id: meta |
| 70 | + uses: docker/metadata-action@v4 |
| 71 | + with: |
| 72 | + images: ghcr.io/${{ github.repository_owner }}/flair-rstudio |
| 73 | + tags: | |
| 74 | + type=ref,event=branch |
| 75 | + type=ref,event=pr |
| 76 | + type=semver,pattern={{version}} |
| 77 | + type=semver,pattern={{major}}.{{minor}} |
| 78 | + type=sha |
| 79 | + type=raw,value=latest,enable={{is_default_branch}} |
| 80 | + - name: Build and push RStudio image |
| 81 | + uses: docker/build-push-action@v4 |
| 82 | + with: |
| 83 | + context: . |
| 84 | + platforms: linux/amd64 |
| 85 | + push: ${{ github.event_name != 'pull_request' }} |
| 86 | + tags: ${{ steps.meta.outputs.tags }} |
| 87 | + labels: ${{ steps.meta.outputs.labels }} |
| 88 | + build-args: | |
| 89 | + DEFAULT_USER=rstudio |
| 90 | + secrets: | |
| 91 | + PASSWORD=${{ secrets.RSTUDIO_PASSWORD }} |
| 92 | + cache-from: type=gha |
| 93 | + cache-to: type=gha,mode=max |
| 94 | + provenance: false |
0 commit comments