diff --git a/README.md b/README.md index 8f1e4371..9d3da0d6 100644 --- a/README.md +++ b/README.md @@ -42,11 +42,33 @@ This will get you up and running quickly for development purposes. 1. Clone the repository and navigate to its root. 1. Execute `echo "http://localhost:8080" >app/public/api_url` -1. Execute `docker compose watch`. +1. Execute `docker compose up`. 1. Navigate in your browser to `http://localhost:8081/`. -`docker compose` will automatically reload containers when you make changes. Data is persisted -until you `docker compose rm --volumes`. +Data is persisted until you `docker compose rm --volumes`. + +If you want to use image versions besides the defaults, you can use environment variables +`JANUS_AGGREGATOR_IMAGE`, `JANUS_MIGRATOR_IMAGE`, `DIVVIUP_API_IMAGE` and +`DIVVIUP_API_MIGRATOR_IMAGE` when invoking `docker compose`. For example: + +```bash +DIVVIUP_API_IMAGE=divviup_api:localversion \ + JANUS_IMAGE=us-west2-docker.pkg.dev/divviup-artifacts-public/janus/janus_aggregator:0.7.18 \ + docker compose up +``` + +`divviup_api:localversion` will be pulled from the local Docker repository and +`us-west2-docker.pkg.dev/divviup-artifacts-public/janus/janus_aggregator:0.7.18` will be pulled from +`us-west2-docker.pkg.dev`. + +We also provide `compose.dev.yaml`, which will build `divviup-api` from local sources. Try: + +```bash +docker compose -f compose.dev.yaml watch +``` + +`docker compose` will automatically reload containers when you make changes. The `JANUS_IMAGE` and +`JANUS_MIGRATOR_IMAGE` variables are honored by `compose.dev.yaml`. Two Janus aggregators will be created for you, but are not automatically paired to divviup-api. Their information is: @@ -58,6 +80,7 @@ testing client, they are mapped to `localhost:9001` and `localhost:9002`, respec If using the divviup CLI, consider compiling with the `--features admin` option. Also, set these environment variables. + ```bash # This token is intentionally blank, but you'll still need to set the variable. export DIVVIUP_TOKEN= diff --git a/compose.dev.override.yaml b/compose.dev.override.yaml new file mode 100644 index 00000000..cfec4b75 --- /dev/null +++ b/compose.dev.override.yaml @@ -0,0 +1,31 @@ +# Overrides for the local development docker compose setup. Meant only to be used by +# compose.dev.yaml + +services: + divviup_api: + image: !reset null + build: + context: . + args: + RUST_PROFILE: dev + RUST_FEATURES: integration-testing + develop: + watch: + - path: src/ + action: rebuild + + divviup_api_migrate: + image: !reset null + build: + context: . + args: + RUST_PROFILE: dev + # This isn't strictly required for migrations, but it allows reusing one container image + # for both this and the divviup_api service. + RUST_FEATURES: integration-testing + develop: + watch: + - path: migration + action: rebuild + ignore: + - README.md diff --git a/compose.dev.yaml b/compose.dev.yaml new file mode 100644 index 00000000..735f2bae --- /dev/null +++ b/compose.dev.yaml @@ -0,0 +1,8 @@ +# Local development-only compose file which builds divviup-api from source. This is not suitable for +# production! + +include: + - path: + # These files are ordered deliberately so that they will be merged correctly + - compose.yaml + - compose.dev.override.yaml diff --git a/compose.yaml b/compose.yaml index dd9d433c..6e370a4b 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,7 +1,7 @@ -# Local development-only compose file. This is not suitable for production! +# Compose file for bringing up a simple local Divvi Up environment. This is not suitable for production! x-janus-common: &janus_common - image: us-west2-docker.pkg.dev/divviup-artifacts-public/janus/janus_aggregator:0.7.7 + image: ${JANUS_AGGREGATOR_IMAGE:-us-west2-docker.pkg.dev/divviup-artifacts-public/janus/janus_aggregator:0.7.7} restart: always healthcheck: test: ["CMD", "/bin/sh", "-c", "wget http://0.0.0.0:8000/healthz -O - >/dev/null"] @@ -12,7 +12,7 @@ x-janus-common: &janus_common condition: service_completed_successfully x-janus-migrate: &janus_migrate - image: us-west2-docker.pkg.dev/divviup-artifacts-public/janus/janus_db_migrator:0.7.7 + image: ${JANUS_MIGRATOR_IMAGE:-us-west2-docker.pkg.dev/divviup-artifacts-public/janus/janus_db_migrator:0.7.7} command: - migrate - run @@ -43,13 +43,7 @@ services: target: /docker-entrypoint-initdb.d/postgres_init.sql divviup_api_migrate: - build: - context: . - args: - RUST_PROFILE: dev - # This isn't strictly required for migrations, but it allows reusing one container image - # for both this and the divviup_api service. - RUST_FEATURES: integration-testing + image: ${DIVVIUP_API_MIGRATOR_IMAGE:-us-west2-docker.pkg.dev/divviup-artifacts-public/divviup-api/divviup_api:0.3.12} entrypoint: - /migration - up @@ -58,19 +52,9 @@ services: depends_on: postgres: condition: service_started - develop: - watch: - - path: migration - action: rebuild - ignore: - - README.md divviup_api: - build: - context: . - args: - RUST_PROFILE: dev - RUST_FEATURES: integration-testing + image: ${DIVVIUP_API_IMAGE:-us-west2-docker.pkg.dev/divviup-artifacts-public/divviup-api/divviup_api:0.3.12} ports: - "8080:8080" environment: @@ -89,10 +73,6 @@ services: depends_on: divviup_api_migrate: condition: service_completed_successfully - develop: - watch: - - path: src/ - action: rebuild divviup_api_vite: build: