Set up and push Docker containers for demonstration purposes
These containers take the place of a desktop install
This commit is contained in:
committed by
=Michael Hohn
parent
681fcdab8c
commit
1e2df515e3
12
client/containers/ghmrva/README.org
Normal file
12
client/containers/ghmrva/README.org
Normal file
@@ -0,0 +1,12 @@
|
||||
* MRVA cli tools container
|
||||
Set up via
|
||||
#+BEGIN_SRC sh
|
||||
# Build
|
||||
cd ~/work-gh/mrva/mrvacommander/
|
||||
make ghm
|
||||
# Run
|
||||
docker run --rm gh-mrva
|
||||
# Push
|
||||
make ghm-push
|
||||
#+END_SRC
|
||||
|
||||
@@ -4,14 +4,6 @@ FROM busybox
|
||||
# This data container holds data from existing runs. It cannot be built without
|
||||
# ready data.
|
||||
|
||||
# Before running docker build, make sure you have set up the directory mirrors
|
||||
# dbstore-data and scratch.
|
||||
|
||||
# E.g.:
|
||||
# cd ~/work-gh/mrva/mrvacommander/client/containers/mrvadata/
|
||||
# mkdir tmp
|
||||
# cp -r ../../../dbstore-data tmp
|
||||
# cp -r ../../qldbtools/scratch tmp
|
||||
|
||||
# Mirror parts of the host directory structure in the container
|
||||
COPY tmp/dbstore-data /data/mrvacommander/dbstore-data
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
all: image
|
||||
|
||||
image:
|
||||
docker build -t mrvadata .
|
||||
|
||||
image-shell: image
|
||||
docker run --rm -it mrvadata sh
|
||||
|
||||
image-push: image
|
||||
docker tag mrvadata ghcr.io/hohn/mrvadata:0.1.24
|
||||
docker push ghcr.io/hohn/mrvadata:0.1.24
|
||||
|
||||
image-test:
|
||||
docker pull ghcr.io/hohn/mrvadata:0.1.24
|
||||
docker run --rm -it --name test-mrvadata ghcr.io/hohn/mrvadata:0.1.24 sh
|
||||
|
||||
86
client/containers/mrvadata/REAME.org
Normal file
86
client/containers/mrvadata/REAME.org
Normal file
@@ -0,0 +1,86 @@
|
||||
* Data container for demonstration
|
||||
Contains [[https://github.com/hohn/mrva-open-source-download.git][mrva-open-source-download]] repo and some downloads.
|
||||
|
||||
This container has several non-trivial build prerequisites which is why it
|
||||
exists in the first place. The [[*Building the container][Building the container]] instructions are intended
|
||||
for building it /after/ much work has been done, to make it easy to share that
|
||||
work with others.
|
||||
|
||||
If you just want to use the container, see [[*Using the container][Using the container]]
|
||||
|
||||
** Using the container
|
||||
To get and test this image, run the container via the following
|
||||
#+BEGIN_SRC sh
|
||||
docker pull ghcr.io/hohn/mrvadata:0.1.24
|
||||
docker run --rm -it --name test-mrvadata ghcr.io/hohn/mrvadata:0.1.24 sh
|
||||
#+END_SRC
|
||||
|
||||
Inside the container, check the contents via
|
||||
#+BEGIN_SRC sh
|
||||
ls /data/mrvacommander/qldbtools/*
|
||||
ls /data/mrvacommander/dbstore-data/*
|
||||
#+END_SRC
|
||||
|
||||
This should be something of the form
|
||||
#+BEGIN_SRC text
|
||||
/ # ls /data/mrvacommander/qldbtools/*
|
||||
|
||||
cp-dbs-to-upload.txt db-info-1.csv gh-mrva-selection.json
|
||||
cp-gh-mrva-selection.json db-info-2.csv selection-full-info
|
||||
cp-vscode-selection.json db-info-3.csv vscode-selection.json
|
||||
|
||||
/ # ls /data/mrvacommander/dbstore-data/*
|
||||
|
||||
BoomingTech$Piccoloctsj6d7177.zip mawww$kakounectsjc54fab.zip
|
||||
KhronosGroup$OpenXR-SDKctsj984ee6.zip microsoft$node-native-keymapctsj4cc9a2.zip
|
||||
OpenRCT2$OpenRCT2ctsj975d7c.zip nem0$LumixEnginectsjfab756.zip
|
||||
StanfordLegion$legionctsj39cbe4.zip pocoproject$pococtsj26b932.zip
|
||||
USCiLab$cerealctsj264953.zip quickfix$quickfixctsjebfd13.zip
|
||||
WinMerge$winmergectsj101305.zip rui314$moldctsjfec16a.zip
|
||||
draios$sysdigctsj12c02d.zip swig$swigctsj78bcd3.zip
|
||||
gildor2$UEViewerctsjfefdd8.zip tdlib$telegram-bot-apictsj8529d9.zip
|
||||
git-for-windows$gitctsjb7c2bd.zip timescale$timescaledbctsjf617cf.zip
|
||||
google$orbitctsj9bbeaf.zip xoreaxeaxeax$movfuscatorctsj8f7e5b.zip
|
||||
libfuse$libfusectsj7a66a4.zip xrootd$xrootdctsje4b745.zip
|
||||
luigirizzo$netmapctsj6417fa.zip
|
||||
|
||||
#+END_SRC
|
||||
|
||||
|
||||
|
||||
** Building the container
|
||||
|
||||
The Dockerfile is used to make an image contain data; it uses busybox as
|
||||
base.
|
||||
|
||||
Steps to build this image from a preloaded minio instance[fn:1].
|
||||
|
||||
- Prepare data. This requires that a minio instance has already been populated
|
||||
and will be documented in the future.
|
||||
# TODO
|
||||
#+BEGIN_SRC sh
|
||||
cd ~/work-gh/mrva/mrvacommander/client/containers/mrvadata/ && \
|
||||
rm -fR tmp && \
|
||||
mkdir tmp
|
||||
cp -r ../../../dbstore-data tmp
|
||||
cp -r ../../qldbtools/scratch tmp
|
||||
#+END_SRC
|
||||
|
||||
- Make image
|
||||
#+BEGIN_SRC sh
|
||||
cd ~/work-gh/mrva/mrvacommander/client/containers/mrvadata/
|
||||
docker build -t mrvadata .
|
||||
#+END_SRC
|
||||
|
||||
- Tag and Push to GHCR
|
||||
#+BEGIN_SRC sh
|
||||
echo $GHCR_GITHUB_TOKEN | docker login ghcr.io -u hohn --password-stdin
|
||||
|
||||
cd ~/work-gh/mrva/mrvacommander/client/containers/mrvadata
|
||||
docker tag mrvadata ghcr.io/hohn/mrvadata:0.1.24
|
||||
docker push ghcr.io/hohn/mrvadata:0.1.24
|
||||
#+END_SRC
|
||||
|
||||
* Footnotes
|
||||
|
||||
[fn:1] This is itself effort, hence the creation of this image.
|
||||
18
client/containers/qldbtools/README.org
Normal file
18
client/containers/qldbtools/README.org
Normal file
@@ -0,0 +1,18 @@
|
||||
* MRVA python tools container
|
||||
Set upDocker image with python 3.11 and pip and the qldbtools
|
||||
|
||||
#+BEGIN_SRC sh
|
||||
# Build
|
||||
cd ~/work-gh/mrva/mrvacommander
|
||||
make dbt
|
||||
|
||||
# Check
|
||||
cd ~/work-gh/mrva/mrvacommander
|
||||
make dbt-check
|
||||
|
||||
# Use
|
||||
cd ~/work-gh/mrva/mrvacommander
|
||||
make dbt-run
|
||||
|
||||
#+END_SRC
|
||||
|
||||
65
client/containers/vscode/Dockerfile
Normal file
65
client/containers/vscode/Dockerfile
Normal file
@@ -0,0 +1,65 @@
|
||||
FROM codercom/code-server:4.92.2-debian
|
||||
|
||||
# ======================
|
||||
# Pre-install a custom JDK for this platform and redirect CodeQL to it
|
||||
|
||||
USER root
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# Install packages
|
||||
RUN apt-get update && apt-get install --no-install-recommends --assume-yes \
|
||||
ca-certificates \
|
||||
curl \
|
||||
default-jdk \
|
||||
git \
|
||||
libcurl4-openssl-dev \
|
||||
libssl-dev \
|
||||
python3 \
|
||||
python3-dev \
|
||||
unzip
|
||||
|
||||
# Build argument for CodeQL version, defaulting to the latest release
|
||||
ARG CODEQL_VERSION=latest
|
||||
|
||||
# If the version is 'latest', get the latest release version from GitHub, unzip
|
||||
# the bundle into /opt, and delete the archive
|
||||
RUN if [ "$CODEQL_VERSION" = "latest" ]; then \
|
||||
CODEQL_VERSION=$(curl -s https://api.github.com/repos/github/codeql-cli-binaries/releases/latest | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/'); \
|
||||
fi && \
|
||||
echo "Using CodeQL version $CODEQL_VERSION" && \
|
||||
curl -L "https://github.com/github/codeql-cli-binaries/releases/download/$CODEQL_VERSION/codeql-linux64.zip" -o /tmp/codeql.zip && \
|
||||
unzip /tmp/codeql.zip -d /opt && \
|
||||
rm /tmp/codeql.zip && \
|
||||
chmod -R +x /opt/codeql
|
||||
|
||||
# ======================
|
||||
# Install code-server
|
||||
USER coder
|
||||
|
||||
# Set environment variables
|
||||
ENV PASSWORD mrva
|
||||
|
||||
# Install VS Code extensions as user root -- globally
|
||||
RUN code-server --install-extension ms-python.python \
|
||||
&& code-server --install-extension esbenp.prettier-vscode \
|
||||
&& code-server --install-extension GitHub.vscode-codeql
|
||||
|
||||
# Expose the port that Code Server runs on
|
||||
EXPOSE 9080
|
||||
|
||||
# Point CodeQL to the java binary for this platform
|
||||
ENV CODEQL_JAVA_HOME=/usr
|
||||
|
||||
# Add
|
||||
# codeQl.cli.executablePath
|
||||
# to user settings.
|
||||
# This is in addition to the environment variable CODEQL_JAVA_HOME which has no
|
||||
# effect on the plugin
|
||||
COPY ./settings.json /home/coder/.local/share/code-server/User/
|
||||
|
||||
# Start Code Server
|
||||
ENTRYPOINT ["dumb-init", "code-server", "--bind-addr", "0.0.0.0:9080", "."]
|
||||
|
||||
# Run as the coder user
|
||||
USER coder
|
||||
26
client/containers/vscode/Makefile
Normal file
26
client/containers/vscode/Makefile
Normal file
@@ -0,0 +1,26 @@
|
||||
all: code-server-initialized
|
||||
|
||||
CSI_TARGET := code-server-initialized:0.1.24
|
||||
csi: code-server-initialized
|
||||
code-server-initialized:
|
||||
docker build -t ${CSI_TARGET} .
|
||||
touch $@
|
||||
|
||||
csi-serve: csi
|
||||
docker run -d -p 9080:9080 ${CSI_TARGET}
|
||||
|
||||
clean:
|
||||
-docker rmi -f ${CSI_TARGET}
|
||||
-rm code-server-initialized
|
||||
|
||||
# Targets below are used after some manual setup of the container. See README.org
|
||||
# for details
|
||||
|
||||
csi-push: csi
|
||||
docker tag ${CSI_TARGET} ghcr.io/hohn/${CSI_TARGET}
|
||||
docker push ghcr.io/hohn/${CSI_TARGET}
|
||||
touch $@
|
||||
|
||||
csi-test:
|
||||
docker pull ghcr.io/hohn/${CSI_TARGET}
|
||||
docker run --rm -it --name test-code-server-codeql ghcr.io/hohn/${CSI_TARGET} sh
|
||||
60
client/containers/vscode/README.org
Normal file
60
client/containers/vscode/README.org
Normal file
@@ -0,0 +1,60 @@
|
||||
* MRVA VS Code server container
|
||||
On the host:
|
||||
|
||||
- Build the container via
|
||||
#+BEGIN_SRC sh
|
||||
make csi
|
||||
#+END_SRC
|
||||
|
||||
- Run the container via
|
||||
#+BEGIN_SRC sh
|
||||
make csi-serve
|
||||
#+END_SRC
|
||||
|
||||
- Connect to it at http://localhost:9080/?folder=/home/coder, password is =mrva=.
|
||||
|
||||
Inside the container:
|
||||
|
||||
- Setup inside the container
|
||||
#+BEGIN_SRC shell
|
||||
export PATH=/opt/codeql:$PATH
|
||||
codeql pack init qldemo
|
||||
cd qldemo
|
||||
codeql pack add codeql/python-all@1.0.6
|
||||
#+END_SRC
|
||||
|
||||
- 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
|
||||
redirects)
|
||||
#+BEGIN_SRC java
|
||||
import python
|
||||
select 42
|
||||
#+END_SRC
|
||||
|
||||
- Create database.
|
||||
#+BEGIN_SRC sh
|
||||
cd ~/qldemo
|
||||
|
||||
cat > short.py <<EOF
|
||||
print('hello world')
|
||||
EOF
|
||||
export PATH=/opt/codeql:$PATH
|
||||
codeql database create --language=python -s . -v short-db
|
||||
#+END_SRC
|
||||
|
||||
- Set the database as default and run the query.
|
||||
|
||||
- Capture the state of this container and create a new image from it
|
||||
#+BEGIN_SRC sh
|
||||
docker ps
|
||||
docker commit 0c15aeeaa914 code-server-initialized:0.1.24
|
||||
docker kill 0c15aeeaa914
|
||||
docker run -d -p 9080:9080 code-server-initialized:0.1.24
|
||||
#+END_SRC
|
||||
|
||||
- Push this container
|
||||
[[file:~/work-gh/mrva/mrvacommander/client/containers/vscode/Makefile::image-push: image]]
|
||||
#+BEGIN_SRC sh
|
||||
docker images |head
|
||||
make csi-push
|
||||
#+END_SRC
|
||||
4
client/containers/vscode/settings.json
Normal file
4
client/containers/vscode/settings.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"codeQL.runningQueries.numberOfThreads": 2,
|
||||
"codeQl.cli.executablePath": "/opt/codeql"
|
||||
}
|
||||
Reference in New Issue
Block a user