Helpful Docker commands that allow you to bring up containers, run a bunch of tests and then stop the containers.
Note for Mac Users: By default, docker on Mac will restrict itself to using just 2GB of memory. This should be increased to at least 6GB to avoid running in to unexpected problems.
Note for Mac Users 2: Should you ever come across this error:
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
Go to Docker Desktop -> Settings -> General and check the Use Rosetta for x86/amd64 emulation on Apple Silicon checkbox. That should fix the issue.
Note for all users: The docker volumes for the frontend, api and sandbox api are all mounted. This means that you should not need to rebuild the containers when you make changes and you should see your changes reflected immediately. However, there are certain changes that will require you to rebuild. In that case, bring down the containers and run the script again. The scripts will always rebuild you containers if it detects code changes, otherwise they will be quick to come up and will just use the images it has in the docker cache.
Prerequisite:
cp sample.env .env
- Docker
- Table of Contents
Ensure you have gcloud CLI installed and you are logged in following their instructions (you will need to ask SRE for access). You will need to setup authentication using the gcloud credential helper before you can push the new container. The project to select is sre-docker-registry
If you have issues when building the dependencies image, especially if you are using a Mac with an Apple chip, this is most likely due to incompatibility with the
arm
architecture; instead you need to build onamd
architecture. Please refer to troubleshooting guide and follow the steps under the Building dependency images section, before retrying the build command below.
export VERSION=4.3.8 # Increment this version each time when you edit Dockerfile.
docker build -f Dockerfile.dependencies -t data-hub-frontend-dependencies . --platform linux/amd64
docker tag data-hub-frontend-dependencies:latest gcr.io/sre-docker-registry/data-hub-frontend-dependencies:${VERSION}
docker tag data-hub-frontend-dependencies:latest gcr.io/sre-docker-registry/data-hub-frontend-dependencies:latest
docker push gcr.io/sre-docker-registry/data-hub-frontend-dependencies:${VERSION}
docker push gcr.io/sre-docker-registry/data-hub-frontend-dependencies:latest
Your image should be now listed at Google Container Registry.
Prerequisite: Ensure data-hub-api
is sitting in the same directory as data-hub-frontend
make start-dev // bring up the containers
make stop-dev // stop and remove the containers
Once the containers are up, in a browser go to: http://localhost:3000
and you'll be redirected to mock-sso. For now (we're working on it) change the domain from mock-sso
to localhost
to view the application.
make start-mock // bring up the containers
make functional-tests // runs the tests inside the container
make stop-mock // stop and remove the containers
Instead of running the tests inside the container you can also run them outside the container npm run test:functional
.
make start-e2e-dit // bring up the containers
make e2e-tests-dit // run the tests inside the container
make stop-e2e // stop and remove the containers
make start-e2e-lep // bring up the containers
make e2e-tests-lep // run the tests inside the container
make stop-e2e // stop and remove the containers
make start-e2e-da // bring up the containers
make e2e-tests-da // run the tests inside the container
make stop-e2e // stop and remove the containers
Note: Before running the tests (and the containers are up) in a browser go to: http://localhost:3000
and you'll be redirected to mock-sso. For now (we're working on it) change the domain from mock-sso
to localhost
to view the application.
make start-mock // bring up the containers
make a11y-tests // run the tests inside the container
make unit-client-tests