SBT incremental compilation with WebJars inside Docker - scala

I am working on Play! application with Angular 2 and webjars dependencies.
SBT play plugin and typescript plugin. I use incremental compilation, but it takes great amount of time on each recompilation. I set "sbt-optimizer" to check which tasks are longest one. And i see that on each recompilation WebJars are taking almost all the recompile time. I can't imagine why he needs to do something with static files after first compilation. But even if i change scala file or twirl template, it does not matter again all webjars.
UPD:
If i run on machine without Docker then speed is normal - recompile take few seconds.
Inside Docker - 200sec+.
Compilation messages without docker - 2s, inside docker - 13s.
Operations on screen without docker 10-300ms inside docker 500-60000ms.
UPD:
Adding my docker file
FROM openjdk:8
ENV SCALA_VERSION=2.12.1
ENV SBT_VERSION=0.13.13
ENV NODEJS_VERSION=6.10.0
# Install sbt
RUN cd /tmp && \
wget https://dl.bintray.com/sbt/native-packages/sbt/$SBT_VERSION/sbt-$SBT_VERSION.zip && \
unzip sbt-$SBT_VERSION.zip -d /usr/local && \
rm sbt-$SBT_VERSION.zip
#install nodejs for web jars
RUN cd /tmp && \
wget https://nodejs.org/dist/v$NODEJS_VERSION/node-v$NODEJS_VERSION-linux-x64.tar.xz && \
tar -C /usr/local --strip-components 1 -xJf node-v$NODEJS_VERSION-linux-x64.tar.xz &&
rm node-v$NODEJS_VERSION-linux-x64.tar.xz
Here is printout from optimizer:
May be i missed something, or someone had such problems, why SBT do that each time, and how can i prevent this?
Thank you

If you are running a mounted volume on Docker for Mac, you're probably hitting this issue with performance of mounted volumes.

Related

how to run an app with flutter-pi from a docker container

I'm running a flutter app on a raspberry pi 4, I'm using flutter-pi. Everything works fine, but I want to take it to a higher level.
I want to encapsulate the app and all flutter-pi dependencies in a docker container.
I am using the ubuntu:jammy image as a base, I have installed all the dependencies according to flutter-pi.
When I run the app I get this error:
[locales] Warning: The system has no configured locale. The default "C" locale may or may not be supported by the app.
[keyboard] Could not load keyboard configuration from "/etc/default/keyboard". Default keyboard config will be used. load_file: No such file or directory
[flutter-pi] Could not query DRM device list: No such file or directory
NOTE: the raspberry is configured to do a console auto login and does not have a graphical interface
I have developed a flutter-pi application and encapsulated it in a container.
What I noticed is that this error (Could not query DRM device list: No such file or directory) happens to me only sometimes, the configuration is always the same but sometimes I faced it and some times I didn't.
I'm assuming it is related with the host system in which the docker containers are running, because as I previously said the configuration of the container is always the same in both the working container and the not working one.
I'm attaching down below the configuration of my dockerfile (it's made of 2 dockerfiles but it's only 1 container that I'm running, the second dockerfile uses the first one which is built in emotionsrl/tower-display-base).
The display_launcher.py only runs the flutter (flutter-pi --release ./spotlink_build) after a few checks that are not related with the rest.
FROM ubuntu
RUN apt -y update \
&& apt -y install git \
&& apt -y install wget \
&& apt -y install build-essential
WORKDIR /TOWER_DISPLAY
# STEP 1 DIPENDENZE
RUN git clone --depth 1 \
https://github.com/ardera/flutter-engine-binaries-for-arm.git \
engine-binaries && cd engine-binaries && ./install.sh
# STEP 2 DIPENDENZE
ENV TZ=Europe/Rome
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt -y install cmake \
libgl1-mesa-dev \
libgles2-mesa-dev \
libegl1-mesa-dev \
libdrm-dev \
libgbm-dev
RUN DEBIAN_FRONTEND='noninteractive' apt -y install ttf-mscorefonts-installer
RUN apt -y install fontconfig \
libsystemd-dev \
libinput-dev \
libudev-dev \
libxkbcommon-dev
#STEP 3 DIPENDENZE
RUN fc-cache
###########################
# COMPILING
RUN git clone https://github.com/ardera/flutter-pi
WORKDIR /TOWER_DISPLAY/flutter-pi/build
RUN cmake ..
RUN make -j `nproc`
RUN make install
FROM emotionsrl/tower-display-base
WORKDIR /TOWER_DISPLAY
COPY spotlink_build ./spotlink_build
COPY display_launcher.py ./display_launcher.py
CMD python3 ./display_launcher.py

