Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add image parameters to compose.yaml #1092

Merged
merged 5 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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=
Expand Down
31 changes: 31 additions & 0 deletions compose.dev.override.yaml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions compose.dev.yaml
Original file line number Diff line number Diff line change
@@ -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
30 changes: 5 additions & 25 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -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"]
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -89,10 +73,6 @@ services:
depends_on:
divviup_api_migrate:
condition: service_completed_successfully
develop:
watch:
- path: src/
action: rebuild

divviup_api_vite:
build:
Expand Down
Loading