How to deploy a Scala/Akka application? - scala

I'm developing an application which subscribes to Instagram real times updates(Users). I need to provide an urlcallback in order to receive the users updates.
Curl -F 'client_id=CLIENT-ID' \
-F 'client_secret=CLIENT-SECRET' \
-F 'object=user' \
-F 'aspect=media' \
-F 'verify_token=myVerifyToken' \
-F 'callback_url=http://YOUR-CALLBACK/URL' \
https://api.instagram.com/v1/subscriptions/
Now my application is running on localhost.
How can I deploy a Scala application in order to have a real urlcallback?

Configure sbt-native-packager at your project by modifying build.sbt and project/plugins.sbt files.
Build your application using sbt-native-packager, either on your local machine or on a build server like Jenkins. This creates a zip, docker image, rpm or Debian. In case you run an Debian type server like Ubuntu, the Debian file would be the easiest choice.
Upload the just created file to your server, using for example scp or rsync. The files created by the build are located in the target directory of your project.
Install your app on your server. In case you are running a Debian type server like Ubuntu and created a Debian file at the build process, a simple dpkg -i will install your app.
In your case you should install a proxy like nginx and configure your app as an nginx backend. See: http://nginx.org/en/docs/http/ngx_http_upstream_module.html

you could use sbt-assembly plugin, make a fat jar with "sbt assembly" in the console and then do java -jar aplication.jar.

There are a couple of ways to deploy your Scala application. If it is a web application, then you can package that application in a .war file and deploy on any machine which has a web server.The another option is you can use an AWS EC2 instance or AWS Elasticbeanstalk service to deploy your .war file.In any case,your urlCallback would be "http://:/"

Related

Deploying custom Kong plugin in GKE deployed Kong API Gateway

I'm looking up on the Kong API gateway and deployed a Kong instance on GKE via Google Cloud Marketplace. I want to add a custom Kong plugin to this instance and enable it for my services. How could I do it? are there any resources I could follow to get an idea on this? thank you.
if you are using docker
you can install any plugin in kong using luarocks
For example here is one sample docker file
FROM kong
ENV LUA_PATH /usr/local/share/lua/5.1/?.lua;/usr/local/kong-oidc/?.lua;;
# For lua-cjson
ENV LUA_CPATH /usr/local/lib/lua/5.1/?.so;;
# Install unzip for luarocks, gcc for lua-cjson
RUN yum install -y unzip gcc
RUN luarocks install luacov
here one example of oidc plugin : https://github.com/nokia/kong-oidc
we can install plugin using : luarocks install <plugin name>
build your own custom docker image and use kong image as base docker image.
here whole example working Dockerfile
FROM kong:latest
USER root
RUN apk update && apk add git unzip luarocks
RUN luarocks install kong-oidc
USER kong
by this way also you can add some of the community plugin and enterprise plugin in docker.
You could either bake the custom plugin into your container image, or modify your Deployment manifest to download and run the plugin with command and arguments in the configuration.
For the first option, you only need to add the commands to install and run the plugin to your Dockerfile, then build an image with docker build. Once you have the new image, you can perform a rolling update by using kubectl set image deployment or modify the workload in the Cloud Console.
Modifying the Deployment YAML would have a similar result, but you would need to add command and arguments to download and run the custom plugin whenever the container starts.
The google-marketplace-kong-app and kong-dist-kubernetes repo has instructions on how to build and deploy Kong manually. I'd recommend checking them and include your custom plugin.

Play 2.5.6 application on Tomcat or any alternative?

