Skip to content
This repository has been archived by the owner. It is now read-only.
WARNING: This repository is no longer maintained ⚠️ This repository will not be updated.
HTML Java Dockerfile
Branch: master
Clone or download
Latest commit b7817f5 Jun 4, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
doc/source/images [ImgBot] Optimize images Apr 18, 2019
src Automated Update Mar 26, 2019
.cfignore init Nov 15, 2018
.gitignore init Nov 15, 2018
CONTRIBUTING.md Automated Update Dec 13, 2018
Dockerfile add Dockerfile for Kube deploys May 30, 2019
LICENSE Replace MIT license with Apache 2.0 Nov 16, 2018
MAINTAINERS.md Automated Update Dec 6, 2018
README.md Update README.md Jun 4, 2019
pom.xml init Nov 15, 2018

README.md

WARNING: This repository is no longer maintained ⚠️

This repository will not be updated. The repository will be kept available in read-only mode.

Platform

Create and deploy a Java Backend For Frontend (BFF) using Spring

We have similar patterns available for Node.js, Swift, and Java Liberty as well!

In this code pattern, you will create a Backend for Frontend (BFF) web service using Spring in Java, matching a RESTful API documented in Swagger.

A BFF can be used to elegantly expose complex backend systems to multiple client-facing platforms, such as iOS and the web, without building a monolothic API that attempts to serve all clients equally. Different types of clients require different types of user experiences, and having a backend API tightly coupled to each specific user experience actually makes for a much more loosely coupled system overall. This pattern helps frontend teams iterate on features faster by giving them more control over the APIs they interact with, without affecting the user experience or development team driving a sister frontend.

When you have completed this code pattern, you will understand how to:

  • Build out the Backend for Frontend (BFF) architecture pattern
  • Deploy to Kubernetes, Cloud Foundry or a DevOps Pipeline
  • Operate an application with monitoring and distributed trace
  • Connect to provisioned services

Video

Learn more about the Backend for Frontend pattern in this tech talk:

BFFs and GraphQL, terms you should know and why

Steps

As an alternative to the steps below, you can create this project as a starter kit on IBM Cloud, which automatically provisions required services, and injects service credentials into a custom fork of this pattern. Then, you can skip directly to step 3 below.

  1. Install development tools
  2. Project contents
  3. Run

1. Install development tools

Ensure you have the required development tools installed:

2. Project contents

The BFF application has a health endpoint which is accessible at <host>:<port>/health. The ports are set to the defaults of 8080 for HTTP and 8443 for HTTPS and are exposed to the CLI in the cli-config.yml file.

The project contains IBM Cloud specific files that are used to deploy the application as part of a IBM Cloud DevOps flow. The .bluemix directory contains files used to define the IBM Cloud toolchain and pipeline for your application. The manifest.yml file specifies the name of your application in IBM Cloud, the timeout value during deployment and which services to bind to.

Credentials are either taken from the VCAP_SERVICES environment variable that IBM Cloud provides or from environment variables passed in by the config file src/main/resources/application-local.properties.

3. Run

To build and run the application:

  1. mvn install
  2. java -jar ./target/springbackendforfrontend-1.0-SNAPSHOT.jar

To run the application in Docker use the Docker file called Dockerfile. If you do not want to install Maven locally you can use Dockerfile-tools to build a container with Maven installed.

The application exposes the following endpoints:

  • Health endpoint: <host>:<port>/health (for example, http://localhost:8080/health).

The ports are set in the pom.xml file and exposed to the CLI in the cli-config.yml file.

License

This code pattern is licensed under the Apache License, Version 2. Separate third-party code objects invoked within this code pattern are licensed by their respective providers pursuant to their own separate licenses. Contributions are subject to the Developer Certificate of Origin, Version 1.1 and the Apache License, Version 2.

Apache License FAQ

You can’t perform that action at this time.