Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Product Changes | PDF Download Button #104

Merged
merged 10 commits into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Created by .ignore support plugin (hsz.mobi)
### VINCE-localstack
volumes

### Python template
# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
22 changes: 21 additions & 1 deletion bigvince/settings_.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
ROOT_DIR = environ.Path(__file__) - 3

# any change that requires database migrations is a minor release
VERSION = "2.0.7"
VERSION = "2.0.8"

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
Expand Down Expand Up @@ -821,3 +821,23 @@ def get_secret(secret_arn):
#If you choose to disable TLP statements in CSAF comment out the MAP dictionary below
CSAF_TLP_MAP = { "PUBLIC": "WHITE", "PRIVATE": "AMBER" }

#Added in SECTORS for VERSION 2.0.8
SECTORS = (
('Chemical', 'Chemical'),
('Commercial Facilities', 'Commercial Facilities'),
('Communications', 'Communications'),
('Critical Manufacturing', 'Critical Manufacturing'),
('Dams', 'Dams'),
('Defense Industrial Base', 'Defense Industrial Base'),
('Emergency Services', 'Emergency Services'),
('Energy', 'Energy'),
('Financial', 'Financial'),
('Food and Agriculture', 'Food and Agriculture'),
('Government Facilities', 'Government Facilities'),
('Healthcare and Public Health', 'Healthcare and Public Health'),
('Information Technology', 'Information Technology'),
('Nuclear Reactors, Materials, and Waste', 'Nuclear Reactors, Materials, and Waste'),
('Transportation Systems', 'Transportation Systems'),
('Water and Wastewater Systems', 'Water and Wastewater Systems')
)

8 changes: 4 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3.8"
services:
localstack:
container_name: localstack
image: localstack/localstack
image: localstack/localstack:1.1.0
ports:
- "127.0.0.1:4566:4566" # LocalStack Gateway
- "127.0.0.1:4510-4559:4510-4559" # external services port range
Expand Down Expand Up @@ -36,8 +36,8 @@ services:
bv-postgres:
container_name: bv-postgres
image: postgres:latest
# ports:
# - "127.0.0.1:5432:5432"
#ports:
# - "127.0.0.1:5432:5432"
environment:
- POSTGRES_PASSWORD=${POSTGRESQL_PASS}
volumes:
Expand All @@ -62,4 +62,4 @@ services:
- localstack
- bv-postgres
networks:
vince_net:
vince_net:
6 changes: 6 additions & 0 deletions localstackdev/Dockerfile-localstackdev
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM localstack/localstack:1.1.0

