mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-24 08:16:51 -04:00
4
.gitignore
vendored
4
.gitignore
vendored
@@ -102,8 +102,12 @@ node_modules
|
|||||||
bower_components
|
bower_components
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
|
|
||||||
|
# Mac + local
|
||||||
|
*.DS_Store
|
||||||
environment.sh
|
environment.sh
|
||||||
.envrc
|
.envrc
|
||||||
|
.env
|
||||||
|
.env*
|
||||||
|
|
||||||
# CloudFoundry
|
# CloudFoundry
|
||||||
.cf
|
.cf
|
||||||
|
|||||||
6
Makefile
6
Makefile
@@ -26,15 +26,15 @@ VIRTUALENV_ROOT := $(shell [ -z $$VIRTUAL_ENV ] && echo $$(pwd)/venv || echo $$V
|
|||||||
bootstrap: generate-version-file ## Set up everything to run the app
|
bootstrap: generate-version-file ## Set up everything to run the app
|
||||||
pip3 install -r requirements_for_test.txt
|
pip3 install -r requirements_for_test.txt
|
||||||
source $(HOME)/.nvm/nvm.sh && nvm install && npm ci --no-audit
|
source $(HOME)/.nvm/nvm.sh && nvm install && npm ci --no-audit
|
||||||
. environment.sh; source $(HOME)/.nvm/nvm.sh && npm run build
|
source $(HOME)/.nvm/nvm.sh && npm run build
|
||||||
|
|
||||||
.PHONY: watch-frontend
|
.PHONY: watch-frontend
|
||||||
watch-frontend: ## Build frontend and watch for changes
|
watch-frontend: ## Build frontend and watch for changes
|
||||||
. environment.sh; npm run watch
|
npm run watch
|
||||||
|
|
||||||
.PHONY: run-flask
|
.PHONY: run-flask
|
||||||
run-flask: ## Run flask
|
run-flask: ## Run flask
|
||||||
. environment.sh && flask run -p 6012
|
flask run -p 6012 --host=0.0.0.0
|
||||||
|
|
||||||
.PHONY: npm-audit
|
.PHONY: npm-audit
|
||||||
npm-audit: ## Check for vulnerabilities in NPM packages
|
npm-audit: ## Check for vulnerabilities in NPM packages
|
||||||
|
|||||||
@@ -104,9 +104,9 @@ class Development(Config):
|
|||||||
MOU_BUCKET_NAME = 'notify.tools-mou'
|
MOU_BUCKET_NAME = 'notify.tools-mou'
|
||||||
TRANSIENT_UPLOADED_LETTERS = 'development-transient-uploaded-letters'
|
TRANSIENT_UPLOADED_LETTERS = 'development-transient-uploaded-letters'
|
||||||
PRECOMPILED_ORIGINALS_BACKUP_LETTERS = 'development-letters-precompiled-originals-backup'
|
PRECOMPILED_ORIGINALS_BACKUP_LETTERS = 'development-letters-precompiled-originals-backup'
|
||||||
|
|
||||||
ADMIN_CLIENT_SECRET = 'dev-notify-secret-key'
|
ADMIN_CLIENT_SECRET = 'dev-notify-secret-key'
|
||||||
API_HOST_NAME = 'http://localhost:6011'
|
# check for local compose orchestration variable
|
||||||
|
API_HOST_NAME = os.environ.get('DEV_API_HOST_NAME', 'http://dev:6011')
|
||||||
DANGEROUS_SALT = 'dev-notify-salt'
|
DANGEROUS_SALT = 'dev-notify-salt'
|
||||||
SECRET_KEY = 'dev-notify-secret-key'
|
SECRET_KEY = 'dev-notify-secret-key'
|
||||||
ANTIVIRUS_API_HOST = 'http://localhost:6016'
|
ANTIVIRUS_API_HOST = 'http://localhost:6016'
|
||||||
@@ -115,7 +115,8 @@ class Development(Config):
|
|||||||
|
|
||||||
ASSET_PATH = '/static/'
|
ASSET_PATH = '/static/'
|
||||||
|
|
||||||
REDIS_URL = 'redis://localhost:6379/0'
|
REDIS_URL = os.environ.get('DEV_REDIS_URL', 'http://redis:6379')
|
||||||
|
|
||||||
REDIS_ENABLED = os.environ.get('REDIS_ENABLED') == '1'
|
REDIS_ENABLED = os.environ.get('REDIS_ENABLED') == '1'
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,5 @@
|
|||||||
gov.uk
|
gsa.gov
|
||||||
nhs.uk
|
gmail.com
|
||||||
nhs.net
|
dispostable.com
|
||||||
nhs.scot
|
simulator.amazonses.com
|
||||||
police.uk
|
amazonses.com
|
||||||
cjsm.net
|
|
||||||
ac.uk
|
|
||||||
sch.uk
|
|
||||||
onevoicewales.wales
|
|
||||||
suttonmail.org
|
|
||||||
hscni.net
|
|
||||||
42
devcontainer-admin/.devcontainer.json
Normal file
42
devcontainer-admin/.devcontainer.json
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
{
|
||||||
|
"name": "notification-admin",
|
||||||
|
"dockerComposeFile": "../docker-compose.devcontainer.yml",
|
||||||
|
"service": "admin",
|
||||||
|
"workspaceFolder": "/workspace",
|
||||||
|
"shutdownAction": "stopCompose",
|
||||||
|
"remoteEnv": {
|
||||||
|
"PATH": "/home/vscode/.local/bin:${containerEnv:PATH}" // give our installed Python modules precedence
|
||||||
|
},
|
||||||
|
"settings": {
|
||||||
|
"[python]": {
|
||||||
|
"editor.formatOnSave": true
|
||||||
|
},
|
||||||
|
"python.linting.enabled": true,
|
||||||
|
"python.linting.pylintEnabled": true,
|
||||||
|
"python.pythonPath": "/usr/local/bin/python"
|
||||||
|
},
|
||||||
|
"features": {
|
||||||
|
"docker-from-docker": {
|
||||||
|
"version": "latest",
|
||||||
|
"moby": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"extensions": [
|
||||||
|
"ms-python.black-formatter",
|
||||||
|
"donjayamanne.python-extension-pack",
|
||||||
|
"ms-azuretools.vscode-docker",
|
||||||
|
"ms-python.vscode-pylance",
|
||||||
|
"eamodio.gitlens",
|
||||||
|
"wholroyd.jinja",
|
||||||
|
"pmbenjamin.vscode-snyk",
|
||||||
|
"visualstudioexptteam.vscodeintellicode",
|
||||||
|
"yzhang.markdown-all-in-one",
|
||||||
|
"ms-ossdata.vscode-postgresql",
|
||||||
|
"GitHub.copilot"
|
||||||
|
],
|
||||||
|
"forwardPorts": [
|
||||||
|
6012
|
||||||
|
],
|
||||||
|
"postCreateCommand": "chmod u+x devcontainer-admin/scripts/notify-admin-entrypoint.sh && ./devcontainer-admin/scripts/notify-admin-entrypoint.sh",
|
||||||
|
"remoteUser": "vscode"
|
||||||
|
}
|
||||||
52
devcontainer-admin/Dockerfile
Normal file
52
devcontainer-admin/Dockerfile
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
FROM mcr.microsoft.com/vscode/devcontainers/python:0-3.9
|
||||||
|
|
||||||
|
# RUN groupadd --gid 1000 node \
|
||||||
|
# && useradd --uid 1000 --gid node --shell /bin/bash --create-home node
|
||||||
|
|
||||||
|
ENV NODE_VERSION 16.15.1
|
||||||
|
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get -y install --no-install-recommends apt-utils 2>&1 \
|
||||||
|
&& apt-get -y install \
|
||||||
|
curl \
|
||||||
|
emacs \
|
||||||
|
exa \
|
||||||
|
fd-find \
|
||||||
|
git \
|
||||||
|
iproute2 \
|
||||||
|
less \
|
||||||
|
libsodium-dev \
|
||||||
|
lsb-release \
|
||||||
|
man-db \
|
||||||
|
manpages \
|
||||||
|
net-tools \
|
||||||
|
nodejs \
|
||||||
|
npm \
|
||||||
|
openssh-client \
|
||||||
|
procps \
|
||||||
|
sudo \
|
||||||
|
tldr \
|
||||||
|
unzip \
|
||||||
|
vim \
|
||||||
|
&& apt-get autoremove -y \
|
||||||
|
&& apt-get clean -y \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
RUN echo $(node --version)
|
||||||
|
RUN echo $(npm --version)
|
||||||
|
|
||||||
|
# Upgrade pip
|
||||||
|
RUN pip install --upgrade pip
|
||||||
|
|
||||||
|
RUN groupadd --gid 1001 node \
|
||||||
|
&& useradd --uid 1001 --gid node --shell /bin/bash --create-home node
|
||||||
|
|
||||||
|
COPY package-lock.json ./
|
||||||
|
COPY package.json ./
|
||||||
|
COPY devcontainer-admin/scripts/notify-admin-entrypoint.sh ./
|
||||||
|
|
||||||
|
RUN npm ci --no-audit
|
||||||
|
|
||||||
|
ENV SHELL /bin/zsh
|
||||||
|
|
||||||
|
EXPOSE 6012
|
||||||
36
devcontainer-admin/scripts/notify-admin-entrypoint.sh
Executable file
36
devcontainer-admin/scripts/notify-admin-entrypoint.sh
Executable file
@@ -0,0 +1,36 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
###################################################################
|
||||||
|
# This script will get executed *once* the Docker container has
|
||||||
|
# been built. Commands that need to be executed with all available
|
||||||
|
# tools and the filesystem mount enabled should be located here.
|
||||||
|
###################################################################
|
||||||
|
|
||||||
|
# Define aliases
|
||||||
|
echo -e "\n\n# User's Aliases" >> ~/.zshrc
|
||||||
|
echo -e "alias fd=fdfind" >> ~/.zshrc
|
||||||
|
echo -e "alias l='ls -al --color'" >> ~/.zshrc
|
||||||
|
echo -e "alias ls='exa'" >> ~/.zshrc
|
||||||
|
echo -e "alias l='exa -alh'" >> ~/.zshrc
|
||||||
|
echo -e "alias ll='exa -alh@ --git'" >> ~/.zshrc
|
||||||
|
echo -e "alias lt='exa -al -T -L 2'" >> ~/.zshrc
|
||||||
|
|
||||||
|
cd /workspace
|
||||||
|
|
||||||
|
# Warm up git index prior to display status in prompt else it will
|
||||||
|
# be quite slow on every invocation of starship.
|
||||||
|
git status
|
||||||
|
|
||||||
|
pip3 install -r requirements.txt
|
||||||
|
pip3 install -r requirements_for_test.txt
|
||||||
|
|
||||||
|
# npm rebuild node-sass
|
||||||
|
make generate-version-file
|
||||||
|
# make babel
|
||||||
|
|
||||||
|
# npm ci install
|
||||||
|
npm run build
|
||||||
|
|
||||||
|
# run flask
|
||||||
|
# make run
|
||||||
25
docker-compose.devcontainer.yml
Normal file
25
docker-compose.devcontainer.yml
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
version: '3'
|
||||||
|
|
||||||
|
services:
|
||||||
|
admin:
|
||||||
|
container_name: admin
|
||||||
|
image: notification-admin
|
||||||
|
env_file: .env
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: devcontainer-admin/Dockerfile
|
||||||
|
command: sleep infinity
|
||||||
|
volumes:
|
||||||
|
- .:/workspace:cached
|
||||||
|
ports:
|
||||||
|
- "6012:6012"
|
||||||
|
expose:
|
||||||
|
- "6012"
|
||||||
|
adminredis:
|
||||||
|
command: sh -c "rm -f /data/dump.rdb && redis-server --port 6379" # disable persistence
|
||||||
|
image: redis:latest
|
||||||
|
|
||||||
|
networks:
|
||||||
|
default:
|
||||||
|
name: notify-network
|
||||||
|
external: true
|
||||||
@@ -24,6 +24,7 @@ notifications-python-client==6.3.0
|
|||||||
rtreelib==0.2.0
|
rtreelib==0.2.0
|
||||||
fido2==0.9.3
|
fido2==0.9.3
|
||||||
pyproj==3.3.1
|
pyproj==3.3.1
|
||||||
|
python-dotenv==0.20.0
|
||||||
|
|
||||||
# PaaS
|
# PaaS
|
||||||
awscli-cwlogs>=1.4,<1.5
|
awscli-cwlogs>=1.4,<1.5
|
||||||
|
|||||||
@@ -172,6 +172,8 @@ python-dateutil==2.8.2
|
|||||||
# via
|
# via
|
||||||
# awscli-cwlogs
|
# awscli-cwlogs
|
||||||
# botocore
|
# botocore
|
||||||
|
python-dotenv==0.20.0
|
||||||
|
# via -r requirements.in
|
||||||
python-json-logger==2.0.2
|
python-json-logger==2.0.2
|
||||||
# via notifications-utils
|
# via notifications-utils
|
||||||
pytz==2022.1
|
pytz==2022.1
|
||||||
|
|||||||
31
sample.env
Normal file
31
sample.env
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
|
||||||
|
NOTIFY_ENVIRONMENT=development
|
||||||
|
FLASK_APP=application.py
|
||||||
|
FLASK_ENV=development
|
||||||
|
WERKZEUG_DEBUG_PIN=off
|
||||||
|
|
||||||
|
REDIS_URL=redis://adminredis:6379/0
|
||||||
|
DEV_REDIS_URL=redis://adminredis:6379/0
|
||||||
|
REDIS_ENABLED=1
|
||||||
|
|
||||||
|
SQLALCHEMY_DATABASE_URI=postgres://postgres:chummy@db:5432/notification_api
|
||||||
|
|
||||||
|
ANTIVIRUS_ENABLED=0
|
||||||
|
GIT_SSL_NO_VERIFY=1 # Dont use in production, if we need to install gds reqs from source, get and add the cert manually
|
||||||
|
NODE_VERSION=16.15.1
|
||||||
|
|
||||||
|
ADMIN_CLIENT_ID=notify-admin
|
||||||
|
GOVUK_ALERTS_CLIENT_ID=govuk-alerts
|
||||||
|
|
||||||
|
# URL of admin app
|
||||||
|
ADMIN_BASE_URL=http://0.0.0.0:6012
|
||||||
|
|
||||||
|
# URL of api app (on AWS this is the internal api endpoint)
|
||||||
|
API_HOST_NAME=http://0.0.0.0:6011
|
||||||
|
DEV_API_HOST_NAME=http://0.0.0.0:6011
|
||||||
|
|
||||||
|
# AWS
|
||||||
|
AWS_REGION=us-west-2
|
||||||
|
AWS_ACCESS_KEY_ID=
|
||||||
|
AWS_SECRET_ACCESS_KEY=
|
||||||
|
|
||||||
Reference in New Issue
Block a user