-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b072d71
Showing
6 changed files
with
282 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
FROM ubuntu | ||
|
||
ENV SRC_DIR /app/lobster/dev | ||
|
||
ENV BUILD_DIR $SRC_DIR/build | ||
|
||
ENV DISPLAY :0 | ||
|
||
ENV USERNAME developer | ||
|
||
WORKDIR /app | ||
|
||
RUN apt update | ||
|
||
# Ubuntu specific issues | ||
# - DEBIAN_FRONTEND=noninteractive prevents from asking timezone | ||
# - --no-install-recommends prevents install extras | ||
# - specific deps for https | ||
# - apt-transport-https | ||
# - software-properties-common | ||
|
||
# Undocumented dep | ||
# - libxext-dev | ||
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ | ||
apt-transport-https sudo \ | ||
software-properties-common \ | ||
git cmake wget g++ mesa-common-dev libxext-dev | ||
|
||
RUN wget -qO /app/ninja.gz https://github.com/ninja-build/ninja/releases/latest/download/ninja-linux.zip \ | ||
&& gunzip /app/ninja.gz \ | ||
&& chmod a+x /app/ninja | ||
|
||
# link the executable so we can call it anywhere | ||
RUN ln -s /app/ninja /bin/ninja | ||
|
||
# the docs ended with .git | ||
# my preference is no extension | ||
RUN git clone https://github.com/aardappel/lobster | ||
|
||
# the docs didn't do this like this | ||
# my preference and seems to be best practice use a build dir | ||
RUN cmake -S $SRC_DIR -B $BUILD_DIR -G Ninja | ||
RUN ninja -C $BUILD_DIR | ||
|
||
# link the executable so we can call it anywhere | ||
RUN ln -s /app/lobster/bin/lobster /bin/lobster | ||
|
||
# create and switch to a user | ||
RUN echo "backus ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers | ||
RUN useradd --no-log-init --home-dir /home/$USERNAME --create-home --shell /bin/bash $USERNAME | ||
RUN adduser $USERNAME sudo | ||
USER $USERNAME | ||
|
||
WORKDIR /home/$USERNAME | ||
|
||
COPY bin . | ||
|
||
ENTRYPOINT ["lobster"] | ||
|
||
CMD ["main.lobster"] | ||
|
||
# Needs X11 on linux | ||
# CMD ["/app/lobster/samples/pythtree.lobster"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
FROM ubuntu | ||
|
||
ENV SRC_DIR /app/lobster/dev | ||
|
||
ENV BUILD_DIR $SRC_DIR/build | ||
|
||
ENV DISPLAY :0 | ||
|
||
ENV USERNAME developer | ||
|
||
WORKDIR /app | ||
|
||
RUN apt update | ||
|
||
# Ubuntu specific issues | ||
# - DEBIAN_FRONTEND=noninteractive prevents from asking timezone | ||
# - --no-install-recommends prevents install extras | ||
# - specific deps for https | ||
# - apt-transport-https | ||
# - software-properties-common | ||
|
||
# Undocumented dep | ||
# - libxext-dev | ||
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ | ||
apt-transport-https sudo \ | ||
software-properties-common \ | ||
git cmake make g++ mesa-common-dev libxext-dev | ||
|
||
# the docs ended with .git | ||
# my preference is no extension | ||
RUN git clone https://github.com/aardappel/lobster | ||
|
||
# the docs didn't do this like this | ||
# my preference and seems to be best practice use a build dir | ||
RUN cmake -S $SRC_DIR -B $BUILD_DIR | ||
RUN make -C $BUILD_DIR | ||
|
||
# link the executable so we can call it anywhere | ||
RUN ln -s /app/lobster/bin/lobster /bin/lobster | ||
|
||
# create and switch to a user | ||
RUN echo "backus ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers | ||
RUN useradd --no-log-init --home-dir /home/$USERNAME --create-home --shell /bin/bash $USERNAME | ||
RUN adduser $USERNAME sudo | ||
USER $USERNAME | ||
|
||
WORKDIR /home/$USERNAME | ||
|
||
COPY bin . | ||
|
||
ENTRYPOINT ["lobster"] | ||
|
||
CMD ["main.lobster"] | ||
|
||
# Needs X11 on linux | ||
# CMD ["/app/lobster/samples/pythtree.lobster"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# lobster-cli-hello-world | ||
|
||
## Description | ||
This is a POC project to demonstrate lobster, a cross between cpp and python. | ||
|
||
Supports X11 display forwarding from docker container. | ||
|
||
## Tech stack | ||
- lobster | ||
- gpp | ||
- cmake | ||
|
||
## Docker stack | ||
- ubuntu | ||
|
||
## To run | ||
`sudo ./install.sh -u` | ||
|
||
## To stop (optional) | ||
`sudo ./install.sh -d` | ||
|
||
## To see help | ||
`sudo ./install.sh -h` | ||
|
||
## Credit | ||
- [Offical docs](http://aardappel.github.io/lobster/getting_started.html) | ||
- [Docker X11 display forwarding](https://askubuntu.com/questions/1249043/run-simple-x11-app-in-docker-container-on-ubuntu-20-04) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
print("Hello, world!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[2023-08-29 09:15:53 INFO]: install::setup-logging ended | ||
================ | ||
[2023-08-29 09:15:53 INFO]: install::start-up started | ||
[2023-08-29 09:15:53 INFO]: install::start-up running image | ||
[2023-08-29 09:15:53 INFO]: install::start-up running image | ||
[2023-08-29 09:15:53 INFO]: install::start-up ended | ||
================ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
#!/usr/bin/env bash | ||
|
||
basefile="install" | ||
logfile="general.log" | ||
timestamp=`date '+%Y-%m-%d %H:%M:%S'` | ||
|
||
if [ "$#" -ne 1 ]; then | ||
msg="[ERROR]: $basefile failed to receive enough args" | ||
echo "$msg" | ||
echo "$msg" >> $logfile | ||
exit 1 | ||
fi | ||
|
||
function setup-logging(){ | ||
scope="setup-logging" | ||
info_base="[$timestamp INFO]: $basefile::$scope" | ||
|
||
echo "$info_base started" >> $logfile | ||
|
||
echo "$info_base removing old logs" >> $logfile | ||
|
||
rm -f $logfile | ||
|
||
echo "$info_base ended" >> $logfile | ||
|
||
echo "================" >> $logfile | ||
} | ||
|
||
function root-check(){ | ||
scope="root-check" | ||
info_base="[$timestamp INFO]: $basefile::$scope" | ||
|
||
echo "$info_base started" >> $logfile | ||
|
||
#Make sure the script is running as root. | ||
if [ "$UID" -ne "0" ]; then | ||
echo "[$timestamp ERROR]: $basefile::$scope you must be root to run $0" >> $logfile | ||
echo "==================" >> $logfile | ||
echo "You must be root to run $0. Try the following" | ||
echo "sudo $0" | ||
exit 1 | ||
fi | ||
|
||
echo "$info_base ended" >> $logfile | ||
echo "================" >> $logfile | ||
} | ||
|
||
function docker-check() { | ||
scope="docker-check" | ||
info_base="[$timestamp INFO]: $basefile::$scope" | ||
cmd=`docker -v` | ||
|
||
echo "$info_base started" >> $logfile | ||
|
||
if [ -z "$cmd" ]; then | ||
echo "$info_base docker not installed" | ||
echo "$info_base docker not installed" >> $logfile | ||
fi | ||
|
||
echo "$info_base ended" >> $logfile | ||
echo "================" >> $logfile | ||
|
||
} | ||
|
||
function usage() { | ||
echo "" | ||
echo "Usage: " | ||
echo "" | ||
echo "-u: start." | ||
echo "-d: tear down." | ||
echo "-h: Display this help and exit." | ||
echo "" | ||
} | ||
function start-up(){ | ||
|
||
scope="start-up" | ||
docker_img_name=`head -n 1 README.md | sed 's/# //'` | ||
info_base="[$timestamp INFO]: $basefile::$scope" | ||
|
||
echo "$info_base started" >> $logfile | ||
|
||
xhost + local:docker | ||
|
||
sudo docker build -t ${docker_img_name} . | ||
|
||
echo "$info_base running image" >> $logfile | ||
|
||
sudo docker run -ti --rm \ | ||
-v /tmp/.X11-unix:/tmp/.X11-unix ${docker_img_name} | ||
|
||
echo "$info_base running image" >> $logfile | ||
|
||
echo "$info_base ended" >> $logfile | ||
|
||
echo "================" >> $logfile | ||
} | ||
function tear-down(){ | ||
|
||
scope="tear-down" | ||
info_base="[$timestamp INFO]: $basefile::$scope" | ||
|
||
echo "$info_base started" >> $logfile | ||
|
||
echo "$info_base services removed" >> $logfile | ||
|
||
echo "$info_base ended" >> $logfile | ||
|
||
echo "================" >> $logfile | ||
} | ||
|
||
root-check | ||
docker-check | ||
|
||
while getopts ":udh" opts; do | ||
case $opts in | ||
u) | ||
setup-logging | ||
start-up ;; | ||
d) | ||
tear-down ;; | ||
h) | ||
usage | ||
exit 0 ;; | ||
/?) | ||
usage | ||
exit 1 ;; | ||
esac | ||
done |