Heroku Procfile increases slug size dramatically - heroku

I have a scala + play (2.3) app, which I deploy on heroku. When there is no Procfile defined, the app deploys and runs without any problems (heroku detects that this is a scala play application). The slug size is 89MB
However, when I add a very simple Procfile:
web: target/universal/stage/bin/app_name -Dconfig.resource=application-heroku.conf
where application-heroku.conf is just a copy of my application.conf (I wanted to create separate application.confs for dev and prod)
the slug size increases to 380MB and the application fails to deploy (as the limit is 300MB).
Am I doing something wrong?

Something is preventing the buildpack from clearing out the build artifacts before preparing the slug. Do you see these lines in your build output:
-----> Dropping ivy cache from the slug
-----> Dropping sbt boot dir from the slug
-----> Dropping project boot dir from the slug
-----> Dropping compilation artifacts from the slug
If not, can you confirm that either
You have a conf/application.conf file in your project (even if you don't use it)
Or you have the sbt-native-packager dependency in your project/plugins.sbt
If neither of these is true, the buildpack cannot safe clear the build artifacts. If you do not have a conf/application.conf try adding one -- even if it's an empty place holder.
If you do see those "Dropping" lines in your build output, and are still getting a slug that is too big, then check that you are not using a custom buildpack (i.e. that your BUILDPACK_URL is not set).

Related

Gitlab CI - Auto DevOps job failed, Unable to select a buildpack for a Go project?

My Gitlab CI Auto DevOps job failed with
Status: Downloaded newer image for gliderlabs/herokuish:latest
-----> Unable to select a buildpack
ERROR: Job failed: exit code 1
I've gone through
Auto DevOps and
Getting started with Auto DevOps
and am still not sure where I should put the buildpack.
Mine should be heroku-buildpack-go, which I've lost track where I get that from.
My repo consist only a single-character README.md, and the "Hello, playground" main.go.
Conclusion:
Thanks to David's comprehensive explanation, I was able to get DevOps started with correct buildpack:
From this I would conclude that your single .go file at the root of the directory tree does not meet the activation criteria for auto-building Go projects. I'd suggest picking one of the dependency managers in the requirements above and modifying your project to support it.
FTA, I just did touch go.mod then git add & git push and the AutoDevops started building my GO project indeed.
However it seems to me that Gitlab AutoDevops is not able to build any GO projects very easily, as I get the following error (with project variable TRACE=true):
...
!! The go.mod file for this project does not specify a Go version
!!
!! Defaulting to go1.11.1
!!
!! For more details see: https://devcenter.heroku.com/articles/go-apps-with-modules#build-configuration
!!
-----> Installing go1.11.1
-----> Fetching go1.11.1.linux-amd64.tar.gz... done
!! Installing package '.' (default)
!!
!! To install a different package spec add a comment in the following form to your `go.mod` file:
!! // +heroku install ./cmd/...
!!
!! For more details see: https://devcenter.heroku.com/articles/go-apps-with-modules#build-configuration
!!
-----> Running: go install -v -tags heroku .
go: cannot determine module path for source directory /tmp/build (outside GOPATH, no import comments)
ERROR: Job failed: exit code 1
The easier solution is to use .gitlab-ci.yml file instead, documented in
https://blog.boatswain.io/post/build-go-project-with-gitlab-ci/
(and followed up at Gitlab CI - Start Shared Runner for normal repos).
From the AutoDevops documentation:
Auto Build creates a build of the application in one of two ways:
If there is a Dockerfile, it will use docker build to create a Docker image.
Otherwise, it will use Herokuish and Heroku buildpacks to automatically detect and build the application into a Docker image.
Then looking at the build activation criteria, as per the Heroku Go buildpack documentation:
This buildpack will detect your repository as Go if you are using either:
go modules
dep
govendor
glide
GB
Godep
Or more specifically for godep, govendor or GB:
The Heroku Go buildpack is used when an application meets one of the following requirements:
has a Godeps/Godeps.json file, identifying the application as being managed by godep;
has a vendor/vendor.json file, identifying the application as being managed by govendor;
has a src directory, which has sub directories, contains one or more .go files, identifying the application as being managed by gb.
From this I would conclude that your single .go file at the root of the directory tree does not meet the activation criteria for auto-building Go projects. I'd suggest picking one of the dependency managers in the requirements above and modifying your project to support it. After that AutoDevops should start building your project.
If you are still having issues after that, this debugging note might help:
After making sure that the project meets the buildpack requirements;
if it still fails, setting a project variable TRACE=true will enable verbose logging which​ may help to continue troubleshooting.

jhipster : angularjs files and browser cache

I am developping a Jhipster web app.
My problem is that when I update some angularjs files and then deploy the new war file in Tomcat7 the modifications are not taken into account, the clients pc is still reading the old angularjs file.
Is there a way(or a jhipster configuration) to tell the client pc to reload all angularjs file in order to be up to date?
Thanks you.
When you build your app with prod profile using mvn -Pprod package or gradlew -Pprod bootRepackage the web assets are minified and prefixed with a unique code in dist folder. An older version of same file has a different prefix so if it is cached it will not prevent the new one from being loaded.
If you don't see this behavior, it's probably because you didn't set the spring.profiles.active property to prod in Tomcat and so your app is running in dev mode and not using the files from dist.
If your frontend and backend are in the same war: 0.0.1-SNAPSHOT change this version in pom.xml before making a build to avoid angular caching issues.
If your frontend is split then go to: gulp/utils.js and change this version: '0.0.5-SNAPSHOT';

Deploy WebSharper.Suave web application to Heroku

I can not understand what I need to change to make it.
I created a demo project from this blogpost with app.json and Procfile:
web: fsharpi-heroku WebsahrperSuaveHerokuExample1.sln
Next, I tried to deploy it to Heroku in accordance with these recommendations:
heroku create websahrper-with-suave-example --buildpack https://github.com/SuaveIO/mono-script-buildpack.git
heroku git:remote -a websahrper-with-suave-example
git push heroku master
There was an error in Heroku when building the project:
...
Import process completed.
-----> packages.config found, installing dependencies with nuget
Cannot open assembly 'install': No such file or directory.
! Push rejected, failed to compile SuaveFramework app
Could you suggest me a solution if there is one?
Have you tried here:
https://github.com/SuaveIO/heroku-getting-started
Fork it and click the Deploy to Heroku button.
Don't have the rep to comment on the above, but ademar's solution should cover as well as long as you don't have a file named "app.fsx"
The heroku buildpack checks to see if there is a script, then checks for a solution:
https://github.com/SuaveIO/mono-script-buildpack/blob/master/bin/compile#L66
Just make sure there is a .sln file in the project directory (can be empty, just needs to be present) or fork the buildpack and just make it default run mono $YOURPROJECT in the compile step.
When using an sln instead of a script, you need to change your Procfile to:
web: mono Path/execName.exe

How do the results of /bin/compile in a Heroku buildpack relate to the slug?

Does anyone know for sure exactly how the bin/compile phase of a buildpack relates to the slug and deployment? Does the entire BUILD_DIR from the compile phase get tgz'd and unpacked at /app?
Yes, as specified in the buildpack documentation:
The application in BUILD_DIR along with all changes made by the compile script will be packaged into a slug.

Can I have a playframework 2.0 webapp and a maven based worker process on heroku?

I have an existing webapp on heroku that needs to send messages to a queue. I want a worker to pick the messages up and process them. After reading the example on https://devcenter.heroku.com/articles/run-non-web-java-processes-on-heroku I figured running another play process through the Procfile would be wasteful, so I made the following project structure to just use maven for the worker instead:
[git root]
+--[play 2.0 app]
| + (project files)
| +-Procfile (web)
|
+--[maven based worker]
+ (project files)
+-Procfile (worker)
Now if I try to push all of this to heroku it fails miserably. Heroku thinks this is a play 1.2.4 project and then just falls apart. When I try to specify a play 2.0 buildpack it says "no Cedar-supported app detected". So obviously heroku doesn't like my directory structure.
I want my play app and my maven worker to share the same git repository and if possible, be part of the same deployment to heroku. Is there a common pattern to solve this problem?
You can't mix multiple buildpacks in a single app on Heroku. Instead you could do this all as a Play 2 app. Here is an example project that will help get you started:
https://github.com/jamesward/play2-scheduled-job-demo

Resources