From 8da7a4057bb1a64443946097dd3a07ad1213c147 Mon Sep 17 00:00:00 2001 From: davidycliao Date: Mon, 30 Dec 2024 01:19:51 +0000 Subject: [PATCH 1/2] UPLOAD docker evn --- .github/workflows/docker-publish.yml | 67 +++++++++------------------- Dockerfile | 8 +++- 2 files changed, 26 insertions(+), 49 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 31eeb66f..1efcef50 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -1,55 +1,13 @@ -name: flaiR-Docker +name: R-Docker on: push: - branches: [main, master] - pull_request: - branches: [main, master] + branches: [ main, master ] + release: + types: [created] jobs: - R-CMD-check: - runs-on: ${{ matrix.config.os }} - name: ${{ matrix.config.os }} (${{ matrix.config.r }}) - strategy: - fail-fast: false - matrix: - config: - - {os: macos-latest, r: 'release'} - - {os: windows-latest, r: 'release'} - - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} - - {os: ubuntu-latest, r: 'release'} - env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - R_KEEP_PKG_SOURCE: yes - steps: - - uses: actions/checkout@v3 - - uses: r-lib/actions/setup-r@v2 - with: - r-version: ${{ matrix.config.r }} - http-user-agent: ${{ matrix.config.http-user-agent }} - 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: Check Python Version - run: python --version - - 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 + build: runs-on: ubuntu-latest permissions: contents: read @@ -65,6 +23,21 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + context: . + push: true + tags: | + ghcr.io/${{ github.repository_owner }}/flair:latest + ghcr.io/${{ github.repository_owner }}/flair:${{ github.sha }} + - 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 diff --git a/Dockerfile b/Dockerfile index 7e9202f4..f82e16fb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,8 +23,12 @@ RUN R -e "install.packages(c('remotes', \ 'knitr', 'rmarkdown', 'lsa', 'purrr', 'jsonlite', 'ggplot2', 'plotly', 'testthat'), \ repos='https://cloud.r-project.org/')" -# 從 GitHub 安裝 flaiR -RUN R -e "remotes::install_github('davidycliao/flaiR', force = TRUE)" +# 複製你的 R 包源碼到容器中 +COPY . /pkg +WORKDIR /pkg + +# 從本地安裝套件 +RUN R -e "remotes::install_local('/pkg', force = TRUE)" # 設定預設命令 CMD ["R"] From aa1a283e422455b387ed25419de5e83faf7e3d4d Mon Sep 17 00:00:00 2001 From: davidycliao Date: Mon, 30 Dec 2024 02:11:35 +0000 Subject: [PATCH 2/2] Update docker-publish.yml --- .github/workflows/docker-publish.yml | 83 ++++++++++++++++++++-------- 1 file changed, 60 insertions(+), 23 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 1efcef50..8cd07ca5 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -1,13 +1,62 @@ -name: R-Docker +name: flaiR-Docker on: push: - branches: [ main, master ] - release: - types: [created] + branches: [main, master] + pull_request: + branches: [main, master] jobs: - build: + R-CMD-check: + runs-on: ${{ matrix.config.os }} + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) + strategy: + fail-fast: false + matrix: + config: + - {os: macos-latest, r: 'release'} + - {os: windows-latest, r: 'release'} + - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} + - {os: ubuntu-latest, r: 'release'} + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + R_KEEP_PKG_SOURCE: yes + steps: + - uses: actions/checkout@v3 + + - uses: r-lib/actions/setup-r@v2 + with: + r-version: ${{ matrix.config.r }} + http-user-agent: ${{ matrix.config.http-user-agent }} + 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: Check Python Version + run: python --version + + - 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 @@ -16,21 +65,12 @@ jobs: steps: - uses: actions/checkout@v3 - - 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 QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 - - name: Build and push Docker image - uses: docker/build-push-action@v4 - with: - context: . - push: true - tags: | - ghcr.io/${{ github.repository_owner }}/flair:latest - ghcr.io/${{ github.repository_owner }}/flair:${{ github.sha }} - name: Log in to GitHub Container Registry uses: docker/login-action@v2 with: @@ -38,14 +78,11 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Build and push Docker image uses: docker/build-push-action@v4 with: context: . + platforms: linux/amd64,linux/arm64 push: true tags: | ghcr.io/${{ github.repository_owner }}/flair:latest