|
Post by Pjot on Jan 11, 2023 20:10:57 GMT 1
All,
For those of you interested in using BaCon from a Docker container, it can be done.
An interesting advantage is that all required dependencies for compilation are kept within the container, and that the BaCon installation files do not clutter your filesystem.
The following is a Dockerfile. Simply put it in the source tree of BaCon:
FROM debian:bullseye-slim
RUN apt update RUN apt install -y build-essential libtcmalloc-minimal4 flex indent ksh
COPY . /usr/src/bacon WORKDIR /usr/src/bacon
RUN LDFLAGS=-l:libtcmalloc_minimal.so.4 ./configure RUN make RUN make install
WORKDIR /tmp
Then build the Docker image with name 'bacon' using the command:
# docker build -t bacon .
When done, the image has to be invoked with some arguments. To make sure that BaCon generates binaries with your UID/GID we have to provide these in the 'docker run' command. Also, we need to set a home directory explicitly, as BaCon wants to write down some settings.
This example should work:
# docker run --rm --volume $(pwd):/tmp --user "$(id -u):$(id -g)" --env HOME=/tmp bacon:latest bacon myapp.bac
The current directory is visible in the container because of the --volume argument. Because of the provided UID/GID, BaCon will create a binary with the correct rights.
Obviously, such large command line can be scripted as well.
Regards Peter
|
|
|
Post by bigbass on Jan 17, 2023 2:37:19 GMT 1
Hello Peter
Thanks for the Docker image for BaCon!
was unsure if the little RPI3 would be able to get the job done and build the bacon image (limited RAM) but gave it a try anyhow
Good news!
sudo docker run --rm --volume $(pwd):/tmp --user "$(id -u):$(id -g)" --env HOME=/tmp bacon:latest bacon -v
BaCon version 4.6 on Linux armv7l - (c) Peter van Eerten - MIT License.
Thanks will be able to run some tests tomorrow but its all set up now
joe@raspberrypi:~/bacon-4.6 $ sudo docker image ls REPOSITORY TAG IMAGE ID CREATED SIZE bacon latest ce7031272709 3 hours ago 264MB debian bullseye-slim 9dcb173f25a7 5 days ago 56.6MB
Joe P.S
on a related thought outside of the docker image just the normal OS we can compile using PRAGMA LDFLAGS -ltcmalloc_minimal tested to be working with Qt5 baconized apps!
apt-get install libtcmalloc-minimal4
PRAGMA LDFLAGS -ltcmalloc_minimal
|
|
|
Post by bigbass on Jan 17, 2023 17:23:04 GMT 1
Hello Peter
Here is some feed back from another box the RPI3
well I had to start over so that I didn't need to use sudo no problem but it should be noted the difference from my first post as you see now running rootless
Snip from the command
docker info
Security Options: seccomp Profile: default rootless cgroupns Kernel Version: 5.15.61-v7+ Operating System: Raspbian GNU/Linux 11 (bullseye) OSType: linux Architecture: armv7l CPUs: 4 Total Memory: 807.2MiB
First check
#shortened the command to see if bacon is working only
docker run bacon:latest bacon -v BaCon version 4.6 on Linux armv7l - (c) Peter van Eerten - MIT License.
Second check if we can build a bacon app using the command you provided but adding some details
# some notes presteps I created a simple file called test.bac and placed it on my normal OS in /tmp #which for simplicity just contains a PRINT command #PRINT "Hello Moby"
docker run --rm --volume $(pwd):/tmp --user "$(id -u):$(id -g)" --env HOME=/tmp bacon:latest bacon test.bac Converting 'test.bac'... done, 2 lines were processed in 0.208 seconds. Creating lexical analyzer using flex... done. Compiling 'test.bac'... cc -c test.bac.c cc -o test test.bac.o -lm Done, program 'test' ready.
Third check see if the app runs after it was compiled from the docker image
joe@raspberrypi:/tmp $ ./test Hello Moby
all is working thanks for your bacon docker image ! Joe
next step bacon apps as docker images ...
|
|
|
Post by Pjot on Jan 17, 2023 18:06:42 GMT 1
Thanks Joe, All looks as if it works as intended On my systems, I always use the 'libtcmalloc-minimal4', or, if this is not available, libjemalloc. These libraries provide a 'malloc' and 'calloc' which are a lot faster than the defaults from libc, boosting the BaCon performance approx. 20-40%. Best regards, Peter
|
|
|
Post by bigbass on Jan 17, 2023 18:44:30 GMT 1
Hello Peter
yes, working well
on the last note of libtcmalloc-minimal4 I tested it on Qt5 c++ mixed with bacon works too
yes and this works for me to keep it a bit easier
export COMPILE=" --rm --volume $(pwd):/tmp --user $(id -u):$(id -g) --env HOME=/tmp bacon:latest bacon"
then we can just type this (for the lazy people in the house)
docker run $COMPILE test.bac Converting 'test.bac'... done, 2 lines were processed in 0.002 seconds. Creating lexical analyzer using flex... done. Compiling 'test.bac'... cc -c test.bac.c cc -o test test.bac.o -lm Done, program 'test' ready.
P.S special note when I rebuilt the docker image apt wouldnt allow me to build again I needed to replace apt for apt-get in the Dockerfile then it rebuilt correctly
Joe
|
|
|
Post by Pjot on Jan 18, 2023 18:16:59 GMT 1
Thanks Joe, I'll change the "apt" to "apt-get". I didn't run into this issue myself, because I kept removing old images when testing Best regards Peter
|
|
|
Post by bigbass on Jan 20, 2023 19:05:12 GMT 1
|
|
|
Post by Pjot on Jan 21, 2023 8:20:06 GMT 1
Thanks Joe for sorting that out! I actually was wondering how to get the GUI working I guess we can safely add the GUI packages to the Docker file now as well. Best regards, Peter
|
|
|
Post by bigbass on Jan 22, 2023 18:21:08 GMT 1
Hello Peter
I think it is a very good idea to have a working minimal bacon docker and am thankful you set up one for bacon!
For me I will refer to it as "official bacon docker" with bacon cli (Because you did it)
of course for your work In bacon there are several GUI apps In at least gtk2 gtk3 and fltk and it makes sense to be able to test those on multiple OS and archs adding whatever is needed to do just that
and so we dont overwrite this docker We can make new ones
such as bacon-qt5 bacon-gtk3 bacon-fltk and maybe bacon-N-eggs and we include everything possible
It sounds like a little joke there but being serious. It saves more space to have one big docker Than many small ones When you run everything on a 16GB sd card
But then again the small dockers are great for app testing too
So its a win ,win
Nice to see That you are always expanding bacon install and testing options
Joe
|
|
|
Post by Pjot on Jan 23, 2023 20:54:39 GMT 1
In bacon there are several GUI apps In at least gtk2 gtk3 and fltk Hi Joe, Actually, the current GTK editor is getting old and bloated and becomes hard to maintain. So I have recreated the GTK version from scratch, now using the native GUI functions.
I have tried to align its functionality with the built-in ASCII editor.
Note that the amount of code went down from almost 3500 lines to a mere 266 lines
The autoconf macros for GTK2, GTK3 and GTK4 are there, however, currently only the GTK3 version works. For GTK4, it seems that a suitable webkit is not available in the repos yet.
The editor is still in beta, it still needs a few more tweaks, but you're interested then you can download the new version here. BR Peter
|
|
|
Post by bigbass on Jan 24, 2023 1:38:23 GMT 1
Hello Peter
Wow shaving off several hundreds of lines anytime is impressive but when you shave off about 3200 lines and give us a great example of your bacon GUI code ported at only 266 lines !
I set up a clean install of raspbian with only the docker code installed so I could test the new beta
I might not have everything installed yet and it is the first try using gtkwebkit2 in the docker but I was able to build and run the bacon gui editor
some tech notes I fully understand this is beta testing so its just some feedback not a bug report
the new main gui editor compiled correctly in its input
but the bacon scratch pad gave some errors just used PRINT "hello"
maybe we could quiet it with -Wno-implicit-function-declaration
---------------------------------------- Converting '/dev/shm/scratchpad.bac'... done, 1 lines were processed in 0.001 seconds. Creating lexical analyzer using flex... done. Compiling '/dev/shm/scratchpad.bac'... cc -c scratchpad.bac.c scratchpad.bac.c:13:1: warning: implicit declaration of function '__b2c__argument'; did you mean '__b2c__ulen'? [-Wimplicit-function-declaration]
INFO: see full error report (y/[n])? y scratchpad.bac.c: In function 'main': scratchpad.bac.c:13:1: warning: implicit declaration of function '__b2c__argument'; did you mean '__b2c__ulen'? [-Wimplicit-function-declaration] 13 | __b2c__argument(&ARGUMENT$, argc, argv); | ^~~~~~~~~~~~~~~ | __b2c__ulen scratchpad.bac.c:17:1: warning: implicit declaration of function '__b2c__timer'; did you mean '__b2c__blen'? [-Wimplicit-function-declaration] 17 | __b2c__timer(1); | ^~~~~~~~~~~~ | __b2c__blen scratchpad.bac.c:19:16: error: '__b2c__catch_signal' undeclared (first use in this function); did you mean '__b2c__catch_set'? 19 | signal(SIGILL, __b2c__catch_signal); | ^~~~~~~~~~~~~~~~~~~ | __b2c__catch_set scratchpad.bac.c:19:16: note: each undeclared identifier is reported only once for each function it appears in make: *** [Makefile.bacon:6: scratchpad.bac.o] Error 1
---------------------------------
EDITED I needed to install xterm ! the gui bacon editor needs xterm
I edited your Dockerfile to this worked adding the deps and added --no-install-recommends to reduce the size
# --------------------------------------------------------------------- # # Create the Docker image with: # docker build -t bacon . # # Run the BaCon converter as follows: # docker run --rm --volume $(pwd):/tmp --user "$(id -u):$(id -g)" --env HOME=/tmp bacon:latest bacon myapp.bac # # ---------------------------------------------------------------------
FROM debian:bullseye-slim
#added deps for new bacon GUI bacongui-gtk3.bac needs xterm RUN apt-get update && apt-get install --no-install-recommends -y \ build-essential libtcmalloc-minimal4 flex \ indent ksh xterm libgtksourceview-4-dev libwebkit2gtk-4.0-dev
COPY . /usr/src/bacon WORKDIR /usr/src/bacon
RUN LDFLAGS=-l:libtcmalloc_minimal.so.4 ./configure RUN make RUN make install
WORKDIR /tmp
#1.) build the images
docker build -t bacon-webkit2gtk .
#2.) #First check to see if bacon is working only
docker run bacon-webkit2gtk:latest bacon -v
#3.) #add the docker to the list that X11 can use in its display
xhost +local:
#4.) #shorten a long line of code
export X2DOCKER=" -it -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$DISPLAY bacon-webkit2gtk"
#5.) #run the new bacon editor gui inside the docker
docker run $X2DOCKER bacongui-gtk
joe@raspberrypi:~/Downloads/bacon-f05636859b/bacon_trunk $ docker image ls REPOSITORY TAG IMAGE ID CREATED SIZE bacon-webkit2gtk latest 92128b604d7a 7 minutes ago 686MB debian bullseye-slim 9dcb173f25a7 12 days ago 56.6MB
Extras ---------------------------------------------
A nice trick is cd into your normal os /tmp
then
docker run -it --entrypoint /bin/bash bacon-webkit2gtk
you can run bash inside the docker
cd .. ls
bin dev home media opt root sbin sys usr boot etc lib mnt proc run srv tmp var
you can run anything now
Joe
|
|
|
Post by bigbass on Jan 24, 2023 19:16:11 GMT 1
Hello Peter I figured out the scratch pad issue in a docker
I just changed bacongui-gtk3.bac from CONST Scratch_Temp$ = "/dev/shm/scratchpad.bac" to CONST Scratch_Temp$ = "/tmp/scratchpad.bac" might just be a problem from inside a docker but anyway it works now *I dont know if this is only docker related because I haven't tested yet outside of the docker but anyway this should be a simple way to just test it and you may have another reason for using shm which is fine Joe P.S I am using your latest beta from fossil another thing I forgot to say that's a nice option having the bacon -r (RUN it) ! Joe
|
|
|
Post by Pjot on Jan 25, 2023 17:50:44 GMT 1
Thanks again Joe,
Regarding that '/dev/shm', this usually is a virtual disk in memory, and commonly used for temporary files.
In Docker, indeed this will not be accessible, so I will change it to '/tmp' as you recommend.
In the meantime, I am working on a GTK4 port of the editor, hope to finalize this by the end of the week.
Best regards Peter
|
|
|
Post by bigbass on Jan 26, 2023 20:24:16 GMT 1
Hello Peter
sounds great a new GUI updated to handle up to GTK4 that is forward looking to stay ahead of the game and should note its the first time without embedding gtk just using your new GUI code 100%
will check that on Manjaro when you get it finished for testing!
I am a little slow on feedback setting up a new box and at the same time testing ideas on docker
I had time today to install bacon via fossil beta and test outside of the docker
all is fine only one small note for you to check in the bacongui-gtk3.bac
the Help menu---> Documentation points to the home folder .bacon
and .bacon is empty after an install I manually copied the files there and it works now or you want to point to /usr/share/BaCon/documentation ? and did that just for testing anyway ...
here is a copy of the installers output to give you some better feedback
Joe -------------------------------------------------------------------------- joe@raspberrypi:~/Downloads/bacon-cd4b1a5f31/bacon_trunk $ sudo make install mkdir -p /usr/bin mkdir -p /usr/share/applications /usr/bin/install -c bacon.sh /usr/bin /usr/bin/install -c build/bacon /usr/bin /usr/bin/install -c build/bacongui-gtk3 /usr/bin/bacongui-gtk mkdir -p /usr/share/gtksourceview-4/language-specs /usr/bin/install -c syntax/bacon.lang /usr/share/gtksourceview-4/language-specs/bacon.lang /usr/bin/install -c -m 644 bacongui-gtk.desktop /usr/share/applications mkdir -p /usr/share/icons/hicolor/scalable/apps /usr/bin/install -c -m 644 icons/BaCon.png /usr/share/icons/hicolor/scalable/apps/bacon.png gtk-update-icon-cache update-icon-caches /usr/share/icons/hicolor/* mkdir -p /usr/share/man/man1 /usr/bin/install -c -m 644 bacon.1 /usr/share/man/man1 mkdir -p /usr/share/pixmaps /usr/bin/install -c -m 644 icons/BaCon.png /usr/share/pixmaps /usr/bin/install -c -m 644 icons/BaCon.xbm /usr/share/pixmaps /usr/bin/install -c -m 644 icons/BaCon24.png /usr/share/pixmaps /usr/bin/install -c -m 644 icons/BaConEyes.png /usr/share/pixmaps mkdir -p /usr/share/enscript/hl /usr/bin/install -c -m 644 syntax/bacon.st /usr/share/enscript/hl mkdir -p /usr/share/BaCon /usr/bin/install -c -m 644 LICENSE /usr/share/BaCon mkdir -p /usr/share/BaCon/syntax /usr/bin/install -c -m 644 syntax/lower.m4 /usr/share/BaCon/syntax /usr/bin/install -c -m 644 syntax/upper.m4 /usr/share/BaCon/syntax /usr/bin/install -c -m 644 syntax/bacon.vim /usr/share/BaCon/syntax /usr/bin/install -c -m 644 syntax/bacon.lang /usr/share/BaCon/syntax mkdir -p /usr/share/BaCon/documentation /usr/bin/install -c -m 644 documentation/documentation.txt /usr/share/BaCon/documentation /usr/bin/install -c -m 644 documentation/documentation.html /usr/share/BaCon/documentation /usr/bin/install -c -m 644 documentation/doc_index.html /usr/share/BaCon/documentation /usr/bin/install -c -m 644 documentation/doc_frame.html /usr/share/BaCon/documentation joe@raspberrypi:~/Downloads/bacon-cd4b1a5f31/bacon_trunk $
|
|
|
Post by Pjot on Jan 29, 2023 7:44:35 GMT 1
Thanks Joe, The ~/.bacon directory should contain the at least the documentation files, I'll fix it shortly. Regarding GTK4, after fiddling around with this toolkit the last couple of days, I found it is a complete nightmare! For example, some widgets and properties do not seem to work properly (like the 'monospace' setting for the GtkTextView, or the 'gtk_file_chooser_get_filename' function when the dialog is set to GTK_FILE_CHOOSER_ACTION_OPEN), some widgets and containers have been replaced completely, where additional configuration should be done in GIO (like the menu structure), some properties have different names or have disappeared altogether (like GTK_WIN_POS_CENTER). Also, the whole approach of a structured widget hierarchy in a object/property model is broken. In many cases, the argument for these changes are they're are 'not portable'. In many cases there's no argument at all. As far as I am concerned, at this point, GTK4 is way too beta and immature to be used for something useful. Besides, there's no suitable Webkit for GTK4 available yet (other than trying to compile the source code together with GTK4 ourselves). They even rewrote their documentation in such a way that it is inconvenient to find things back. For some reason, GTK4 now talks about 'classes' and 'interfaces' while it is based on plain C and not some object-oriented paradigma. I mean, why is everybody so much in love with this OOP? All the GTK4 stuff has been a huge disappointment, and honestly, I got so frustrated, that decided to look around for alternatives. There are two more toolkits which follow the idea of 'object/property' and widget hierarchy, on of which also follows the concept of setting all properties right away per widget (like the GUI functions in BaCon).
That is the good old 'Tk' toolkit, which seems to integrate fairly easy: PRAGMA OPTIONS `pkg-config --cflags tk tcl` PRAGMA LDFLAGS `pkg-config --libs tk tcl` PRAGMA INCLUDE <tcl.h> <tk.h>
FUNC hello(ClientData d, Tcl_Interp *i, int argc, const char **argv) TYPE int PRINT "Hello" RETURN TCL_OK ENDFUNC
LOCAL interp TYPE Tcl_Interp*
CALL Tcl_FindExecutable(argv[0])
interp = Tcl_CreateInterp()
IF Tcl_Init(interp) = TCL_ERROR THEN EPRINT Tcl_GetStringResult(interp) FORMAT "No TCL INIT possible: %s\n" END TCL_ERROR ENDIF
IF Tk_Init(interp) = TCL_ERROR THEN EPRINT Tcl_GetStringResult(interp) FORMAT "No TK INIT possible: %s\n" END TCL_ERROR ENDIF
CALL Tcl_CreateCommand(interp, "hello", hello, (ClientData)0, NULL)
CALL Tcl_Eval(interp, \ "package require Tk\n" \ "wm title . \"Testing TK\"\n" \ "text .txt -width 50 -height 20 -wrap none \n" \ "pack .txt\n" \ "button .b -text \"Say Hello\" -command hello\n" \ "pack .b -padx 5 -pady 5 -side right\n" \ "focus .txt\n")
CALL Tk_MainLoop()
It may not be the most beautiful set of widgets, but it is well maintained and fully functional. The text with original Tk definitions is very similar as to what we're doing in BaCon. It should not be much work to add this to the current BaCon implementation. The other toolkit is IUP. This toolkit has been recommended to me in the past. However, it does not come with prebuilt installers, and compiling the code from scratch is a bit tedious (but doable). They do have prebuilt libraries but only for Debian based systems. Next to that, they rely heavily on GTK3, which we already can use fairly easy. Lastly, there have been no changes for the last 2.5 years, which may be of concern. On the positive side, the IUP toolkit is complete including HTML renderer and a text widget with syntax highlighting based on Scintilla. Furthermore it follows a very strict 'object/property' model with an easy layout manager. Best regards Peter
|
|