This sample shows how to deploy a Spring Boot application protected by Sqreen to Google App Engine flexible with Docker image. For simplicity and transparency, the example is based on the sample from GoogleCloudPlatform. Below you will find a Sqreen Integration Guide with required steps to use a Sqrreen Java Agent in the project deployed to the Google App Engine flexible.
- JDK11
- Maven
- Google Cloud console
- Set the correct Cloud SDK project via
gcloud config set project YOUR_PROJECT
to the ID of your application. - Put your
SQREEN_TOKEN
andSQREEN_APP_NAME
tosrc/main/appengine/app.yaml
- Build and deploy application
mvn clean package appengine:deploy
- View web app
gcloud app browse
(or navigatehttps://<your-project-id>.appspot.com
) - In response HTTP headers you should see string
x-protected-by: Sqreen
- Download java agent
sqreen.jar
into dedicated project folder. In the sample java agent located atsqreen/sqreen.jar
- To use Sqreen, you need add
Dockerfile
where will app run (Docker image should contains both jar-files andapp.jar
, andsqreen.jar
). Put Dockerfile to /src/main/docker/Dockerfile:
FROM openjdk:11-jre-slim
COPY helloworld-*.jar /app.jar
COPY sqreen.jar /sqreen.jar
CMD ["java", "-javaagent:sqreen.jar", "-Dsqreen.log_level=INFO", "-jar", "/app.jar"]
- Runtime should be
custom
atapp.yaml
to make it works with prepared Dockerfile. - Sqreen requires
SQREEN_TOKEN
andSQREEN_APP_NAME
related to your Sqreen account. Get token and app from your dashboard and add them as environement variables toapp.yaml
:
env_variables:
SQREEN_APP_NAME: XXXXXXXXX
SQREEN_TOKEN: env_org_XXXXXXXXX
- To make Google App Engine use Sqreen - add external files directory (where the
sqreen.jar
stored), to maven configurationpom.xml
. If you are usingGradle
to build your project, you must use similar configuration to include external files (please check official documentation).
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
...
<configuration>
....
<extraFilesDirectories>
<extraFilesDirectory>sqreen</extraFilesDirectory>
</extraFilesDirectories>
</configuration>
</plugin>
- Build, deploy and test the app with Sqreen protection.