This project uses gradle and uses the default tasks to compile and run unit tests.
./gradlew clean assemble check
- Build the docker container
./gradlew clean assemble check docker
- Run the docker container
docker run -e SPRING_PROFILES_ACTIVE=localhost -p 8080:8080 -i -t spring-boot-java-base
./gradlew clean assemble check docker dockerTag -PTAG=$(git rev-parse --verify HEAD --short) -PREPOSITORY_URI=${DOCKER_REPO}${IMAGE_NAME}
To debug the container locally, the JAVA_OPTS
environment variable can be provided when running the container.
docker run -p 8080:8080 -i -t -e JAVA_OPTS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005" spring-boot-java-base
New relic can be enabled by providing the following JAVA_OPTS
environment variable. Ensure to provide the correct newrelic.environment
system property. To configure New Relic add/update the Application Environments section in newrelic.yml
, more information can be found here.
docker run -p 8080:8080 -i -t -e JAVA_OPTS="-javaagent:newrelic/newrelic.jar -Dnewrelic.environment=development -Dnewrelic.config.file=newrelic/newrelic.yml" spring-boot-java-base
This project uses Terraform and the AWS CLI to deploy the service to the BNC ECS Cluster. To have the CI/CD pipeline deploy a service which has be deployed using a fork of this project you can follow the instructions below.
By default Terraform will not create the required workspaces. Before setting up the deployment in the CI environment, ensure you have created all of the appropriate workspaces.
The default workspaces for BNC are:
- development
- production
To create the workspaces run the following commands:
cd deployment/terraform/ecs-service
terraform workspace new production
terraform workspace new development
- Fill in the following environment variables.
AWS_DEFAULT_REGION=
STATE_S3_BUCKET=
STATE_DYNAMODB_TABLE=
KEY=<The project key for the ECR repository>, e.g bnc/<team>/ecr/<service-name>
SERVICE_KEY=<The project key for ECS service>, e.g ecs/<service-name>
SPLUNK_URL=
- Encrypt the following global environment variables using the Travis-CI CLI.
DEPLOYMENT_ACCESS_KEY_ID=
DEPLOYMENT_SECRET_ACCESS_KEY=
KMS_KEY_ID=
ROLE_ARN=
OPERATIONS_ROLE_ARN=
- Encrypt the following environment variables for the development deployment:
TF_WORKSPACE=
SPLUNK_TOKEN=
-
cd deployment/terraform/ecr
-
Copy
backend.tfvars.example
tobackend.tfvars
. -
Fill out the
backend.tfvars
-
Run
terraform init "-backend-config=backend.tfvars"
. -
Copy
master.tfvars.example
tomaster.tfvars
. -
Fill in the
master.tfvars
with the correct values. -
Now the project is fully setup and you will have the ability to run terraform commands.
terraform plan "-var-file=master.tfvars"
-
cd deployment/terraform/ecs-service
-
Copy
backend.tfvars.example
tobackend.tfvars
. -
Fill out the
backend.tfvars
-
Run
terraform init "-backend-config=backend.tfvars"
. -
Copy
master.tfvars.example
tomaster.tfvars
. -
Fill in the
master.tfvars
with the correct values. -
Select the development work space
terraform workspace select development
-
Now the project is fully setup and you will have the ability to run terraform commands.
terraform plan "-var-file=master.tfvars"