cloudfoundry-incubator / cflocal

Stage and launch CF apps, push and pull droplets, and connect to real CF services -- in Docker
Apache License 2.0
178 stars 27 forks source link

Usage example for run -d #25

Open rwetzold opened 6 years ago

rwetzold commented 6 years ago

I have an app that consists of a backend (Java) and a UI (static html files). The jar and the HTML files are then assembled into a WAR.

What does cflocal offer in such a case? I want to be able to change the Java or the UI coding and automatically have this reflected in the running app.

I have a Maven build where in the target directory I can see the extracted app, containing the html files in the root, the libraries in the lib folder etc. I figured this would be the natural candidate to point to but when doing so I get the error that catalina.sh could not be found.

Are there any examples that show where to point the -d work dir to? Are there best practices when working with Eclipse and Maven? Using a Tomcat inside Eclipse I get a roundtrip time of around 5s if I change Java and a roundtrip time of 0.5s when changing the HTML. It's hotdeployed. But this is outside the CF environment so I need to use cflocal. Is it possible to achieve similar times there?

sclevine commented 6 years ago

CF Local provides the same buildpacks as CF. The Java buildpack requires a compiled Java JAR or WAR, so instead of cf local run -d, the recommended development workflow for CF Local is to use Spring Boot DevTools, which can update a running app as you develop locally. You can use SBDT with CF Local just like you would with CF.

https://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-devtools.html

till commented 5 years ago

@sclevine is it possible to get some docs up on how to use -d anyway? I am evaluating cf-local currently for a local development environment and it would seem like it checks all the tings, but some of the docs are lacking.

sclevine commented 5 years ago

CF Local is currently on hold while we build out the Cloud Native Buildpacks project, which has a CLI that's similar to CF Local. I plan to update CF Local to use pack underneath once we finish converting all the CF buildpacks to the new Cloud Native Buildpacks API.

Cloud Native Buildpacks has an API intended to support local development that should work in cases where -d doesn't.

till commented 5 years ago

@sclevine so, I am not sure if -d works, or doesn't. I was mostly interested how to use it. Most of CF Local seems to do. It's just this and my inability to forward a service (see my comment on #27).

mruell commented 3 years ago

Figured out another way, just export to docker using cf local export app and then run it in docker while mounting only the public dir and vendor using

docker run --rm -p 8080:8080 -v /.../public:/home/vcap/app/public -v /.../vendor:/home/vcap/app/vendor app

(... should be the absolute path of the app directory on your host)

Paths may differ for you, I am using this options.json file

{
    "WEBDIR": "public",
    "COMPOSER_VENDOR_DIR": "vendor"
}