Skip to content

Commit

Permalink
Refactoring bootstrap script as well as enabling the audit log for po…
Browse files Browse the repository at this point in the history
…rtal.
  • Loading branch information
JRWu committed Apr 11, 2024
1 parent 1cb30fc commit 13dfb64
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ deployments/tyk/volumes/tyk-gateway/certs/tls-private-key.pem
deployments/tyk/volumes/tyk-gateway/certs/private-key.pem
deployments/tyk/volumes/tyk-gateway/certs/public-key.pem
deployments/tyk/volumes/tyk-dashboard/certs/private-key.pem

deployments/portal/volumes/portal.log
## Portal Deployment
deployments/portal/volumes/database/portal.db
7 changes: 2 additions & 5 deletions deployments/portal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,5 @@ To use this deployment, run the `up.sh` script with the `portal` parameter:
```

This install comes bootstrapped with an admin user, an external api consumer user and an internal api developer user.
Initially the portal comes bootstrapped with a default admin user but becomes overwritten with a SQLite database containing users, organizations, and image assets.
The SQLite database file is located within deployments/portal/volumes/database/portal.db.

### Dependencies
<li> SQLite </li>
The Portal will spin up a Postgres database containing portal configurations as well as assets.
There is an exposed logfile in the directory `./deployments/portal/volumes/portal.log` for debugging purposes.
21 changes: 8 additions & 13 deletions deployments/portal/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ deployment="Portal"
log_start_deployment
bootstrap_progress

log_message "Overwriting old portal log with empty logfile."
cp ./deployments/portal/volumes/portal.log.example ./deployments/portal/volumes/portal.log


# Grab the Dashboard License line from ENV file
licence_line=$(grep "DASHBOARD_LICENCE=" .env)
# Parse out the DASHBOARD_LICENSE= bit
Expand Down Expand Up @@ -34,6 +38,8 @@ set_docker_environment_value "PORTAL_DOCRENDERER" stoplight
set_docker_environment_value "PORTAL_REFRESHINTERVAL" 10
set_docker_environment_value "PORTAL_LOG_LEVEL" debug
set_docker_environment_value "PORTAL_LOG_FORMAT" dev
set_docker_environment_value "PORTAL_AUDIT_LOG_ENABLE" true



# Create Plans and Policies for NEW Developer Portal
Expand Down Expand Up @@ -235,33 +241,22 @@ for plan in "${plans[@]}"; do
--header "Authorization: $portal_admin_api_token")
plan_response=$(echo $plan_response | jq -r '.Catalogues = [1]')
plan_response=$(echo $plan_response | jq -r '.Quota = -1')
if [ "$plan" -ge 2 ]
if [ "$plan" -ge 3 ]
then
plan_response=$(echo $plan_response | jq -r '.Catalogues = [1, 2]')
fi
api_response=$(curl --location --request PUT 'http://tyk-portal.localhost:3100/portal-api/plans/2' -s \
api_response=$(curl --location --request PUT "http://tyk-portal.localhost:3100/portal-api/plans/$plan" -s \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header "Authorization: $portal_admin_api_token" \
--data "$plan_response")
log_message "PLAN UPDATED: $api_response"
unset api_response plan_response
done

log_ok
bootstrap_progress












log_end_deployment
# Echo credentials for Admin, Example Developer and Example Consumer
echo -e "\033[2K
Expand Down
3 changes: 3 additions & 0 deletions deployments/portal/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ services:
image: tykio/portal:v1.8.5
networks:
- tyk
environment:
- PORTAL_AUDIT_LOG_PATH=/opt/portal/
env_file:
- .env
ports:
- 3100:3001
entrypoint: /opt/portal/dev-portal
volumes:
- ./deployments/portal/volumes/portal.log:/opt/portal/portal.log
- ./deployments/portal/volumes/database/portal.db:/opt/portal/portal.db
- ./deployments/portal/volumes/assets/:/opt/portal/public/system/products/
tyk-portal-postgres:
Expand Down
Empty file.
Empty file.

0 comments on commit 13dfb64

Please sign in to comment.