Skip to content

Commit

Permalink
Initial app install
Browse files Browse the repository at this point in the history
  • Loading branch information
wilson1000 committed Oct 5, 2023
1 parent 47bf565 commit 862cf55
Show file tree
Hide file tree
Showing 307 changed files with 15,134 additions and 3 deletions.
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/composer.lock
/package-lock.json
/.git
/Makefile
/resources/ops/*/Dockerfile
/node_modules/
/vendor/
/storage/logs/
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_size = 2

[docker-compose.yml]
indent_size = 4
50 changes: 50 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
APP_NAME="Tooling Procurement Centre"
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://127.0.0.1:8000

LOG_CHANNEL=stack
LOG_LEVEL=debug

DB_CONNECTION=mysql
DB_HOST=mariadb
DB_PORT=3306
DB_DATABASE=tp_centre
DB_USERNAME=tpc
DB_PASSWORD=tpc

BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DRIVER=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

REDIS_HOST=redis-master
REDIS_PASSWORD=null
REDIS_PORT=6379
PROMETHEUS_REDIS_PREFIX=PROMETHEUS_

MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* text=auto
*.css linguist-vendored
*.scss linguist-vendored
*.js linguist-vendored
CHANGELOG.md export-ignore
20 changes: 20 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: CI
on: [ push, workflow_dispatch ]
jobs:
build-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: php-actions/composer@v6
with:
php_version: 8.0

- name: Launch TDD process using PHPUnit
uses: php-actions/phpunit@v3
with:
bootstrap: vendor/autoload.php
configuration: phpunit.xml
env:
TEST_NAME: TPCentre
APP_KEY: base64:2NCh00CfUJ89QkCz2Ez8jMMkRnlR81pFLCdN/Mp4O5Q=
24 changes: 24 additions & 0 deletions .github/workflows/trivy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Vulnerability
on: [ push, workflow_dispatch ]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Run Trivy vulnerability scanner in repo mode
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
ignore-unfixed: true
format: 'template'
template: '@/contrib/sarif.tpl'
output: 'trivy-results.sarif'
severity: 'CRITICAL'

- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v1
with:
sarif_file: 'trivy-results.sarif'
26 changes: 26 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/node_modules
/public/hot
/public/storage
/storage/*.key
/public/mix-manifest.json
/public/favicon.ico
/public/assets
/vendor
.env
.env.backup
.phpunit.result.cache
docker-compose.override.yml
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
/public/css
/public/js
.idea/
.DS_*
._DS*

# No lock files, allow updates for security
# ... manage versions, rely on CI and TDD
composer.lock
package-lock.json
13 changes: 13 additions & 0 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
php:
preset: laravel
disabled:
- no_unused_imports
finder:
not-name:
- index.php
- server.php
js:
finder:
not-name:
- webpack.mix.js
css: true
21 changes: 21 additions & 0 deletions LICENCE
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 NON-INFRINGEMENT. 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.
60 changes: 60 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
.PHONY: dshell

d-compose:
docker-compose up -d nginx phpmyadmin
docker-compose run --service-ports --rm --entrypoint=bash php

dshell:
[ -f "./.env" ] || cp .env.example .env
echo "http://127.0.0.1:8080/" > public/hot
make d-compose

setup:
composer install
php artisan key:generate
php artisan migrate
php artisan db:seed
php artisan notify:restart

restart:
docker-compose down
make d-compose

db-migrate:
php artisan db:wipe
php artisan migrate
php artisan db:seed

test:
php artisan test

# Remove ignored git files
clean:
@if [ -d ".git" ]; then git clean -xdf --exclude ".env" --exclude ".idea"; fi

node-assets:
npm install
npm run watch

bash-nginx:
docker compose exec --workdir /var/www/html nginx bash

bash-node:
docker compose exec --workdir /node node bash

#####
## Production CI mock
#####

build-nginx:
docker image build -f resources/ops/docker/nginx/Dockerfile -t tp-centre-nginx:latest --target nginx .

build-fpm:
docker image build -f resources/ops/docker/fpm/Dockerfile -t tp-centre-fpm:latest --target fpm .

build:
make build-fpm
make build-nginx

ks-apply:
kubectl apply -f resources/ops/kubernetes
69 changes: 66 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,84 @@

</div>

# Installation
# Tooling Procurement Centre

## Requirements
The core purpose of the TPC (Tooling Procurement Centre) is to aggregate data related to tooling within government
digital teams and display exploratory reports and structured data for administrative review, financial quantification
and high-confidence decision-making.

* Docker
## Installation

The configuration uses multiple Docker containers and volumes to manage ephemeral assets and caching. The view is to
speed up and strengthen the environment for development. The result is a faster loading time with hot reloading of
frontend assets. The focus for this project has been, primarily, on creating a fluid development environment.

***MacOS example***

1. `cd ~/`
2. `git clone https://github.com/ministryofjustice/tooling-procurement-centre`
3. `cd tooling-procurement-centre && make dshell`
4. In your new docker shell, run: `make setup`
5. `exit`
6. `make restart`
7. Visit http://127.0.0.1:8000/

Nb. steps 5 and 6 are necessary and fix a bug that occurs due to Laravel's APP_KEY being generated on the fly, and the
systems' inability to read environment variables that change after init. When we restart the containers the newly
generated APP_KEY loads correctly.

### Useful commands

Monitor asset compilation output from the node container. Output is produced by `mix watch`. The terminal view will
update when changes are made to any file tracked in `webpack.mix.js`

```
docker compose logs node -f
```

## Laravel inside...

<img alt="Laravel logo" src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="200">

<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.svg" alt="Build Status"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>

Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and
creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in
many web projects, such as:

- [Simple, fast routing engine](https://laravel.com/docs/routing).
- [Powerful dependency injection container](https://laravel.com/docs/container).
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache)
storage.
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
- [Robust background job processing](https://laravel.com/docs/queues).
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).

Laravel is accessible, powerful, and provides tools required for large, robust applications.

## License

The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).


<!-- PHP -->

[PHP Link]: https://github.com/ministryofjustice/developer-playground/tree/php 'Click to view the Laravel application.'

[PHP Icon]: https://badgen.net/badge/PHP/Laravel/fb503b?scale=4&labelColor=484C89&icon=php

<!-- License -->

[License Link]: https://github.com/ministryofjustice/developer-playground/blob/java/LICENSE 'License.'

[License Icon]: https://img.shields.io/github/license/ministryofjustice/developer-playground?style=for-the-badge

<!-- MoJ Standards -->

[Standards Link]: https://operations-engineering-reports.cloud-platform.service.justice.gov.uk/public-report/developer-playground 'Repo standards badge.'

[Standards Icon]: https://img.shields.io/endpoint?labelColor=231f20&color=005ea5&style=for-the-badge&url=https%3A%2F%2Foperations-engineering-reports.cloud-platform.service.justice.gov.uk%2Fapi%2Fv1%2Fcompliant_public_repositories%2Fendpoint%2Fdeveloper-playground&logo=data:image/png;base64,iVBORw0KGg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akly01Cg7Cw0+qyXxkjojq9Lw+vT2AUY+DlF/otYq1Ixc35re2V7R8aTRg2KUv7+ou3x/14PsUBn3NG51S0XpG0Z9PcOPKWSS0SKNUo9Rv2Mmt/G5WpPF6pHGra7Jv410OVsdaz217AbkAPX3ubkm240belCuudT4Rp5p/DyC2lf9mfq1iq5eFe8/lu+K0YrVp0uret4nAkwlB6vzjI/1PxrlrTp/oNHbzTJI92T1qAT+BfW49MhMg6JUp7ehY5a6Tl2jjmVvitF9fxo5Yq8CaAfAkzLMnySt6uz/1k6bPx59CpCNxGfoSKA30IPoH7cQXdArwCOllFX/i53P5P9a/gNkKpsCMFRuFAAAAABJRU5ErkJggg==
Loading

0 comments on commit 862cf55

Please sign in to comment.