I created playframework project with 2 submodules
Submodule 'core'. Available under http://localhost:9000/core/... E.g. http://localhost:9000/core/users
Submodule 'chat'. Available under http://localhost:9000/chat/... http://localhost:9000/chat/messages
I created docker image by
sbt docker:publishLocal
When I start the app inside docker, my modules are available by URL without module name. E.g.
http://DOCKER_IP:9000/users (must be http://DOCKER_IP:9000/core/users )
http://DOCKER_IP:9000/messages (must be http://DOCKER_IP:9000/chat/messages )
So it does not work correctly. How can I make play in docker to use correct URLs?
Docker is not responsible for designing your URLs or even mapping them, it only maps the port (9000).
Playframework web conf is what you are looking for.
Related
I am using spring-boot 2.7.1 with native configuration as the guide follows in the link.
Spring native official doc
My problem is that when running bootBuildImage, the buildpack ["gcr.io/paketo-buildpacks/java-native-image:7.19.0"] is trying to download external dependency paketo-buildpacks/bellsoft-liberica from https://download.bell-sw.com/vm/22.3.0/bellsoft-liberica-vm-core-openjdk17.0.5+8-22.3.0+2-linux-amd64.tar.gz which is not allowed by company firewall.
I then researched that you can configure dependeny-mapping bindings towards these dependencies within required buildpack, at-least using this pack cli guide.
But when using purely pack-cli the gradle bootBuildImage gets a bit irrelevant and then I have to use some external tool to fix the native docker container and image. And I would like to only use the bootBuildImage to map these dependency-bindings.
I found this binding function within Gradle bootBuildImage docs. but I am not sure what string it expects, if the path should be similar to pack-cli config or not, can't find any relevant info.
The provided image show the bootBuildImage config
bootBuildImage {
builder = 'docker.io/paketobuildpacks/builder:tiny'
runImage = 'docker.io/paketobuildpacks/run:tiny-cnb'
buildpacks = ['gcr.io/paketo-buildpacks/java-native-image']
binding("bindnings/bellsoft-jre-config:/platform/bindings/bellsoft-jre-config")
environment = [
"BP_NATIVE_IMAGE" : "true",
]
}
The dependency-mapping config contains 2 files:
The type file contains:
echo "dependency-mapping" >> type
The sha256 (bellsoft-liberica) file 3dea0f7a9312c738d22b5e399b6ce9abe13b45b2bc2c04346beb941a94e8a932 contains:
'echo "https://download.bell-sw.com/vm/22.3.0/bellsoft-liberica-vm-core-openjdk17.0.5+8-22.3.0+2-linux-amd64.tar.gz" >> 3dea0f7a9312c738d22b5e399b6ce9abe13b45b2bc2c04346beb941a94e8a932'
And yes I'm aware that this is the exact same url, but this is just to test that the binding config is correctly setup. Because if ok it should fail on untrusted certificate when downloading instead.
Currently the build fails with:
Caused by: org.springframework.boot.buildpack.platform.docker.transport.DockerEngineException: Docker API call to 'localhost/v1.24/containers/create' failed with status code 400 "Bad Request"
at org.springframework.boot.buildpack.platform.docker.transport.HttpClientTransport.execute(HttpClientTransport.java:156)
at org.springframework.boot.buildpack.platform.docker.transport.HttpClientTransport.execute(HttpClientTransport.java:136)
at org.springframework.boot.buildpack.platform.docker.transport.HttpClientTransport.post(HttpClientTransport.java:108)
at org.springframework.boot.buildpack.platform.docker.DockerApi$ContainerApi.createContainer(DockerApi.java:340)
at org.springframework.boot.buildpack.platform.docker.DockerApi$ContainerApi.create(DockerApi.java:331)
at org.springframework.boot.buildpack.platform.build.Lifecycle.createContainer(Lifecycle.java:237)
at org.springframework.boot.buildpack.platform.build.Lifecycle.run(Lifecycle.java:217)
at org.springframework.boot.buildpack.platform.build.Lifecycle.execute(Lifecycle.java:151)
at org.springframework.boot.buildpack.platform.build.Builder.executeLifecycle(Builder.java:157)
at org.springframework.boot.buildpack.platform.build.Builder.build(Builder.java:115)
at org.springframework.boot.gradle.tasks.bundling.BootBuildImage.buildImage(BootBuildImage.java:521)
Which i assume is caused by invalid binding config. But I can't find what is should be.
Paketo configuration (binding)
Dependency mapping bindings can be tricky. There are a number of things that have to be just right, or the buildpacks won't pick up the binding and won't map dependencies.
While there are talks of how we can change this in buildpacks to make swapping out dependencies easier, the short-term solution is to use binding-tool.
You can run bt dm -b paketo-buildpacks/bellsoft-liberica and it will go download the dependencies from the specified buildpack and generate the binding files for you.
It will by default download dependencies and write the bindings to $PWD/bindings but you can change that. For example, I like to put my dependencies in my home directory so I can share them across apps. Ex: SERVICE_BINDING_ROOT=~/.bt/bindings bt dm ..., or export SERVICE_BINDING_ROOT=~/.bt/bindings (or whatever command you run to set an env variable in your shell).
Once you have the bindings created, you just need to point your app to them. How you set the property differs between Maven & Gradle, but the value of the property is the same. It should be <local-path>:<container-path>.
The local path should be the full or relative path to where you created the bindings with bt dm. The container path should almost always be /platform/bindings. This maps your full set of bindings locally to the full set of bindings that the buildpacks will consume. In other words, put all of your bindings into the same directory locally, map that to /platform/bindings and the buildpacks will see everything.
For example with Gradle: binding("bindings/:/platform/bindings").
You can adjust the container path by setting SERVICE_BINDING_ROOT in the container as well, but it doesn't offer a lot of advantage.
You can also set multiple entries for bindings, so long as the paths are unique. So you could set binding("/home/user/.bt/bindings/foo:/platform/bindings/foo") and also binding("bindings/bar:/platform/bindings/bar"). That would let you take bindings from two different locations locally and map them into the /platform/bindings directory so both would be visible to buildpacks. This gives you more fine-grained control but as you can see becomes pretty verbose.
Details on configuring Maven and configuring Gradle for buildpacks can be found at those links.
Some context: I'm learning to use docker. I have a manually written Dockerfile and a docker-compose.yml file but when I stand up the container and the netcoreapp3.1 Kestrel web app contained therein, there's a problem loading the SSL certificate. The cert file isn't visible to Kestrel for reasons yet unknown to me.
In the process of fathoming this, I discovered VS Code has support for docker-build tasks. I've excerpted the interesting portion of the docs below.
The part that confuses me is the mandatory appProject property. My Dockerfile pulls source from git; several related projects. Then it compiles it and does various other things. Why do I need to specify an app project in the task when that sort of thing is defined by the Dockerfile? I strongly suspect I have failed to understand how these tasks are intended to be used — something the docs don't really address.
Could someone please explain the intended mode of use and the relevance of these settings? Preferably with examples.
Docker build task
The docker-build task builds Docker images using the Docker command line (CLI). The task can be used by itself, or as part of a chain of tasks to run and/or debug an application within a Docker container.
The most important configuration settings for the docker-build task are dockerBuild and platform:
The dockerBuild object specifies parameters for the Docker build command. Values specified by this object are applied directly to Docker build CLI invocation.
The platform property is a hint that changes how the docker-build task determines Docker build defaults.
Platform support#
While the docker-build task in tasks.json can be used to build any Docker image, the extension has explicit support (and simplified configuration) for Node.js, Python, and .NET Core
.NET Core (docker-build)#
Minimal configuration using defaults
When you build a .NET Core-based Docker image, you can omit the platform property and just set the netCore object (platform is implicitly set to netcore when netCore object is present). Note that appProject is a required property:
{
"version": "2.0.0",
"tasks": [
{
"label": "Build Node Image",
"type": "docker-build",
"netCore": {
"appProject": "${workspaceFolder}/project.csproj"
}
}
]
}
Platform defaults
For .NET Core-based images, the docker-build task infers the following options:
Property
Inferred Value
dockerBuild.context
The root workspace folder.
dockerBuild.dockerfile
The file Dockerfile in the root workspace folder.
dockerBuild.tag
The base name of the root workspace folder.
I want to build BigBlueButton system from the Dockerfiles.
I have tried some times with exist Dockerfiles in source code, but it have not succeeded.
I found many BigBlueButton components in source code, but I don't know the order for building components.
This is the source link and I have listed some components that have Dockerfiles.
https://github.com/bigbluebutton/bigbluebutton/
akka-bbb-apps
akka-bbb-fsesl
bbb-common-message
bbb-common-web
bbb-fsesl-client
bbb-libreoffice
bbb-lti
bbb-webhooks
bigbluebutton-html5
bigbluebutton-web
What is the first packet had to build? And what is the next?
A good resource is the lab build for kubernettes which has a lot of information for how to build the bbb modules.
From the labs directory in the main source from makefile I would try the following order
bbb-common-message, bbb-common-web, bbb-fsesl-client, akka-bbb-apps, akka-bbb-fsesl, bigbluebutton-web, bigbluebutton-html5, bbb-webrtc-sfu, bbb-webhooks
You will need all the build dependencies to be installed like sbt for the scala modules.
If you just want to work on the html5 client or custom integrations then the docker-dev is a good option, not least as it sets up nginx with certs so you can develop locally with https.
I would suggest setting up the docker-dev to get insight on how the modules interact if you are not familiar with the bbb architecture.
I have created a Docker image and embedded some static resource files within it, using the following command in the Dockerfile:
COPY resources /resources
I have a java web application running within the Docker container which requires access to these static files. File paths must be provided using a URL, E.g.:
file://c:/resources/myresourcefile.css
I am able to construct the URL programmatically but am unsure if embedded files can be referenced this way. Any guidance would be appreciated!
Note: I am specifically using the pdfreactor web service, and my Dockerfile is thus:
FROM realobjects/pdfreactor:9.1
EXPOSE 9423
COPY resources /resources
I am trying to set the "BaseURL" of the PDFreactor wrapper client to the root resource folder.
If it’s a Linux container, and the requestor is specifically your Java process running inside the container, then file:///resources will point at the directory you added (a subdirectory of the image root directory). If the URL is being served to something outside the container (like an HTML link or image reference) then a file: URL won’t be able to access files inside the container; you’d have to come up with something else to serve up the files and provide an HTTP URL to them.
As per the official doc on https://www.pdfreactor.com/product/doc_html/index.html#resourceLoading
It is also possible to specify file URLs:
Java: config.setBaseURL("file:///directory/")
PHP: $config["baseURL"] = "file:///directory/";
.NET: config.BaseURL = "file:///directory/";
CLI: --baseURL "file:///directory/"
I completed the integration of the latest Google Tag Manager (v5) for iOS together with Firebase (https://developers.google.com/tag-manager/ios/v5/).
The big change here is that the default container file is not binary anymore, it is plain JSON.
The integration requires that you have a folder (not group!) with the name "container" inside your app workspace. Within this folder the container file should be located. This raises my issue: We have two different GTM Containers, one for the testing/development app and one for production.
By using a folder it is not possible for me to add a different container file and set target references.
I can not create an additional folder since GTM requires the folder on root level and with the exact name "container"
Does anybody have an idea how this can be solved?
Thanks,
Fahim
You should be able to configure an XCode "run script" build step that clears the container directory and copies the correct container into place.
Sample Run Script (if somebody has the same issue):
rm -vf ${SRCROOT}/root_folder/container/*
cp "${SRCROOT}/root_folder/target/test/GTM-XXXXX.json" "${SRCROOT}/root_folder/container/"
It is important that this copy job is done at first within Build Phases, otherwise some other precompiling stuff of GTM does not recognize the container.