Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add r session debug images #147

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
157 changes: 157 additions & 0 deletions .github/workflows/build-debug.yaml
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions r-session-debug/bionic/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should also have strace if it is not already installed

&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

COPY startup.sh /usr/local/bin/startup.sh
18 changes: 18 additions & 0 deletions r-session-debug/bionic/startup.sh
Original file line number Diff line number Diff line change
@@ -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