generated from ministryofjustice/hmpps-template-kotlin
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 50fa2c3
Showing
38 changed files
with
1,409 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
version: 2.1 | ||
|
||
orbs: | ||
hmpps: ministryofjustice/hmpps@7 | ||
|
||
parameters: | ||
alerts-slack-channel: | ||
type: string | ||
default: dps_alerts_security | ||
releases-slack-channel: | ||
type: string | ||
default: dps-releases | ||
|
||
jobs: | ||
validate: | ||
executor: | ||
name: hmpps/java | ||
tag: "19.0" | ||
steps: | ||
- checkout | ||
- restore_cache: | ||
keys: | ||
- gradle-{{ checksum "build.gradle.kts" }} | ||
- gradle- | ||
- run: | ||
command: ./gradlew check | ||
- save_cache: | ||
paths: | ||
- ~/.gradle | ||
key: gradle-{{ checksum "build.gradle.kts" }} | ||
- store_test_results: | ||
path: build/test-results | ||
- store_artifacts: | ||
path: build/reports/tests | ||
|
||
workflows: | ||
version: 2 | ||
build-test-and-deploy: | ||
jobs: | ||
- validate: | ||
filters: | ||
tags: | ||
ignore: /.*/ | ||
- hmpps/helm_lint: | ||
name: helm_lint | ||
- hmpps/build_multiplatform_docker: | ||
name: build_docker | ||
filters: | ||
branches: | ||
only: | ||
- main | ||
- hmpps/deploy_env: | ||
name: deploy_dev | ||
env: "dev" | ||
jira_update: true | ||
context: hmpps-common-vars | ||
filters: | ||
branches: | ||
only: | ||
- main | ||
requires: | ||
- validate | ||
- build_docker | ||
- helm_lint | ||
helm_timeout: 5m | ||
# - request-preprod-approval: | ||
# type: approval | ||
# requires: | ||
# - deploy_dev | ||
# - hmpps/deploy_env: | ||
# name: deploy_preprod | ||
# env: "preprod" | ||
# jira_update: true | ||
# jira_env_type: staging | ||
# context: | ||
# - hmpps-common-vars | ||
# - hmpps-template-kotlin-preprod | ||
# requires: | ||
# - request-preprod-approval | ||
# helm_timeout: 5m | ||
# - request-prod-approval: | ||
# type: approval | ||
# requires: | ||
# - deploy_preprod | ||
# - hmpps/deploy_env: | ||
# name: deploy_prod | ||
# env: "prod" | ||
# jira_update: true | ||
# jira_env_type: production | ||
# slack_notification: true | ||
# slack_channel_name: << pipeline.parameters.releases-slack-channel >> | ||
# context: | ||
# - hmpps-common-vars | ||
# - hmpps-template-kotlin-prod | ||
# requires: | ||
# - request-prod-approval | ||
# helm_timeout: 5m | ||
|
||
security: | ||
triggers: | ||
- schedule: | ||
cron: "11 5 * * 1-5" | ||
filters: | ||
branches: | ||
only: | ||
- main | ||
jobs: | ||
- hmpps/gradle_owasp_dependency_check: | ||
slack_channel: << pipeline.parameters.alerts-slack-channel >> | ||
context: | ||
- hmpps-common-vars | ||
- hmpps/trivy_latest_scan: | ||
slack_channel: << pipeline.parameters.alerts-slack-channel >> | ||
context: | ||
- hmpps-common-vars | ||
- hmpps/veracode_pipeline_scan: | ||
slack_channel: << pipeline.parameters.alerts-slack-channel >> | ||
context: | ||
- veracode-credentials | ||
- hmpps-common-vars | ||
security-weekly: | ||
triggers: | ||
- schedule: | ||
cron: "0 5 * * 1" | ||
filters: | ||
branches: | ||
only: | ||
- main | ||
jobs: | ||
- hmpps/veracode_policy_scan: | ||
slack_channel: << pipeline.parameters.alerts-slack-channel >> | ||
context: | ||
- veracode-credentials | ||
- hmpps-common-vars | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: rename-project-create-pr | ||
|
||
on: [workflow_dispatch] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Run rename-project script | ||
run: ./rename-project.bash ${{ github.event.repository.name }} | ||
|
||
- name: Delete this github actions workflow | ||
run: rm .github/workflows/rename_template_project* | ||
|
||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v4 | ||
with: | ||
commit-message: updating project name after deployment from template repository | ||
title: Update template project name/references | ||
body: Update all references to project name after deploying from template repository | ||
branch: rename_template_project | ||
base: main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Created by .ignore support plugin (hsz.mobi) | ||
### JetBrains template | ||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm | ||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 | ||
|
||
.idea/ | ||
.gradle/ | ||
build/ | ||
|
||
# CMake | ||
cmake-build-debug/ | ||
|
||
## File-based project format: | ||
*.iws | ||
|
||
## Plugin-specific files: | ||
|
||
# IntelliJ | ||
out/ | ||
*.iml | ||
|
||
# mpeltonen/sbt-idea plugin | ||
.idea_modules/ | ||
|
||
# JIRA plugin | ||
atlassian-ide-plugin.xml | ||
|
||
# Crashlytics plugin (for Android Studio and IntelliJ) | ||
com_crashlytics_export_strings.xml | ||
crashlytics.properties | ||
crashlytics-build.properties | ||
fabric.properties | ||
### Java template | ||
# Compiled class file | ||
*.class | ||
|
||
# Log file | ||
*.log | ||
|
||
# BlueJ files | ||
*.ctxt | ||
|
||
# Mobile Tools for Java (J2ME) | ||
.mtj.tmp/ | ||
|
||
# Package Files # | ||
*.war | ||
*.ear | ||
*.zip | ||
*.tar.gz | ||
*.rar | ||
|
||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
hs_err_pid* | ||
|
||
Dockerrun.aws.json | ||
dist | ||
|
||
# Elastic Beanstalk Files | ||
.elasticbeanstalk/* | ||
!.elasticbeanstalk/config.yml | ||
!.elasticbeanstalk/*.cfg.yml | ||
!.elasticbeanstalk/*.global.yml | ||
|
||
# AWS DOcker build | ||
ecr.repo | ||
dps-gradle-spring-boot-suppressions.xml | ||
.editorconfig | ||
sonar-project.properties | ||
|
||
#Helm | ||
**/Chart.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# WARNING - THIS FILE WAS GENERATED BY THE dps-gradle-spring-boot GRADLE PLUGIN | ||
# AND ANY MANUAL CHANGES WILL BE OVERRIDDEN ON YOUR NEXT BUILD. | ||
# | ||
# To make general changes to the suppressions below, change the gradle plugin dps-gradle-spring-boot, | ||
# publish a new version and update to the new version in your gradle build script | ||
# | ||
# To stop the dps-gradle-spring-boot project from overwriting any project specific customisations here, remove the | ||
# warning at the top of this file. | ||
# | ||
# Suppression for snakeyaml 1.30 vulnerability as bundled with application insights so can't be upgraded easily | ||
# Can be suppressed as we we don't parse untrusted yaml | ||
CVE-2022-25857 | ||
CVE-2022-38751 | ||
# Suppression for snakeyaml 1.31 vulnerability as not fixed yet | ||
# Can be suppressed as we we don't parse untrusted yaml | ||
CVE-2022-38752 | ||
# Suppression for snakeyaml 1.33 vulnerability as not fixed yet | ||
# Can be suppressed as we we don't parse untrusted yaml | ||
CVE-2022-1471 | ||
# Suppression for snakeyaml 1.33 vulnerability as not fixed yet | ||
# Can be suppressed as we we don't parse untrusted yaml | ||
CVE-2022-41854 | ||
# Suppression for jackson databind 2.13.4 as no release for it yet | ||
# Can be suppressed as UNWRAP_SINGLE_VALUE_ARRAYS is not enabled | ||
CVE-2022-42003 | ||
# Suppression for jackson databind 2.13.3 as bundled with application insights | ||
# Can be suppressed as don't parse untrusted json in application insights | ||
CVE-2022-42004 | ||
# Suppression for apache common-text 1.9 as bundled with application insights | ||
# can be suppressed for the time being as it will be fixed in next version of application insights | ||
CVE-2022-42889 | ||
# Suppression for h2 2.1.214 password on command line vulnerability | ||
# can be suppressed as we only run h2 locally and not on build environments | ||
CVE-2022-45868 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
FROM --platform=$BUILDPLATFORM eclipse-temurin:19-jre-jammy AS builder | ||
|
||
ARG BUILD_NUMBER | ||
ENV BUILD_NUMBER ${BUILD_NUMBER:-1_0_0} | ||
|
||
WORKDIR /app | ||
ADD . . | ||
RUN ./gradlew --no-daemon assemble | ||
|
||
FROM eclipse-temurin:19-jre-jammy | ||
LABEL maintainer="HMPPS Digital Studio <[email protected]>" | ||
|
||
ARG BUILD_NUMBER | ||
ENV BUILD_NUMBER ${BUILD_NUMBER:-1_0_0} | ||
|
||
RUN apt-get update && \ | ||
apt-get -y upgrade && \ | ||
apt-get install -y curl && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
ENV TZ=Europe/London | ||
RUN ln -snf "/usr/share/zoneinfo/$TZ" /etc/localtime && echo "$TZ" > /etc/timezone | ||
|
||
RUN addgroup --gid 2000 --system appgroup && \ | ||
adduser --uid 2000 --system appuser --gid 2000 | ||
|
||
WORKDIR /app | ||
COPY --from=builder --chown=appuser:appgroup /app/build/libs/hmpps-template-kotlin*.jar /app/app.jar | ||
COPY --from=builder --chown=appuser:appgroup /app/build/libs/applicationinsights-agent*.jar /app/agent.jar | ||
COPY --from=builder --chown=appuser:appgroup /app/applicationinsights.json /app | ||
COPY --from=builder --chown=appuser:appgroup /app/applicationinsights.dev.json /app | ||
|
||
USER 2000 | ||
|
||
ENTRYPOINT ["java", "-XX:+AlwaysActAsServerClassMachine", "-javaagent:/app/agent.jar", "-jar", "/app/app.jar"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020-2021 Crown Copyright (Ministry of Justice) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# hmpps-template-kotlin | ||
[](https://operations-engineering-reports.cloud-platform.service.justice.gov.uk/public-github-repositories.html#hmpps-template-kotlin "Link to report") | ||
[](https://circleci.com/gh/ministryofjustice/hmpps-template-kotlin) | ||
[](https://quay.io/repository/hmpps/hmpps-template-kotlin) | ||
[](https://hmpps-template-kotlin-dev.hmpps.service.justice.gov.uk/webjars/swagger-ui/index.html?configUrl=/v3/api-docs) | ||
|
||
This is a skeleton project from which to create new kotlin projects from. | ||
|
||
# Instructions | ||
|
||
If this is a HMPPS project then the project will be created as part of bootstrapping - | ||
see https://github.com/ministryofjustice/dps-project-bootstrap. | ||
|
||
## Creating a CloudPlatform namespace | ||
|
||
When deploying to a new namespace, you may wish to use this template kotlin project namespace as the basis for your new namespace: | ||
|
||
<https://github.com/ministryofjustice/cloud-platform-environments/tree/main/namespaces/live.cloud-platform.service.justice.gov.uk/hmpps-template-kotlin> | ||
|
||
Copy this folder, update all the existing namespace references, and submit a PR to the CloudPlatform team. Further instructions from the CloudPlatform team can be found here: <https://user-guide.cloud-platform.service.justice.gov.uk/#cloud-platform-user-guide> | ||
|
||
## Renaming from HMPPS Template Kotlin - github Actions | ||
|
||
Once the new repository is deployed. Navigate to the repository in github, and select the `Actions` tab. | ||
Click the link to `Enable Actions on this repository`. | ||
|
||
Find the Action workflow named: `rename-project-create-pr` and click `Run workflow`. This workflow will | ||
execute the `rename-project.bash` and create Pull Request for you to review. Review the PR and merge. | ||
|
||
Note: ideally this workflow would run automatically however due to a recent change github Actions are not | ||
enabled by default on newly created repos. There is no way to enable Actions other then to click the button in the UI. | ||
If this situation changes we will update this project so that the workflow is triggered during the bootstrap project. | ||
Further reading: <https://github.community/t/workflow-isnt-enabled-in-repos-generated-from-template/136421> | ||
|
||
## Manually renaming from HMPPS Template Kotlin | ||
|
||
Run the `rename-project.bash` and create a PR. | ||
|
||
The `rename-project.bash` script takes a single argument - the name of the project and calculates from it: | ||
* The main class name (project name converted to pascal case) | ||
* The project description (class name with spaces between the words) | ||
* The main package name (project name with hyphens removed) | ||
|
||
It then performs a search and replace and directory renames so the project is ready to be used. |
Oops, something went wrong.