Prerequisites

Prerequisites

The intended audience for these Getting Started Guides is developers who want to quickly learn how to build solutions with YaaS. The guides have two main sections:

YaaS Bites

Learn and explore the basic YaaS landscape with the YaaS Bites Overview, then take your YaaS Bites First Steps and also learn the YaaS Bites Essentials. The YaaS Bites Sequel describes YaaS solutions in languages beyond Java, including Scala and Akka.

Wishlist Tutorial

Use the YaaS Service SDK in this section to create your own sample Wishlist service and Builder module, then integrate that service into a cloned storefront.

The prerequisites for following these guides are:

If you do not have Java 8 and Maven installed on your machine, read the Start with Docker documentation to go through this guide.

Start with Docker

If you do not have Java 8 or Maven, install the Docker as explained in the following section. In the console window, navigate to the project folder and execute the following command:

docker run -it --rm --name my-maven-project -v "$PWD":/usr/src/mymaven -v "$HOME/.m2:/root/.m2" -w /usr/src/mymaven -p 8080:8080 maven:alpine /bin/bash

Once inside the Docker container with your current directory mounted as /usr/src/mymaven, execute the Maven and Java commands from the console window. To exit the interactive mode, enter exit.

On the Windows platform, mount local directories on a Docker Linux image using the -v parameter, by specifying paths in Linux format since they are used in the container. For example, this code: Example: C:\Users\Resource7400123456\.m2 Is written as: //C/Users/Resource7400123456/.m2

Mount your local Maven repository

The -v $HOME/.m2:/root/.m2 part in the previous command creates and mounts your local HOME/.m2 directory to use as a local repository. Maven downloads all the needed artifacts to this directory. It is possible to have the artifacts downloaded inside the container, but the download takes time, and all the content of the container is lost when the directory is unmounted. Instead, store the repository outside of the container if you intend to use it more than once. When you no longer need to run Maven, delete the directory.

Run your service locally

The -p 8080:8080 parameter in the previous command allows a web service to be visible outside of the Docker image while running it locally.

Run Maven in non-interactive mode

You do not have to use the Docker in interactive mode to execute Java or Maven commands. Replace the /bin/bash part of the previous command with a single command to be executed. For example, this is the command to execute mvn clean install inside the container:

docker run -it --rm --name my-maven-project -v "$PWD":/usr/src/mymaven -v "$HOME/.m2:/root/.m2" -w /usr/src/mymaven -p 8080:8080 maven:alpine mvn clean install

Run Maven using helper scripts

To simplify the execution of commands in your maven Docker container, a helper Linux bash script and a Windows batch script are provided.

Running these scripts in a directory will run the maven:alpine Docker container, mount that directory as '/usr/src/mymaven', the "$HOME/.m2" directory as '/root/.m2', expose port 8080 and opens the bash shell of the Docker container.

You can also use the scripts to run any command that is executed with Maven and Java while using the docker container. Simply pass the command as the script parameters. For example, this command runs mvn clean install inside the maven:alpine Docker container, but affects the files in your current directory:

mvnDockerRun mvn clean install

To run the helper scripts in any directory on Linux-based machines, add the script files to the /usr/local/bin/ directory. For Windows machines include the scripts' containing folder in the PATH environment variable.

Troubleshooting

If you run a Linux Docker image and the mounting of local directories does not work make sure that you have activated sharing for the drive you're using. (on Windows see Settings -> Shared Drives, in Linux Preferences->File Sharing). Also make sure that your firewall or Intrusion Prevention System (IPS) does not prevent the sharing of your drive.


  • Send feedback

    If you find any information that is unclear or incorrect, please let us know so that we can improve the Dev Portal content.

  • Get Help

    Use our private help channel. Receive updates over email and contact our specialists directly.

  • hybris Experts

    If you need more information about this topic, visit hybris Experts to post your own question and interact with our community and experts.