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 Chrome Remote Desktop Container #5

Open
wants to merge 3 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
69 changes: 69 additions & 0 deletions .github/workflows/sleap_chrome_remote_desktop_production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Build and Push sleap-chrome-remote-desktop (Production Workflow)

# Run on push to main branch after testing is complete
on:
push:
branches:
- main
paths:
- sleap_chrome_remote_desktop/** # Only run on changes to sleap_chrome_remote_desktop
- .github/workflows/sleap_chrome_remote_desktop_production.yml # Only run on changes to this workflow

jobs:
build:
runs-on: ubuntu-latest # Only build on Ubuntu for now since Docker is not available on macOS runners
strategy:
matrix:
platform: [linux/amd64] # Only build amd64 for now
max-parallel: 2 # Build both architectures in parallel (if more than one)
outputs:
git_sha: ${{ steps.get_sha.outputs.sha }}
sanitized_platform: ${{ steps.sanitize_platform.outputs.sanitized_platform }}
steps:
- name: Checkout code
# https://github.com/actions/checkout
uses: actions/checkout@v4

- name: Get Git SHA
id: get_sha
run: echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT

- name: Debug Git SHA
run: echo "Git SHA ${{ steps.get_sha.outputs.sha }}"

# Generate a sanitized platform string with slashes replaced by dashes
- name: Sanitize platform name
id: sanitize_platform
run: |
sanitized_platform="${{ matrix.platform }}" # Copy platform value
sanitized_platform="${sanitized_platform/\//-}" # Replace / with -
echo "sanitized_platform=$sanitized_platform" >> $GITHUB_OUTPUT

- name: Set up Docker Buildx
# https://github.com/docker/setup-buildx-action
uses: docker/setup-buildx-action@v3
with:
driver: docker-container # Use a container driver for Buildx (default)

- name: Log in to Docker Hub
# https://github.com/docker/login-action
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push Docker image
# https://github.com/docker/build-push-action
uses: docker/build-push-action@v6
with:
context: ./sleap_chrome_remote_desktop # Build context wrt the root of the repository
file: ./sleap_chrome_remote_desktop/Dockerfile # Path to Dockerfile wrt the root of the repository
platforms: ${{ matrix.platform }}
push: true # Push the image to Docker Hub
# Tags for the production images, including the "latest" tag
tags: |
${{ vars.DOCKERHUB_USERNAME }}/sleap-chrome-remote-desktop:latest
${{ vars.DOCKERHUB_USERNAME }}/sleap-chrome-remote-desktop:${{ steps.sanitize_platform.outputs.sanitized_platform }}
${{ vars.DOCKERHUB_USERNAME }}/sleap-chrome-remote-desktop:${{ steps.sanitize_platform.outputs.sanitized_platform }}-nvidia-cuda-11.3.1-cudnn8-runtime-ubuntu20.04
${{ vars.DOCKERHUB_USERNAME }}/sleap-chrome-remote-desktop:${{ steps.sanitize_platform.outputs.sanitized_platform }}-sleap-1.3.4
${{ vars.DOCKERHUB_USERNAME }}/sleap-chrome-remote-desktop:${{ steps.sanitize_platform.outputs.sanitized_platform }}-${{ steps.get_sha.outputs.sha }}
68 changes: 68 additions & 0 deletions .github/workflows/sleap_chrome_remote_desktop_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Build and Push sleap-chrome-remote-desktop (Test Workflow)

# Run on push to branches other than main for sleap_chrome_remote_desktop
on:
push:
branches-ignore:
- main
paths:
- sleap_chrome_remote_desktop/** # Only run on changes to sleap_chrome_remote_desktop
- .github/workflows/sleap_chrome_remote_desktop_test.yml # Only run on changes to this workflow

jobs:
build:
runs-on: ubuntu-latest # Only build on Ubuntu for now since Docker is not available on macOS runners
strategy:
matrix:
platform: [linux/amd64] # Only build amd64 for now
max-parallel: 2 # Build both architectures in parallel (if more than one)
outputs:
git_sha: ${{ steps.get_sha.outputs.sha }}
sanitized_platform: ${{ steps.sanitize_platform.outputs.sanitized_platform }}
steps:
- name: Checkout code
# https://github.com/actions/checkout
uses: actions/checkout@v4

- name: Get Git SHA
id: get_sha
run: echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT

- name: Debug Git SHA
run: echo "Git SHA ${{ steps.get_sha.outputs.sha }}"

# Generate a sanitized platform string with slashes replaced by dashes
- name: Sanitize platform name
id: sanitize_platform
run: |
sanitized_platform="${{ matrix.platform }}" # Copy platform value
sanitized_platform="${sanitized_platform/\//-}" # Replace / with -
echo "sanitized_platform=$sanitized_platform" >> $GITHUB_OUTPUT

- name: Set up Docker Buildx
# https://github.com/docker/setup-buildx-action
uses: docker/setup-buildx-action@v3
with:
driver: docker-container # Use a container driver for Buildx (default)

- name: Log in to Docker Hub
# https://github.com/docker/login-action
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push Docker image
# https://github.com/docker/build-push-action
uses: docker/build-push-action@v6
with:
context: ./sleap_chrome_remote_desktop # Build context wrt the root of the repository
file: ./sleap_chrome_remote_desktop/Dockerfile # Path to Dockerfile wrt the root of the repository
platforms: ${{ matrix.platform }}
push: true # Push the image to Docker Hub
# Tags all include "-test" to differentiate from production images
tags: |
${{ vars.DOCKERHUB_USERNAME }}/sleap-chrome-remote-desktop:${{ steps.sanitize_platform.outputs.sanitized_platform }}-test
${{ vars.DOCKERHUB_USERNAME }}/sleap-chrome-remote-desktop:${{ steps.sanitize_platform.outputs.sanitized_platform }}-nvidia-cuda-11.3.1-cudnn8-runtime-ubuntu20.04-test
${{ vars.DOCKERHUB_USERNAME }}/sleap-chrome-remote-desktop:${{ steps.sanitize_platform.outputs.sanitized_platform }}-sleap-1.3.4-test
${{ vars.DOCKERHUB_USERNAME }}/sleap-chrome-remote-desktop:${{ steps.sanitize_platform.outputs.sanitized_platform }}-${{ steps.get_sha.outputs.sha }}-test
20 changes: 20 additions & 0 deletions sleap_chrome_remote_desktop/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "SLEAP VNC Container",
"build": {
"context": "..",
"dockerfile": "../Dockerfile"
},
"runArgs": [
"--gpus=all",
],
"customizations": {
"vscode": {
"settings": {
"terminal.integrated.defaultProfile.linux": "bash"
}
}
},
"postCreateCommand": "echo 'Devcontainer ready for use!'",
"remoteUser": "root"
}

19 changes: 19 additions & 0 deletions sleap_chrome_remote_desktop/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Ignore Python cache
__pycache__/
*.pyc
*.pyo

# Ignore virtual environments
env/
venv/

# Ignore version control and logs
.git/
*.log

# Ignore Docker build artifacts
docker/*.tmp

README.md
.gitignore
terraform/*
57 changes: 57 additions & 0 deletions sleap_chrome_remote_desktop/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Base image with SLEAP and GPU support
# https://hub.docker.com/repository/docker/eberrigan/sleap-cuda/general
FROM eberrigan/sleap-cuda:latest

# Install necessary packages for Chrome Remote Desktop
# psmisc and python3-psutil and python3-packaging and python3-xdg and libutempter0 for GCRD to work
RUN apt-get update && apt-get install -y \
wget \
curl \
gcc-10-base \
libgcc-s1 \
xfce4 \
desktop-base \
dbus-x11 \
xscreensaver \
xbase-clients \
xvfb \
python3-packaging \
python3-psutil \
psmisc \
xserver-xorg-video-dummy \
python3-xdg \
libutempter0 \
gnupg2 \
sudo \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

ENV DEBIAN_FRONTEND=noninteractive

# Install Google Chrome Remote Desktop
# RUN wget https://dl.google.com/linux/direct/chrome-remote-desktop_current_amd64.deb
# RUN dpkg --install chrome-remote-desktop_current_amd64.deb

RUN curl https://dl.google.com/linux/linux_signing_key.pub | gpg --dearmor -o /etc/apt/trusted.gpg.d/chrome-remote-desktop.gpg && \
# Add the Chrome Remote Desktop repository
echo "deb [arch=amd64] https://dl.google.com/linux/chrome-remote-desktop/deb stable main" > /etc/apt/sources.list.d/chrome-remote-desktop.list && \
# Update package lists and install Chrome Remote Desktop
apt-get update && apt-get install --assume-yes chrome-remote-desktop && \
# Clean up to reduce image size
apt-get clean && rm -rf /var/lib/apt/lists/*

RUN echo "exec /etc/X11/Xsession /usr/bin/xfce4-session" > /etc/chrome-remote-desktop-session

RUN systemctl disable lightdm.service

# Create the user hep003
RUN useradd -m -s /bin/bash hep003 && echo "hep003:password" | chpasswd && \
echo "hep003 ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/hep003 && \
chmod 0440 /etc/sudoers.d/hep003 && \
chown -R hep003:hep003 /home/hep003

# Add hep003 to the chrome-remote-desktop group
RUN usermod -aG chrome-remote-desktop hep003

# Set up Chrome Remote Desktop for the user
USER hep003
WORKDIR /home/hep003
Loading