diff --git a/.github/workflows/build-debug.yaml b/.github/workflows/build-debug.yaml new file mode 100644 index 00000000..596b2f65 --- /dev/null +++ b/.github/workflows/build-debug.yaml @@ -0,0 +1,157 @@ +on: + workflow_run: + workflows: + - "Build and Test (latest)" + types: + - completed + +name: Build and Test (debug) +jobs: + + build: + runs-on: ubuntu-latest + name: build-${{ matrix.config.tag_prefix}}${{ matrix.config.product}} + + # beware - several copies of matrix below + strategy: + fail-fast: false + matrix: + config: + - {product: 'r-session-debug', tag_prefix: 'bionic-', dir: 'r-session-debug/bionic', prefix: RSP, version: 1.4.1717-3} + - {product: 'r-session-debug', tag_prefix: 'centos7-', dir: 'r-session-debug/centos7', prefix: RSP, version: 1.4.1717-3} + + steps: + - name: Check Out Repo + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Build + id: docker_build + uses: docker/build-push-action@v2 + with: + context: ./${{ matrix.config.dir }} + file: ./${{ matrix.config.dir }}/Dockerfile + builder: ${{ steps.buildx.outputs.name }} + tags: | + rstudio/${{ matrix.config.product }}:${{ matrix.config.tag_prefix }}latest + rstudio/${{ matrix.config.product }}:${{ matrix.config.tag_prefix }}${{ matrix.config.version }} + ghcr.io/rstudio/${{ matrix.config.product }}:${{ matrix.config.tag_prefix }}latest + ghcr.io/rstudio/${{ matrix.config.product }}:${{ matrix.config.tag_prefix }}${{ matrix.config.version }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + outputs: type=docker,dest=/tmp/${{ matrix.config.tag_prefix }}${{ matrix.config.product }}-image.tar + push: false + build-args: | + RSP_VERSION=${{ matrix.config.version }} + + - name: Upload artifact + uses: actions/upload-artifact@v2 + with: + name: ${{ matrix.config.tag_prefix }}${{ matrix.config.product }}-image + path: /tmp/${{ matrix.config.tag_prefix }}${{ matrix.config.product }}-image.tar + + - name: Image digest + run: echo ${{ steps.docker_build.outputs.digest }} + + test: + runs-on: ubuntu-latest + name: test-${{ matrix.config.tag_prefix }}${{ matrix.config.product}} + needs: build + + strategy: + fail-fast: false + matrix: + config: + - {product: 'r-session-debug', tag_prefix: 'bionic-', dir: 'r-session-debug/bionic', prefix: RSP, version: 1.4.1717-3} + - {product: 'r-session-debug', tag_prefix: 'centos7-', dir: 'r-session-debug/centos7', prefix: RSP, version: 1.4.1717-3} + + steps: + - name: Check Out Repo + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Download artifact + uses: actions/download-artifact@v2 + with: + name: ${{ matrix.config.tag_prefix }}${{ matrix.config.product}}-image + path: /tmp + + - name: Load image + run: | + docker load --input /tmp/${{ matrix.config.tag_prefix }}${{ matrix.config.product }}-image.tar + docker image ls -a + + - name: Test image + env: + IMAGE_NAME: rstudio/${{ matrix.config.product }}:${{ matrix.config.tag_prefix }}${{ matrix.config.version }} + # because we cannot dynamically set env var names... set them all... + RSP_VERSION: ${{ matrix.config.version }} + RSC_VERSION: ${{ matrix.config.version }} + RSPM_VERSION: ${{ matrix.config.version }} + run: | + docker-compose -f ./${{ matrix.config.dir }}/docker-compose.test.yml run sut + + push: + runs-on: ubuntu-latest + needs: test + if: ${{ github.ref == 'refs/heads/main' }} + name: push-${{ matrix.config.tag_prefix }}${{ matrix.config.product}} + environment: build-and-push + + strategy: + fail-fast: false + matrix: + config: + - {product: 'r-session-debug', tag_prefix: 'bionic-', dir: 'r-session-debug/bionic', prefix: RSP, version: 1.4.1717-3} + - {product: 'r-session-debug', tag_prefix: 'centos7-', dir: 'r-session-debug/centos7', prefix: RSP, version: 1.4.1717-3} + + steps: + - name: Check Out Repo + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Download artifact + uses: actions/download-artifact@v2 + with: + name: ${{ matrix.config.tag_prefix }}${{ matrix.config.product}}-image + path: /tmp + + - name: Load image + run: | + docker load --input /tmp/${{ matrix.config.tag_prefix }}${{ matrix.config.product }}-image.tar + docker image ls -a + + - name: Login to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + + - name: Login to ghcr.io + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.BUILD_PAT }} + + - name: Push image(s) to Docker Hub + run: | + docker push rstudio/${{ matrix.config.product }}:${{ matrix.config.tag_prefix }}${{ matrix.config.version }} + docker push rstudio/${{ matrix.config.product }}:${{ matrix.config.tag_prefix }}latest + docker push ghcr.io/rstudio/${{ matrix.config.product }}:${{ matrix.config.tag_prefix }}${{ matrix.config.version }} + docker push ghcr.io/rstudio/${{ matrix.config.product }}:${{ matrix.config.tag_prefix }}latest diff --git a/r-session-debug/bionic/Dockerfile b/r-session-debug/bionic/Dockerfile new file mode 100644 index 00000000..d949403c --- /dev/null +++ b/r-session-debug/bionic/Dockerfile @@ -0,0 +1,15 @@ +ARG RSP_VERSION +FROM rstudio/r-session-complete:bionic-${RSP_VERSION} + +RUN apt-get update -qq \ + && apt-get install -y \ + dnsutils \ + tcpdump \ + netcat \ + net-tools \ + psutils \ + vim \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +COPY startup.sh /usr/local/bin/startup.sh diff --git a/r-session-debug/bionic/startup.sh b/r-session-debug/bionic/startup.sh new file mode 100755 index 00000000..4246d569 --- /dev/null +++ b/r-session-debug/bionic/startup.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +TCPDUMP_OUTPUT=${TCPDUMP_OUTPUT:-/tmp/tcpdump.pcap} +TCPDUMP_MAX_PACKETS=${TCPDUMP_MAX_PACKETS:-10000} + +tcpdump -i any -w ${TCPDUMP_OUTPUT} -c ${TCPDUMP_MAX_PACKETS} & + +# Launch the session based on RSTUDIO_TYPE +if [ -z "$RSTUDIO_TYPE" -o "$RSTUDIO_TYPE" == "session" ]; then + echo "Starting RStudio session..." + exec "/usr/lib/rstudio-server/bin/rserver-launcher" "$@" +elif [ "$RSTUDIO_TYPE" == "adhoc" ]; then + echo "Starting RStudio adhoc job..." + exec "/bin/bash" "$@" +else + echo "ERROR: Unknown RSTUDIO_TYPE: ${RSTUDIO_TYPE}" + exit 1 +fi