How to properly run SpotBugs on a Scala project

I'm trying to get SpotBugs run on Scala project using the SpotBugs CLI.
I installed the CLI like this:
$ curl -L -o /tmp/spotbugs-4.0.3.tgz https://github.com/spotbugs/spotbugs/releases/download/4.0.3/spotbugs-4.0.3.tgz
$ gunzip -c /tmp/spotbugs-4.0.3.tgz | tar xvf - -C /tmp
Then I run it like this
$ time java -jar /tmp/spotbugs-4.0.3/lib/spotbugs.jar -textui -xml:withMessages -html -output target/scala-2.11/spotbugs-report.html vad/target/scala-2.11/projectx-SNAPSHOT-assembly.jar
^Cjava -jar /tmp/spotbugs-4.0.3/lib/spotbugs.jar -textui -xml:withMessages -htm 2462.79s user 135.67s system 130% cpu 33:16.98 total
You can notice that it took more than 30mn without even have finished, I had to halt it.
It obviously seems that SpotBugs is not running properly here, so what am I doing wrong here?

Run Kitura Docker Image causes libmysqlclient.so.18 Error

after i had some previous problem to Dockerise my MySQL Kitura SETUP here : Docker Build Kitura Sqift Container - Shim.h mysql.h file not found
I am running in a new Problem i can not solve following the Guide from : https://www.kitura.io/docs/deploying/docker.html .
After i followed all the steps and also did the fixing on the MySQL issue previously i was now able to run the following command :
docker run -p 8080:8080 -it myapp-run
THis however leads to the following issue :
error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
i assume something tries again to open the libmysqclclient from some wrong Environmental Directories ?
But how can i fix this issues by building the docker images ... is there any way and better a smart way ?
Thanks a lot again for the help.
I was able to update and enhance my dockerfile this is now running smoothly and also can be used for CI and CD tasks.
FROM ibmcom/swift-ubuntu-runtime:latest
##FROM ibmcom/swift-ubuntu-runtime:5.0.1
LABEL maintainer="IBM Swift Engineering at IBM Cloud"
LABEL Description="Template Dockerfile that extends the ibmcom/swift-ubuntu-runtime image."
# We can replace this port with what the user wants
EXPOSE 8080
# Default user if not provided
ARG bx_dev_user=root
ARG bx_dev_userid=1000
# Install system level packages
RUN apt-get update && apt-get dist-upgrade -y
RUN apt-get update && apt-get install -y sudo libmysqlclient-dev
# Add utils files
ADD https://raw.githubusercontent.com/IBM-Swift/swift-ubuntu-docker/master/utils/run-utils.sh /swift-utils/run-utils.sh
ADD https://raw.githubusercontent.com/IBM-Swift/swift-ubuntu-docker/master/utils/common-utils.sh /swift-utils/common-utils.sh
RUN chmod -R 555 /swift-utils
# Create user if not root
RUN if [ $bx_dev_user != "root" ]; then useradd -ms /bin/bash -u $bx_dev_userid $bx_dev_user; fi
# Bundle application source & binaries
COPY ./.build /swift-project/.build
# Command to start Swift application
CMD [ "sh", "-c", "cd /swift-project && .build/release/Beautylivery_Server_New" ]

Run cloud-init cloud-config yaml file

