lsst-epo / investigations-api

Backend to the investigations 2.0 site
0 stars 0 forks source link

Formal Education Investigations Craft CMS

Set up and run the project locally

Make scripts


To list the local databases for this project, first bring up the postgres container if it's not already up:

docker-compose -f docker-compose-local-db.yml up --build postgres

Then, list your local databases:

make db-list


To list the databases sitting around in the prod environment so that you can know which dbname to supply in make cloud-db-export dbname=(which db you want to export):

make cloud-db-list


To export a prod database to the gs://release_db_sql_files/investigations/ bucket:

make cloud-db-export dbname=prod_db

docker-compose -f docker-compose-local-db.yml up --build postgres

Ensure that the dump file is located within ./db/, then run:

make local-db dbname=my_new_local_db dbfile=prod.sql






Deprecated workflow

  1. Uncomment the COPY line in ./db/Dockerfile
  2. Install Docker
  3. Clone this repository
  4. Add a .env file (based on .env.sample) and provide values appropriate to your local dev environment
  5. If running for the first time, docker will create a local DB based on the db.sql file in /db
  6. You'll need to install php packages locally. You may do so with your local composer, but you can also run it all through docker: docker run -v ${PWD}/api:/app composer install
  7. Build and bring up containers for the first time:
docker-compose -f docker-compose-local-db.yml up --build
  1. Subsequent bringing up of containers you've already built:
    docker-compose -f docker-compose-local-db.yml up
  2. Go to http://localhost:8080/admin to administer the site
  3. Default admin username and password, as included in the db.sql file, is example / password

These and other most used docker commands for bringing containers up/down are aliased in a Makefile:

Useful docker commands for local development

  1. Cleaning house: docker volume prune docker system prune
  2. Spin stuff down politely: docker-compose -f docker-compose-local-db.yml down
  3. Peek inside your running docker containers:
    • docker container ls
    • docker exec -it <CONTAINER-ID> /bin/sh
    • and then, for instance, to look at DB psql -d craft -U craft
  4. To rebuild images and bring up the containers: docker-compose -f docker-compose-local-db.yml up --build
  5. When you need to do composer stuff: docker run -v ${PWD}/api:/app composer <blah>
  6. After ssh-ing into a live GAE instance, by way of the GCP console interface, you can ssh into a running container: docker exec -ti gaeapp sh
  7. When working locally, in order to ensure the latest docker craft-base-image is used: docker pull us-central1-docker.pkg.dev/skyviewer/public-images/craft-base-image