Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandhya1874 authored Nov 15, 2024
0 parents commit 5d7397a
Show file tree
Hide file tree
Showing 52 changed files with 2,268 additions and 0 deletions.
109 changes: 109 additions & 0 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Pipeline [test -> build -> deploy]

on:
push:
branches:
- '**'

workflow_dispatch:
inputs:
environment:
description: Environment
type: choice
required: true
options:
- dev
- preprod
- staging
- production
default: 'dev'
docker_registry:
description: Docker registry
required: true
default: 'ghcr.io'
type: choice
options:
- 'ghcr.io'
- 'quay.io'
registry_org:
description: Docker registry organisation
required: true
default: 'ministryofjustice'
type: choice
options:
- 'ministryofjustice'
- 'hmpps'
additional_docker_tag:
description: Additional docker tag that can be used to specify stable tags
required: false
default: ''
type: string
push:
description: Push docker image to registry flag
required: true
default: true
type: boolean
docker_multiplatform:
description: docker multiplatform build or not
required: true
default: true
type: boolean

permissions:
contents: read
packages: write

jobs:
helm_lint:
name: helm lint
uses: ministryofjustice/hmpps-github-actions/.github/workflows/test_helm_lint.yml@v1 # WORKFLOW VERSION
secrets: inherit
with:
environment: ${{ inputs.environment || 'dev' }}
kotlin_validate:
name: Validate the kotlin
uses: ministryofjustice/hmpps-github-actions/.github/workflows/kotlin_validate.yml@v1 # WORKFLOW_VERSION
secrets: inherit
build:
name: Build docker image from hmpps-github-actions
if: github.ref == 'refs/heads/main'
uses: ministryofjustice/hmpps-github-actions/.github/workflows/docker_build.yml@v1 # WORKFLOW_VERSION
needs:
- kotlin_validate
with:
docker_registry: ${{ inputs.docker_registry || 'ghcr.io' }}
registry_org: ${{ inputs.registry_org || 'ministryofjustice' }}
additional_docker_tag: ${{ inputs.additional_docker_tag }}
push: ${{ inputs.push || true }}
docker_multiplatform: ${{ inputs.docker_multiplatform || true }}
deploy_dev:
name: Deploy to dev environment
needs:
- build
- helm_lint
uses: ministryofjustice/hmpps-github-actions/.github/workflows/deploy_env.yml@v1 # WORKFLOW_VERSION
secrets: inherit
with:
environment: 'dev'
app_version: '${{ needs.build.outputs.app_version }}'

# deploy_preprod:
# name: Deploy to pre-production environment
# needs:
# - build
# - deploy_dev
# uses: ministryofjustice/hmpps-github-actions/.github/workflows/deploy_env.yml@v1 # WORKFLOW_VERSION
# secrets: inherit
# with:
# environment: 'preprod'
# app_version: '${{ needs.build.outputs.app_version }}'
# deploy_prod:
# name: Deploy to production environment
# needs:
# - build
# - deploy_preprod
# uses: ministryofjustice/hmpps-github-actions/.github/workflows/deploy_env.yml@v1 # WORKFLOW_VERSION
# secrets: inherit
# with:
# environment: 'prod'
# app_version: '${{ needs.build.outputs.app_version }}'
43 changes: 43 additions & 0 deletions .github/workflows/rename_template_project_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: rename-project-create-pr

on:
workflow_dispatch:
inputs:
product_id:
description: 'Product ID: provide an ID for the product this app/component belongs too. Refer to the developer portal.'
required: true
slack_releases_channel:
description: 'Slack channel for release notifications.'
required: true
security_alerts_slack_channel_id:
description: 'Slack channel for pipeline security notifications.'
required: true
non_prod_alerts_prometheus_severity_label:
description: 'Non-prod kubernetes alerts. The severity label used by prometheus to route alert notifications to slack. See cloud-platform user guide.'
required: true
default: 'digital-prison-service-dev'
prod_alerts_prometheus_severity_label:
description: 'Production kubernetes alerts. The severity label used by prometheus to route alert notifications to slack. See cloud-platform user guide.'
required: true
default: 'digital-prison-service'

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Run rename-project script
run: ./rename-project.bash ${{ github.event.repository.name }} ${{ inputs.slack_releases_channel }} ${{ inputs.security_alerts_slack_channel_id }} ${{ inputs.non_prod_alerts_prometheus_severity_label }} ${{ inputs.prod_alerts_prometheus_severity_label }} ${{ inputs.product_id }}

- name: Delete this github actions workflow
run: rm .github/workflows/rename_template_project*

- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
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
12 changes: 12 additions & 0 deletions .github/workflows/security_owasp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Security OWASP dependency check
on:
workflow_dispatch:
schedule:
- cron: "19 6 * * MON-FRI" # Every weekday
jobs:
security-kotlin-owasp-check:
name: Kotlin security OWASP dependency check
uses: ministryofjustice/hmpps-github-actions/.github/workflows/[email protected] # WORKFLOW_VERSION
with:
channel_id: C05J915DX0Q
secrets: inherit
12 changes: 12 additions & 0 deletions .github/workflows/security_trivy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Security trivy dependency check
on:
workflow_dispatch:
schedule:
- cron: "19 6 * * MON-FRI" # Every weekday
jobs:
security-kotlin-trivy-check:
name: Project security trivy dependency check
uses: ministryofjustice/hmpps-github-actions/.github/workflows/[email protected] # WORKFLOW_VERSION
with:
channel_id: C05J915DX0Q
secrets: inherit
12 changes: 12 additions & 0 deletions .github/workflows/security_veracode_pipeline_scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Security veracode pipeline scan
on:
workflow_dispatch:
schedule:
- cron: "19 6 * * MON-FRI" # Every weekday
jobs:
security-veracode-pipeline-scan:
name: Project security veracode pipeline scan
uses: ministryofjustice/hmpps-github-actions/.github/workflows/[email protected] # WORKFLOW_VERSION
with:
channel_id: C05J915DX0Q
secrets: inherit
12 changes: 12 additions & 0 deletions .github/workflows/security_veracode_policy_scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Security veracode policy scan
on:
workflow_dispatch:
schedule:
- cron: "34 6 * * 1" # Every Monday
jobs:
security-veracode-policy-check:
name: Project security veracode policy scan
uses: ministryofjustice/hmpps-github-actions/.github/workflows/[email protected] # WORKFLOW_VERSION
with:
channel_id: C05J915DX0Q
secrets: inherit
73 changes: 73 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# 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/
.kotlin/
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
12 changes: 12 additions & 0 deletions .trivyignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# 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 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
34 changes: 34 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM --platform=$BUILDPLATFORM eclipse-temurin:21-jdk-jammy AS builder

ARG BUILD_NUMBER
ENV BUILD_NUMBER ${BUILD_NUMBER:-1_0_0}

Check warning on line 4 in Dockerfile

View workflow job for this annotation

GitHub Actions / Build docker image from hmpps-github-actions / Build docker image

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/

WORKDIR /app
ADD . .
RUN ./gradlew --no-daemon assemble

FROM eclipse-temurin:21-jre-jammy
LABEL maintainer="HMPPS Digital Studio <[email protected]>"

ARG BUILD_NUMBER
ENV BUILD_NUMBER ${BUILD_NUMBER:-1_0_0}

Check warning on line 14 in Dockerfile

View workflow job for this annotation

GitHub Actions / Build docker image from hmpps-github-actions / Build docker image

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/

RUN apt-get update && \
apt-get -y upgrade && \
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"]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020-2024 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.
Loading

0 comments on commit 5d7397a

Please sign in to comment.