Genesis icon indicating copy to clipboard operation
Genesis copied to clipboard

[MISC] Add minimal Dockerfile

Open yuxiang-gao opened this issue 10 months ago • 7 comments
trafficstars

This pull request adds a minimal workable Dockerfile to run Genesis.

To run it, first build the docker:

docker build -t genesis .

Then run it using the following command:

xhost +

docker run --gpus all --rm -it -e DISPLAY=$DISPLAY -v /tmp/.X11-unix/:/tmp/.X11-unix genesis python examples/tutorials/hello_genesis.py

yuxiang-gao avatar Dec 21 '24 10:12 yuxiang-gao

Thank you! Could you add something to readme with explanations?

zhouxian avatar Dec 21 '24 16:12 zhouxian

Thank you! Could you add something to readme with explanations?

Sure, happy to. I'll ping you once I'm finished.

yuxiang-gao avatar Dec 22 '24 11:12 yuxiang-gao

Can you add a docker-compose

https://github.com/ETSTribology/Genesis/blob/main/Dockerfile

my version

services:
  genesis:
    build:
      context: .
      dockerfile: Dockerfile
    image: genesis:latest
    runtime: nvidia
    environment:
      - DISPLAY=${DISPLAY}
    volumes:
      - /tmp/.X11-unix:/tmp/.X11-unix
    command: python examples/tutorials/hello_genesis.py
    deploy:
      resources:
        reservations:
          devices:
            - capabilities: [gpu]

antoinebou12 avatar Dec 22 '24 21:12 antoinebou12

Can you add a docker-compose

https://github.com/ETSTribology/Genesis/blob/main/Dockerfile

my version

services:
  genesis:
    build:
      context: .
      dockerfile: Dockerfile
    image: genesis:latest
    runtime: nvidia
    environment:
      - DISPLAY=${DISPLAY}
    volumes:
      - /tmp/.X11-unix:/tmp/.X11-unix
    command: python examples/tutorials/hello_genesis.py
    deploy:
      resources:
        reservations:
          devices:
            - capabilities: [gpu]

Thanks! I have included this version of compose file to this pull request.

yuxiang-gao avatar Dec 23 '24 03:12 yuxiang-gao

Hi @zhouxian , can you take a look? I have updated both the English and Chinese version of the READMEs. Also added a docker-compose.yml file and instructions thanks to @antoinebou12 .

yuxiang-gao avatar Dec 23 '24 03:12 yuxiang-gao

You could also make a action to auto deploy to dockerhub

name: Build and Push Docker Images

on:
  push:
    branches:
      - main
      - docker
  pull_request:
    branches:
      - main
      - docker

jobs:
  build-and-push-standard:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v3

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3

      - name: Log in to DockerHub
        uses: docker/login-action@v2
        with:
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PASSWORD }}

      - name: Cache Docker layers
        uses: actions/cache@v3
        with:
          path: /tmp/.buildx-cache
          key: docker-${{ runner.os }}-${{ hashFiles('Dockerfile', '**/*.cpp', '**/*.h') }}
          restore-keys: |
            docker-${{ runner.os }}-

      - name: Build and Push Standard Docker Image
        uses: docker/build-push-action@v5
        with:
          context: .
          file: Dockerfile
          push: true
          tags: ${{ secrets.DOCKER_USERNAME }}/Genesis:latest
          cache-from: type=local,src=/tmp/.buildx-cache
          cache-to: type=local,dest=/tmp/.buildx-cache,mode=max
          platforms: linux/amd64

      - name: Test Standard Docker Image
        run: |
          docker run --rm ${{ secrets.DOCKER_USERNAME }}/Genesis:latest --help

antoinebou12 avatar Dec 23 '24 18:12 antoinebou12

@Kashu7100 any idea how we proceed with this?

zhouxian avatar Dec 26 '24 16:12 zhouxian

Thanks for your contribution! However, we already have another commit for the Dockerfile. We will acknowledge your help in our next release notes!

YilingQiao avatar Feb 18 '25 04:02 YilingQiao