COPY ./<cert>.crt /usr/local/share/ca-certificates/cert-bundle.crt
RUN update-ca-certificates
ENV CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
ENV REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
14 changes: 8 additions & 6 deletions localstackdev/README_localstack.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Run the following:
### Configuration
Then acquire a valid [Localstack](https://localstack.cloud/) Pro license key (trial will work)

Environment Variables:
## Environment Variables:
#### VINCE/.env:
- Modify the `LOCALSTACK_API_KEY` variable to be proper API key.

Expand All @@ -27,20 +27,20 @@ Add the following to `/etc/hosts`. An example line is below:
127.0.0.1 localstack
127.0.0.1 testpool.us-east-1.localstack

An example `.env` for usage under `bigvince` is provided with fake or development only values. Although it must be copied to the proper location
An example `.env` for usage under `bigvince` is provided in the localstackdev folder with fake or development only values. Although it must be copied to the proper location (bigvince/.env).

This .env file is setup to serve static files from the LocalStack S3 bucket. If you want to truly serve them from a local filepath or nginx, remove the line AWS_DEPLOYED=1.

#### Copy settings_.py
`bigvince/settings_.py` will need to be copied to `bigvince/settings.py`


#### Windows Specific
- Modify Dockerfile-dev to use 20.04.
- Set `git config --global core.autocrlf input` before cloning the repository.

### Usage
Run `sudo docker-compose up`, and wait 2-5 minutes

Navigate to `http://localstack`
Navigate to `http://localstack:80`

### Additional commands
Commands of note are below:
Expand All @@ -49,9 +49,11 @@ Commands of note are below:
- `docker-compose build` (rebuild vince base container)
- `docker-compose up -d` (run in the background)
- `docker-compose ps` (show status of containers)
- `docker-compose exec <name_of_container> /bin/bash` (start a bash shell in a running container)
- `docker-compose exec -it <name_of_container> /bin/bash` (start a bash shell in a running container)

## Additional notes
- With the recent changes to LocalStack docker container, something is broken.The target for LocalStack docker container has been modified LocalStack (1.1.0) inside docker-compose.yml.
- If you are using a self signed certificate, a Dockerfile (Dockerfile-localstackdev) as well as localstackdev/docker-compose_localstackdev.yml are provided. The latter must be named appropriately and replace the original docker-compose.yml file in the root of this repository. The localstack target in this Dockerfile is also an older version (1.1.0).
- The default password is currently set in the fixtures, it can be modified after logging in for the first time
- The ADMIN_EMAIL field is used for login, not the username
- If the containers are created anew from stratch then the browser cache will need to be cleared to remove an old JWT token
Expand Down
68 changes: 68 additions & 0 deletions localstackdev/docker-compose_localstackdev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
version: "3.8"
services:
localstack:
container_name: localstack
build:
context: .
dockerfile: localstackdev/Dockerfile-localstackdev
image: localstack
ports:
- "127.0.0.1:4566:4566" # LocalStack Gateway
- "127.0.0.1:4510-4559:4510-4559" # external services port range
- "127.0.0.1:53:53" # DNS config (only required for Pro)
- "127.0.0.1:53:53/udp" # DNS config (only required for Pro)
- "127.0.0.1:443:443" # LocalStack HTTPS Gateway (only required for Pro)
environment:

- SERVICES=${LOCALSTACK_SERVICES}
- DEBUG=1
- PERSISTENCE=1
- LAMBDA_EXECUTOR=local
- LOCALSTACK_API_KEY=${LOCALSTACK_API_KEY}
- DOCKER_HOST=unix:///var/run/docker.sock
- LS_LOG=${LOCALSTACK_LOG_LEVEL}
- MOCK_UNIMPLEMENTED=1
- REQUIRE_PRO=1
- IGNORE_ES_DOWNLOAD_ERRORS=1
- HOSTNAME=localstack
- HOSTNAME_EXTERNAL=localstack
volumes:
- ./volumes:/var/lib/localstack
- "/var/run/docker.sock:/var/run/docker.sock"
networks:
vince_net:
aliases:
- ${POOL_NAME}.localstack
- ${BUCKET_NAME}.s3.${REGION}.localstack
- cognito-idp.${REGION}.localstack
- ${POOL_NAME}.${REGION}.localstack
bv-postgres:
container_name: bv-postgres
image: postgres:latest
ports:
- "127.0.0.1:5432:5432"
environment:
- POSTGRES_PASSWORD=${POSTGRESQL_PASS}
volumes:
- ./volumes:/var/lib/localstack
networks:
- vince_net
vince:
container_name: vince
build:
context: .
dockerfile: localstackdev/Dockerfile-dev
image: vince
ports:
- "127.0.0.1:80:80"
volumes:
- ./:/opt/vince
networks:
- vince_net
env_file:
- .env
depends_on:
- localstack
- bv-postgres
networks:
vince_net:
4 changes: 3 additions & 1 deletion localstackdev/init.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
#If this is the first time application is run, run initial_install
if [ ! -f /firsttime ]; then
chmod +x /opt/vince/localstackdev/initial_install.sh
/opt/vince/localstackdev/initial_install.sh
Expand All @@ -9,5 +10,6 @@ until $(curl --output /dev/null --silent --head --fail http://localstack:4566);
sleep 5
done
sleep 5
#More Django Commands
python3 manage.py collectstatic --noinput
python3 manage.py runserver 0.0.0.0:80
python3 manage.py runserver 0.0.0.0:80
5 changes: 5 additions & 0 deletions localstackdev/initial_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ until $(curl --output /dev/null --silent --head --fail http://localstack:4566);
sleep 5
done
sleep 5

#All Localstack Commands/Variables
export LOCALSTACK_HOST=localstack
pool_id=$(awslocal cognito-idp create-user-pool --pool-name $POOL_NAME | jq -rc ".UserPool.Id")
client_id=$(awslocal cognito-idp create-user-pool-client --user-pool-id $pool_id --client-name $CLIENT_NAME | jq -rc ".UserPoolClient.ClientId")
Expand Down Expand Up @@ -41,9 +43,12 @@ do
sed -i s/$i.*$/$i=\"$b\"/g $filename
done
export PGPASSWORD=$POSTGRESQL_PASS
#PostgreSQL Database Creation
createdb -h $POSTGRES_HOST -U postgres vince
createdb -h $POSTGRES_HOST -U postgres vincecomm
createdb -h $POSTGRES_HOST -U postgres vincepub
#Django Specific Application Commands
python3 manage.py makemigrations
python3 manage.py migrate
python3 manage.py migrate --database=vincecomm
python3 manage.py migrate --database=vincepub
Expand Down
1 change: 1 addition & 0 deletions localstackdev/vince_dev.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ python-jose==3.3.0
pytz==2022.6
PyYAML==5.4.1
qrcode==7.3.1
redis==4.5.3
redis==4.5.4
requests==2.28.1
rsa==4.7.2
s3transfer==0.6.0
Expand Down
Loading