I have created an application on Play framework 2.5.6. I am trying to find out what is the best way to deploy the application on production. I have tomcat installed on my Ubuntu machine. How to create war file and How to deploy on tomcat? I am using Scala Eclipse IDE for development.
Have a look at this other thread which is very similar to what you're asking here (albeit directed at GAE).
In a nutshell, the disadvantages of deploying your app to Tomcat are:-
you have extra work to do to package your application as a WAR
extra work to deploy it
your application may not be fully asynchronous running in Tomcat
As that outdated documentation suggests - the simplest way of deploying your app in production is just using the version of Netty which is packaged as part of a Play application. See the relevant version of the docs to create a distribution. You only need a relevant version of a JVM on your prod server in this case.
The flow is generally:-
Run $ dist to build the binary (this is a zip by default, but you can also build a tar if you prefer using $ universal:packageZipTarball instead of dist).
Move it into your Linux production environment
Unpack it
Set permissions if you build a zip $ chmod +x /path/to/bin/<project-name> (not required if you created the tar)
Run the app start script (created by the dist task) eg. $ target/universal/stage/bin/<project-name>

drools workbench in cloudfoundry.

I am trying to deploy drools workbench in cloudfoundry. I am not able to push a docker image to my company's CF env, but these docker images works in my local PCF Dev.
So, I pushed a war file to my CF env.
cf push kie -p kie-drools-wb-distribution-wars-6.4.0.Final-wildfly8.war -b jboss-buildpack-offline -m 2g -k 2g -t 180
the application is running in CF. But I am not sure how to get launch the application, to see login page and workbench.
Please help.
Looking at the Dockerfile for drools-workbench (https://hub.docker.com/r/jboss/drools-workbench/~/dockerfile/) it appears to start the workbench using bin/start_drools-wb.sh file, however the JBoss buildpack appears to start the application using standalone.sh
Perhaps you should look at how the application should be started and adapt the start command.

Deploying to Heroku with my persistence.xml (JPA) without using Spring

I have an error in application deployment with "git push master heroku" while locally it works fine.
I want to use my persistence.xml for access to my data base of H2 (I will be use maybe PostgreSQL) all with my data source on WildFly 10.
I found no reference other than the Spring. (I can not use it)
Thank you!
I've deployed JavaEE web app (with jsf, javabean, ejb, di etc) on Heroku. Heroku will allow you to run shell script for starting your application like class with a main method or executable .jar file. Not on the pre installed fullstack application server. Also if you gonna run java app on Heroku your project should be maven.
To make it work from command line you can use cloud ready run anywhere tiny servers like payara-micro, wildfly-swarm, spring-boot. It turns your app and server into single executable jar (Uber JAR). Also tomcat and jetty have wrappers for build uberJar.
I use payara-micro and it's great that very little jar can run almost all of JavaEE features with session replication. Follow this link for instructions payara-micro how to (read also maven parts).
When you git push to Heroku(with heroku cli tool) it will automatically builds your project and run script from file called Procfile from your project root directory. Sample procfile:
web: java -jar target/myapp.jar --port $PORT
Consider $PORT part from above snippet. When Heroku runtime (dyno) starts it will open random port (I think so) and bind to $PORT environment variable. So here I'm passing that accessibe port to payara-micro server for listen. Other mentioned servers should work with similar procedures. You can find documentations at heroku devcenterr
For JPA and database connectivity Heroku provides JDBC_DATABASE_URL and DATABASE_URL environment variables that have connection information (url etc) for you to connect database. I couln't find the way to hook up those variables into persistence.xml. But you can create and configure EntityManagerFactory and EntityManager programmatically.
Hope it helps.

how to download the applications from my cloudbees account to local directory for modification

I am trying to create and deploy a grails application on the cloud bees i tried using both, cloud-bees sdk and as well as the eclipse sdk . I don't no much how to use the cloud bees sdk so I tried using the eclipse sdk.
In eclipse SDK the command is being executed but only thing fails is that it throws an error, now I want to create and deploy the application on the cloud.
Can you please help me?
You should use the CloudBees SDK to deploy a Grails application on CloudBees platform.
You can find the documentation here.
Basically, you can see on the doc these are the steps in the case you don't need database binding:
Create your application
bees app:create -a my-app jvmPermSize=128
Setting the Grails Environment of the Tomcat server
bees config:set -a my-app -P grails.env=production
Deploy your application
bees app:deploy -a my-app target/my-app-0.1.war
You can generate the war file of your application using the command below:
grails war