How do I run, for development purposes, cloud-init yaml file that will be normally run via user-data?
I know how I can re-run cloud-init, but I want to develop complicated cloud-init file and to do that it is rather difficult to continually build new instances.
Sorry to say, you're going to have to run it on a new clean instance (or at least a snapshot of one). Even if you did manually go back and start at different steps, there are potentially side effects.
I think you'll find that if you get used to managing local VMs, you can debug your scripts fairly quickly.
The quickest path for iterating on user-data input to cloud-init is probably via lxd. You can quickly set up lxd on a vm host or a bare metal system. Once set up, launches are very quick.
$ cat ud.yaml
#cloud-config
runcmd:
- "read up idle < /proc/uptime; echo Up $up seconds | tee /run/runcmd.log"
$ lxc launch ubuntu-daily:bionic ud-test "--config=user.user-data=$(cat ud.yaml)"
Creating ud-test
Starting ud-test
$ lxc exec ud-test cat /run/runcmd.log
Up 8.05 seconds
$ lxc stop ud-test
$ lxc delete ud-test
You might be able to get away with just running cloud-init clean and then re-running it.
I'm experimenting with cloud-init and using an Ubuntu box with KVM as a virtualization lab. I made a simple Makefile to build the cloud-init image and launch it in an KVM instance.
You can see my code here:
https://github.com/brennancheung/playbooks/blob/master/cloud-init-lab/Makefile
all: clean build run
INSTANCE_NAME := "vm"
CLOUD_IMAGE_FILE = "bionic-server-cloudimg-amd64.img"
CLOUD_IMAGE_BASE_URL := "http://cloud-images.ubuntu.com/bionic/current"
CLOUD_IMAGE_URL := "$(CLOUD_IMAGE_BASE_URL)/$(CLOUD_IMAGE_FILE)"
download:
wget $(CLOUD_IMAGE_URL)
clean:
#echo "Removing build artifacts"
-#rm -f config.img 2>/dev/null
-#virsh destroy $(INSTANCE_NAME) 2>/dev/null || true
-#virsh undefine $(INSTANCE_NAME) 2>/dev/null || true
-#rm -f $(INSTANCE_NAME).img
build:
#echo "Building cloud config drive"
cloud-localds config.img config.yaml
cp $(CLOUD_IMAGE_FILE) $(INSTANCE_NAME).img
run:
#echo "Spawning instance $(INSTANCE_NAME)"
virt-install \
--name $(INSTANCE_NAME) \
--memory 8192 \
--disk ./$(INSTANCE_NAME).img,device=disk,bus=virtio \
--disk ./config.img,device=cdrom \
--os-type linux \
--os-variant ubuntu18.04 \
--virt-type kvm \
--graphics none \
--network bridge=br0
I am not sure why this answer is not here.. maybe it is not applicable for earlier versions.
All I do to re-run cloud-init for dev testing is (, especially when testing user-data changes):
1 - change the config file/files, usually only /etc/cloud/cloud.cfg
2 - run clean:
cloud-init clean -l
-l cleans the logs also
3 - re-run cloud-init
cloud-init init
of course, this has its limitations, depending on the settings you test, cloud-init clean is not going to revert the previous changes, but maybe you'll be able to figure out ways to test. For example I am testing the creation of new users, and every time I change something in the settings for a user and I want to test it.. I create a new user.
Yes, all this is quick in-development test, if you need to truly verify your changes - you need new instance.
Re-running all of cloud-init without system reboo isn't a recommended approach because some parts of cloud-init are run at systemd generator timeframe to detect new datasource types. That said, the following commands will allow you to accomplish this without reboot on a system.
cloud-init supports a clean subcommand to remove all semaphore files and allow cloud-init to re-run all config modules again. Beware that this will mean SSH host-keys are regenerated and .ssh config files re-written so it could impact your ability to get back into the VM.
To clean all semaphores so cloud-init modules will all re-run on next boot:
sudo cloud-init clean --logs
cloud-init typically runs multiple boot stages in sequence due to systemd service dependencies. If you want to repeat that process without a reboot you can run the following 4 commands:
Detect local datasource (cloud platform) and obtain user-data:
sudo cloud-init init --local
Detect any datasources and user-data which require network up and run cloud_init_modules defined in /etc/cloud/cloud.cfg:
sudo cloud-init init
Run all cloud_config_modules defined in /etc/cloud/cloud.cfg:
sudo cloud-init modules --mode=config
Run all cloud_final_modules defined in /etc/cloud/cloud.cfg:
sudo cloud-init modules --mode=final

How to install Grafana on Mac

