Files
Michael Hohn 77ce997fbb Major changes to support cli-end-to-end demonstration. See full log
* notes/cli-end-to-end-demo.org (Database Aquisition):
  Starting description for the end-to-end demonstration workflow.
  Very simplified version of notes/cli-end-to-end.org

* docker-compose-demo.yml (services):
  Make the pre-populated ql database storage an explicit container
  to get persistent data and straightforward mount semantics.

* docker-compose-demo-build.yml (services):
  Add a docker-compose configuration for *building* the demo environment.

* demo/containers/dbsdata/Dockerfile:
  Add dbsdata Docker image to hold initialized minio database file tree

* client/containers/vscode/README.org
  Update vscode container to use custom plugin for later mrva redirection
2024-10-15 10:18:42 -07:00
..

MRVA VS Code server container

On the host:

  # Build the container via 
  cd ~/work-gh/mrva/mrvacommander/client/containers/vscode/
  docker build -t code-server-initialized:0.1.24 .

  # Run the container in standalone mode via 
  cd ~/work-gh/mrva/mrvacommander/client/containers/vscode/
  docker run -v ~/work-gh/mrva/vscode-codeql:/work-gh/mrva/vscode-codeql \
         -d -p 9080:9080 code-server-initialized:0.1.24

Inside the container:

  • Setup inside the container

      cd 
      export PATH=/opt/codeql:$PATH
      codeql pack init qldemo
      cd qldemo
      codeql pack add codeql/python-all@1.0.6
  • Create a new file qldemo/simple.ql with this query. Open it in VS Code. The plugin will download the CodeQL binaries (but never use them the configuration redirects)

      cd
      cat > qldemo/simple.ql <<eof
      import python
      select 42
      eof
  • Create database.

      cd ~/qldemo
    
      cat > short.py <<EOF
      print('hello world')
      EOF
      export PATH=/opt/codeql:$PATH  
      codeql database create --language=python -s . -v short-db
  • Set the database as default and run the query simple.ql
  • Add the customized VS Code plugin On the host

      cd ~/work-gh/mrva/vscode-codeql
      git checkout mrva-standalone
    
      # Install nvm
      curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
    
      # Install correct node version 
      cd ./extensions/ql-vscode
      nvm install
    
      # Build the extension
      cd ~/work-gh/mrva/vscode-codeql/extensions/ql-vscode
      npm install
      npm run build

    In the container

      # Install extension
      cd /work-gh/mrva/vscode-codeql/dist
    
      /bin/code-server --force --install-extension vscode-codeql-*.vsix
  • Capture the state of this container and create a new image from it

      docker ps
      # Check id column.  Use it below.
      docker commit 2df5732c1850 code-server-initialized:0.1.24
      # Keep the sha
      # sha256:87c8260146e28aed25b094d023a30a015a958f829c09e66cb50ccca2c4a2a000
      docker kill 2df5732c1850
    
      # Make sure the image tag matches the sha
      docker inspect code-server-initialized:0.1.24 |grep Id
    
      # Run the image and check
      docker run --rm -d -p 9080:9080 --name test-code-server-codeql \
             code-server-initialized:0.1.24

    Again connect to it at http://localhost:9080/?folder=/home/coder, password is mrva.

  • Push this container

      # Common
      export CSI_TARGET=code-server-initialized:0.1.24
    
      # Push container
      docker tag ${CSI_TARGET} ghcr.io/hohn/${CSI_TARGET}
      docker push ghcr.io/hohn/${CSI_TARGET}
  • Test the registry image

      # Test pushed container
      docker pull ghcr.io/hohn/${CSI_TARGET}
      docker run --rm -d -p 9080:9080 --name test-code-server-codeql\
             ghcr.io/hohn/${CSI_TARGET}

    In the container, inside the running vs code:

    • Check the plugin version number via the command

      codeql: copy version information