Deploying DCB Admin to AWS
This document outlines how to deploy DCB Admin with AWS Amplify.
Getting started
Sign into the AWS management console and open the AWS Amplify console for your organisation. You should see a page with the title ‘All apps’.
For your first time, you will need to create an Amplify application. To do this, select ‘New app’, and then select ‘Host web app’.
On the next page, select GitHub as your repository provider, and click ‘Continue’.
If you are asked to authorize with GitHub, continue, select openlibraryenvironment, and then choose ‘select repositories’ and select
dcb-admin-ui
from the dropdown.On the ‘Add repository branch’ page,
select the
dcb-admin-ui
repository (https://github.com/openlibraryenvironment/dcb-admin-ui)select the
release
branch and continue.
On the ‘build settings’ page, select ‘Enable SSR logs' if it is not automatically selected, and then choose ‘Create and use a new service role’ to allow Amplify to automatically create a service role for you.
If you have a previously created service role that you want to use instead, select that option.
Choose ‘Next’, and then click ‘Save and deploy’.
If you notice that the framework for your app is automatically set to ‘web’ instead of ‘Next.js - SSR', please scroll down to the ‘Common errors' section of this document and follow the instructions for updating the framework manually.
This section also has instructions for updating the app platform manually - on rare occasions Amplify will automatically set it to ‘Web’ when it should be ‘Web compute’.
For more information, please refer to the relevant AWS Amplify docs.
Setting up environment variables and Keycloak
To set up the necessary environment variables for DCB Admin, you must navigate to ‘App settings’ and then to ‘Environment variables’.
Add the required environment variables from the table below. Some of these variables are deployment-specific, and others will need to come from your Keycloak configuration.
You will then need to modify the Amplify build specification file
amplify.yml
to make these variables accessible to Next.js. This can be found under ‘App build specification’ in ‘Build settings’. Simply click ‘Edit’ and add these lines underbuild: commands:
- env | grep -e DCB_ >> .env.production
- env | grep -e KEYCLOAK_ >> .env.production
- env | grep -e NEXTAUTH_ >> .env.production
Save your changes and redeploy your application - go to ‘All apps', click on your deployment and select ‘redeploy this version’.
Navigate to your Keycloak Admin UI, select
dcb-hub
and then selectdcb
from ‘clients'. You will then need to add the URL of your deployment to ‘Valid redirect URIs’ and 'Valid post-logout redirect URIs’ like so:https://<your-app-URL>/*
. This must be done for all URLs to which DCB Admin is deployed.
For more information please refer to the official documentation.
Required environment variables
DCB_API_BASE | URL of your DCB deployment |
KEYCLOAK_ID | The |
KEYCLOAK_URL | URL of your Keycloak server Example: |
KEYCLOAK_SECRET | This is the |
NEXTAUTH_SECRET | Secret from NextAuth, use this example:
|
NEXTAUTH_URL | URL of your DCB Admin deployment. You can find this under ‘All apps’ in the Amplify console. |
NEXT_PUBLIC_MUI_X_LICENSE_KEY | The license key that enables MUI X Pro features in DCB Admin. Please contact dcb@k-int.com for the key itself. If you are seeing a watermark on data grids in DCB Admin, this environment variable is not configured correctly. Please refer to the MUI docs for more information. |
Common errors and how to solve them
If you encounter the following error (or similar) when deploying DCB Admin, there is a simple fix:
CustomerError: It looks like you are attempting to deploy a Next.js SSR app, but your app's framework looks wrong. Please update your app's framework to 'Next.js - SSR' to ensure that your app is deployed correctly.
Solution: Run the following command in CloudShell. This will update the framework manually:
aws amplify update-branch --app-id <value> --branch-name <value> --framework 'Next.js - SSR'
The value of app-id can be found under ‘App ARN’ in App settings → General. It is the value at the end of the ARN (highlighted in the screenshot)
If you deploy successfully, but encounter a 404 Not Found page when you click on the branch URL, your app platform may have been set incorrectly by Amplify (see this GitHub issue - it should be Web compute). To fix this, run the command
aws amplify update-app --app-id <APP_ID> --platform WEB_COMPUTE --region <REGION>
, getting the value of app-id with the method described above.If you encounter an error when attempting to login (i.e. the URL changes to indicate an OAuthSignInError), please confirm that your Keycloak server is up, and that you have added the correct URL of your DCB Admin deployment to the ‘Valid redirect URIs’ and ‘Valid post-logout redirect URIs’ in your Keycloak admin UI.
If you encounter an error connecting to the repository, please contact Knowledge Integration.
Amplify docs can be found here for further context and troubleshooting https://docs.aws.amazon.com/amplify/latest/userguide/welcome.html
Operated as a Community Resource by the Open Library Foundation