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

Python support #7

Open
wants to merge 13 commits into
base: master
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker4bots/2_run_debug_container.sh
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

source $(dirname $0)/config.sh

Expand Down
21 changes: 21 additions & 0 deletions docker4bots/spn_python_base/Dockerfile
@@ -0,0 +1,21 @@
FROM alpine

RUN apk --no-cache add python3 py3-pip py3-numpy
RUN apk --no-cache add doxygen
RUN pip3 --no-cache-dir install pylint pylint-exit

RUN addgroup -S spnbot && adduser --uid 1337 --home /spnbot -S spnbot --shell /bin/sh -G spnbot

ADD bot_wrapper.sh /

ADD spn_python_framework/ /spnbot/spn_python_framework

# pre-build framework, hand it over to the spnbot user and create the shared memory directory
# (all in one step to save layers)
RUN cd /spnbot/spn_python_framework && chown -R spnbot /spnbot && mkdir /spnshm
VOLUME /spnshm
VOLUME /spndata

USER spnbot

ENTRYPOINT ["/bot_wrapper.sh"]
32 changes: 32 additions & 0 deletions docker4bots/spn_python_base/bot_wrapper.sh
@@ -0,0 +1,32 @@
#!/bin/sh -e

action="$1"

echo "Hello from the SPN Python container!"

case "$action" in
compile)
# copy the code in, build and move the binary out
cd /spnbot/spn_python_framework/

echo "starting pylint"
pylint /spndata/usercode.py || pylint-exit $?
;;

run)
# run the bot and allow coredumps
ulimit -c unlimited
cd /spnbot/spn_python_framework/src
./main.py
;;

doc)
cd /spnbot/spn_python_framework/
doxygen Doxyfile
mv doc/html/* /doc
;;

*)
echo "Invalid action: $action"
exit 1
esac