WIP: Working individual containers and docker compose demo

This commit is contained in:
Michael Hohn
2024-09-12 09:49:25 -07:00
committed by =Michael Hohn
parent 259bac55fb
commit 34958e4cf4
9 changed files with 175 additions and 126 deletions

View File

@@ -118,6 +118,12 @@ docker-compose.
cd ~/work-gh/mrva/mrvacommander cd ~/work-gh/mrva/mrvacommander
docker-compose up --build docker-compose up --build
1. Start the server containers and the desktop/demo containers
cd ~/work-gh/mrva/mrvacommander/
docker-compose down --remove-orphans
docker-compose -f docker-compose-demo.yml up -d
1. Test server via remote client by following the steps in [gh-mrva](https://github.com/hohn/gh-mrva/blob/connection-redirect/README.org#compacted-edit-run-debug-cycle) 1. Test server via remote client by following the steps in [gh-mrva](https://github.com/hohn/gh-mrva/blob/connection-redirect/README.org#compacted-edit-run-debug-cycle)
### Some general docker-compose commands ### Some general docker-compose commands

View File

@@ -14,9 +14,6 @@ RUN go mod download
# Build the Go binary # Build the Go binary
RUN go build . RUN go build .
# # Set the entrypoint
# CMD ["/bin/bash"]
# Use a minimal base image for the final container # Use a minimal base image for the final container
FROM debian:bookworm FROM debian:bookworm
@@ -26,5 +23,5 @@ WORKDIR /app
# Copy the binary from the builder stage # Copy the binary from the builder stage
COPY --from=builder /work-gh/mrva/gh-mrva/gh-mrva /usr/local/bin/gh-mrva COPY --from=builder /work-gh/mrva/gh-mrva/gh-mrva /usr/local/bin/gh-mrva
# Set the entrypoint to the binary # Run forever
ENTRYPOINT ["gh-mrva"] CMD ["tail", "-f", "/dev/null"]

View File

@@ -25,5 +25,6 @@ RUN pip install -r requirements.txt
# Install qldbtools # Install qldbtools
RUN pip install . RUN pip install .
# Set the default entrypoint # Run forever
CMD ["/bin/bash"] CMD ["tail", "-f", "/dev/null"]

View File

@@ -0,0 +1,24 @@
DBT_TARGET := client-qldbtools-container:0.1.24
# Build the qldbtools container image
dbt: client-qldbtools-container
client-qldbtools-container:
docker build -t ${DBT_TARGET} .
touch $@
# Run a shell in the container with the qldbtools
dbt-run: dbt
docker run --rm -it ${DBT_TARGET} /bin/bash
# Run one of the scripts in the container as check. Should exit with error.
dbt-check: dbt
docker run --rm -it ${DBT_TARGET} mc-db-initial-info
dbt-push: dbt
docker tag ${DBT_TARGET} ghcr.io/hohn/${DBT_TARGET}
docker push ghcr.io/hohn/${DBT_TARGET}
touch $@
dbt-test:
docker pull ghcr.io/hohn/${DBT_TARGET}
docker run --rm -it --name test-dbt-server ghcr.io/hohn/${DBT_TARGET} sh

View File

@@ -1,18 +1,13 @@
* MRVA python tools container * MRVA python tools container
Set upDocker image with python 3.11 and pip and the qldbtools Set up Docker image with python 3.11 and pip and the qldbtools. The targets are
in the =Makefile=; most important are
#+BEGIN_SRC sh #+BEGIN_SRC sh
# Build # Build
cd ~/work-gh/mrva/mrvacommander
make dbt make dbt
# Check # Check
cd ~/work-gh/mrva/mrvacommander
make dbt-check make dbt-check
# Use
cd ~/work-gh/mrva/mrvacommander
make dbt-run
#+END_SRC #+END_SRC

View File

@@ -56,7 +56,9 @@ ENV CODEQL_JAVA_HOME=/usr
# to user settings. # to user settings.
# This is in addition to the environment variable CODEQL_JAVA_HOME which has no # This is in addition to the environment variable CODEQL_JAVA_HOME which has no
# effect on the plugin # effect on the plugin
USER root
COPY ./settings.json /home/coder/.local/share/code-server/User/ COPY ./settings.json /home/coder/.local/share/code-server/User/
RUN chown -R coder:coder /home/coder/.local/share/code-server/
# Start Code Server # Start Code Server
ENTRYPOINT ["dumb-init", "code-server", "--bind-addr", "0.0.0.0:9080", "."] ENTRYPOINT ["dumb-init", "code-server", "--bind-addr", "0.0.0.0:9080", "."]

View File

@@ -17,6 +17,7 @@
- Setup inside the container - Setup inside the container
#+BEGIN_SRC shell #+BEGIN_SRC shell
cd
export PATH=/opt/codeql:$PATH export PATH=/opt/codeql:$PATH
codeql pack init qldemo codeql pack init qldemo
cd qldemo cd qldemo
@@ -26,9 +27,12 @@
- Open a new file =qldemo/simple.ql= and add this this query to it. The plugin - Open a new file =qldemo/simple.ql= and add this this query to it. The plugin
will download the CodeQL binaries (but never use them -- the configuration will download the CodeQL binaries (but never use them -- the configuration
redirects) redirects)
#+BEGIN_SRC java #+BEGIN_SRC sh
cd
cat > qldemo/simple.ql <<eof
import python import python
select 42 select 42
eof
#+END_SRC #+END_SRC
- Create database. - Create database.
@@ -42,7 +46,7 @@
codeql database create --language=python -s . -v short-db codeql database create --language=python -s . -v short-db
#+END_SRC #+END_SRC
- Set the database as default and run the query. - Set the database as default and run the query on =simple.ql=
- Capture the state of this container and create a new image from it - Capture the state of this container and create a new image from it
#+BEGIN_SRC sh #+BEGIN_SRC sh
@@ -53,8 +57,6 @@
#+END_SRC #+END_SRC
- Push this container - Push this container
[[file:~/work-gh/mrva/mrvacommander/client/containers/vscode/Makefile::image-push: image]]
#+BEGIN_SRC sh #+BEGIN_SRC sh
docker images |head
make csi-push make csi-push
#+END_SRC #+END_SRC

View File

@@ -1,4 +1,4 @@
{ {
"codeQL.runningQueries.numberOfThreads": 2, "codeQL.runningQueries.numberOfThreads": 2,
"codeQl.cli.executablePath": "/opt/codeql" "codeQL.cli.executablePath": "/opt/codeql/codeql"
} }

View File

@@ -1,14 +1,44 @@
services: services:
code-server: mrvadata:
image: codercom/code-server image: ghcr.io/hohn/mrvadata:0.1.24
ports: container_name: mrvadata
- "9080:8080"
volumes: volumes:
- ./project:/home/coder/project - mrvadata:/data/mrvacommander
- ~/.config/code-server:/home/coder/.config/code-server networks:
- ~/.local/share/code-server:/home/coder/.local/share/code-server - backend
client-qldbtools:
image: ghcr.io/hohn/client-qldbtools-container:0.1.24
volumes:
# data at /data/mrvacommander/qldbtools/scratch
- mrvadata:/data/mrvacommander
depends_on:
- mrvadata
networks:
- backend
client-ghmrva:
# XX: redirect by changing code or using nginx proxy
# client.Get(fmt.Sprintf("http://localhost:8080/repos/%s/code-scanning/codeql/variant-analyses/%d", controller, runId), &response)
image: ghcr.io/hohn/client-ghmrva-container:0.1.24
volumes:
- mrvadata:/data/mrvacommander
depends_on:
- mrvadata
networks:
- backend
code-server:
image: ghcr.io/hohn/code-server-initialized:0.1.24
ports:
- "9080:9080"
volumes:
- mrvadata:/data/mrvacommander
environment: environment:
- PASSWORD=mrva - PASSWORD=mrva
depends_on:
- mrvadata
rabbitmq: rabbitmq:
image: rabbitmq:3-management image: rabbitmq:3-management
@@ -20,33 +50,30 @@ services:
ports: ports:
- "5672:5672" - "5672:5672"
- "15672:15672" - "15672:15672"
networks:
- backend
healthcheck: healthcheck:
test: rabbitmq-diagnostics check_port_connectivity test: rabbitmq-diagnostics check_port_connectivity
interval: 30s interval: 30s
timeout: 30s timeout: 30s
retries: 10 retries: 10
networks:
- backend
server: server:
build: image: ghcr.io/hohn/mrva-server:0.1.24
context: .
dockerfile: ./cmd/server/Dockerfile
command: [ '--mode=container', '--loglevel=debug' ] command: [ '--mode=container', '--loglevel=debug' ]
container_name: server container_name: server
stop_grace_period: 1s stop_grace_period: 1s
ports: ports:
# - "8081:8080" # host:container for proxy
- "8080:8080" # host:container - "8080:8080" # host:container
depends_on: depends_on:
- rabbitmq - rabbitmq
- dbstore - dbstore
- artifactstore - artifactstore
networks:
- backend
env_file: env_file:
- path: ./.env.container - path: ./.env.container
required: true required: true
networks:
- backend
dbstore: dbstore:
image: minio/minio:RELEASE.2024-06-11T03-13-30Z image: minio/minio:RELEASE.2024-06-11T03-13-30Z
@@ -57,15 +84,12 @@ services:
env_file: env_file:
- path: .env.container - path: .env.container
required: true required: true
command: server /data/mrvacommander/dbstore-data --console-address ":9001"
command: server /data --console-address ":9001" depends_on:
# Demo: Mount preloaded minio backing store - mrvadata
volumes: volumes:
- type: volume # data at /data/mrvacommander/dbstore-data
source: dbstore-volume - mrvadata:/data/mrvacommander
target: /data/dbs
volume:
nocopy: true
networks: networks:
- backend - backend
@@ -80,14 +104,15 @@ services:
required: true required: true
command: server /data --console-address ":9001" command: server /data --console-address ":9001"
volumes: volumes:
- ./qpstore-data:/data # data at /data/mrvacommander/qpstore-data
- mrvadata:/data/mrvacommander
# XX: use multiple storage containers?
# - ./qpstore-data:/data
networks: networks:
- backend - backend
agent: agent:
build: image: ghcr.io/hohn/mrva-agent:0.1.24
context: .
dockerfile: ./cmd/agent/Dockerfile
command: [ '--loglevel=debug' ] command: [ '--loglevel=debug' ]
container_name: agent container_name: agent
depends_on: depends_on:
@@ -104,8 +129,5 @@ networks:
backend: backend:
driver: bridge driver: bridge
# Demo: Provide preloaded minio backing store
volumes: volumes:
dbstore-volume: mrvadata:
external: true
name: dbstore-container:/data