I tied the following steps
cd $GOPATH/src/github.com/grafana/grafana
go run build.go setup
I got the following
Version: 2.5.0-pre1, Linux Version: 2.5.0, Package Iteration: pre1
go get -v github.com/tools/godep
github.com/tools/godep (download)
github.com/tools/godep/Godeps/_workspace/src/github.com/kr/fs
github.com/tools/godep/Godeps/_workspace/src/github.com/pmezard/go-difflib/difflib
github.com/tools/godep/Godeps/_workspace/src/golang.org/x/tools/go/vcs
github.com/tools/godep
go get -v github.com/blang/semver
github.com/blang/semver (download)
github.com/blang/semver
go get -v github.com/mattn/go-sqlite3
go install -v github.com/mattn/go-sqlite3
then i executed
$GOPATH/bin/godep restore
i got no putput but command got executed
then i ran the command
go run build.go build
Version: 2.5.0-pre1, Linux Version: 2.5.0, Package Iteration: pre1
rm -r bin
rm -r Godeps/_workspace/pkg
rm -r Godeps/_workspace/bin
rm -r dist
rm -r tmp
rm -r /Users/skhare/sk/go/pkg/darwin_amd64/github.com/grafana
rm -r ./bin/grafana-server
rm -r ./bin/grafana-server.md5
GOPATH=/Users/skhare/sk/go/src/github.com/grafana/grafana/Godeps/_workspace:/Users/skhare/sk/go
go build -ldflags -w -X main.version '2.5.0-pre1' -X main.commit 'v2.1.2+394- gfb767f5' -X main.buildstamp 1442671169 -o ./bin/grafana-server .
# github.com/grafana/grafana
link: warning: option -X main.version 2.5.0-pre1 may not work in future releases; use -X main.version=2.5.0-pre1
link: warning: option -X main.commit v2.1.2+394-gfb767f5 may not work in future releases; use -X main.commit=v2.1.2+394-gfb767f5
link: warning: option -X main.buildstamp 1442671169 may not work in future releases; use -X main.buildstamp=1442671169
then i executed
npm install
i had to install npm
>npm install -g grunt-cli
/usr/local/bin/grunt -> /usr/local/lib/node_modules/grunt-cli/bin/grunt
grunt-cli#0.1.13 /usr/local/lib/node_modules/grunt-cli
├── resolve#0.3.1
├── nopt#1.0.10 (abbrev#1.0.7)
└── findup-sync#0.1.3 (lodash#2.4.2, glob#3.2.11)
>grunt
Running "jscs:src" (jscs) task
>> 156 files without code style errors.
Running "jshint:source" (jshint) task
✔ No problems
Running "jshint:tests" (jshint) task
✔ No problems
Running "tslint:source" (tslint) task
>> 11 files lint free.
Running "clean:gen" (clean) task
Cleaning public_gen...OK
Running "copy:public_to_gen" (copy) task
Created 122 directories, copied 553 files
Running "less:src" (less) task
File public_gen/css/bootstrap.dark.min.css created.
File public_gen/css/bootstrap.light.min.css created.
File public_gen/css/bootstrap-responsive.min.css created.
Running "concat:cssDark" (concat) task
File public_gen/css/grafana.dark.min.css created.
Running "concat:cssLight" (concat) task
File public_gen/css/grafana.light.min.css created.
Running "typescript:build" (typescript) task
42 files created. js: 14 files, map: 14 files, declaration: 14 files (968ms)
Done, without errors.
>go get github.com/Unknwon/bra
the above command did not give any output, nor an error message
bra run
it says -bash: bra: command not found
i tried to look for the resolution, but i could not find it. Please help
Recompile backend on source change
To rebuild on source change (requires that you executed godep restore)
go get github.com/Unknwon/bra
bra run
Running Grafana Locally
You can run a local instance of Grafana by running:
./bin/grafana-server
You must have missed this step!
go get github.com/Unknwon/bra
You can install Grafana using home brew.
brew update
brew install grafana
This sounds like an issue where Go is just being installed to build something else (for me, it was Grafana). In which case $GOPATH/bin is not in your PATH. $GOPATH/bin/bra should work. It did for me.
I suggest you installing Grafana inside Docker. If you install Docker for Mac, the GUI (Kitematic) will allow you to install grafana as easily as one click. You will just need to create a new container with "+ New" button, search grafana through the exisiting image lists and click "Create"
Docker will download grafana and it will appear in the left sidebar: