Docker and docker compose development - CDCgov/prime-simplereport GitHub Wiki
Caution
If you are using a Mac with an M1 chip, this setup will not work, as first noticed on 07/13/2022. When trying to start the frontend
, backend
, and Nginx
containers, it will throw a Function not implemented
error. However, the database
container will still work.
Intro
For ease of local setup, we have created a docker compose setup, which builds docker images for all the necessary components. It also uses Nginx and mkcert to host the app locally over HTTPS. This setup more closely replicates the code deployed to production and is preferred for testing code in production. DevOps engineers prefer this setup.
Prerequisites
- Install docker and docker compose.
- Install mkcert
- Install Node.js 18 using nvm or your preferred method. This is used for yarn scripts and pre-commit hooks.
- Install AdoptOpenJDK 17 using jabba or your preferred method. This is useful for IDE integration (IntelliJ, VS Code, etc.)
- Install yarn by running
npm install --global yarn
.
Starting the app
- Clone this repository:
git clone [email protected]:CDCgov/prime-simplereport.git
- Run
yarn install
in the root of the repository to install pre-commit hooks using lefthook - Run
cp .env.sample .env
in the repository's root, then obtain the needed secrets from Azure or another developer. Be sure to set theOKTA_API_KEY
environment variable. You can generate an API token for yourself by logging into the Okta Preview admin panel and going into Security > API > Tokens. - Run
sudo vim /etc/hosts
(or use your editor of choice) and add a line to the bottom with the following contents and save:127.0.0.1 localhost.simplereport.gov
- Follow these steps from GitHub for authenticating to the container registry.
- Run
yarn start
in the root of the repository to start the app - Make your user a support admin by assigning yourself the
SR-DEV-ADMINS
group in Okta Preview. - When the frontend and backend builds are complete, visit https://localhost.simplereport.gov/app
You should see the support admin page. The application does not yet start with any seed data, so you'll need to add your own organization and facilities. You can create your first org at https://localhost.simplereport.gov/app/sign-up.
Notes
Make sure docker has access to enough resources on your local machine. You'll know it doesn't if you get an error from any of your containers similar to this:
"The build failed because the process exited too early. This probably means the system ran out of memory or someone called `kill -9` on the process."
How to update resource limits on your Mac, and Windows machines.