diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 66f2c2ddbff..4f25902db39 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -51,7 +51,7 @@ jobs: - name: Run API tests working-directory: ./openverse_api env: - PIPENV_DOTENV_LOCATION: ./.env.stencil + PIPENV_DOTENV_LOCATION: ./env.template run: pipenv run test/run_test.sh - name: Run analytics tests working-directory: ./analytics diff --git a/README.md b/README.md index 9a0c13de964..5290d14fa4b 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ This repository is primarily concerned with back end infrastructure like datasto cd openverse-api/ ``` -3. From the monorepo root, bring up the Docker Compose system. Docker Compose will automatically read the necessary environment variables from `.env.docker` files from project directories. +3. From the monorepo root, bring up the Docker Compose system. Docker Compose will automatically read the necessary environment variables from `env.docker` files from project directories. ```bash just up ``` diff --git a/docker-compose.yml b/docker-compose.yml index 7da48d74dd1..33e8cdb3f96 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,7 +5,7 @@ services: ports: - "5432:5432" env_file: - - postgres/.env.docker + - postgres/env.docker healthcheck: test: "pg_isready -U deploy -d openledger" @@ -22,7 +22,7 @@ services: volumes: - ./sample_data:/sample_data env_file: - - postgres/.env.docker + - postgres/env.docker healthcheck: test: "pg_isready -U deploy -d openledger" @@ -59,7 +59,7 @@ services: - es - cache env_file: - - openverse_api/.env.docker + - openverse_api/env.docker stdin_open: true tty: true @@ -80,7 +80,7 @@ services: volumes: - ./ingestion_server:/ingestion_server env_file: - - ingestion_server/.env.docker + - ingestion_server/env.docker stdin_open: true tty: true @@ -96,7 +96,7 @@ services: volumes: - ./ingestion_server:/ingestion_server env_file: - - ingestion_server/.env.docker + - ingestion_server/env.docker stdin_open: true tty: true diff --git a/ingestion_server/README.md b/ingestion_server/README.md index 02b734bb784..11bbdc9c8dd 100644 --- a/ingestion_server/README.md +++ b/ingestion_server/README.md @@ -57,7 +57,7 @@ will be `"INGEST_UPSTREAM"`. ## Configuration -All configuration is performed through environment variables. See the `.env.stencil` file for a comprehensive list of all environment variables. The ones with sane defaults have been commented out. +All configuration is performed through environment variables. See the `env.template` file for a comprehensive list of all environment variables. The ones with sane defaults have been commented out. Pipenv will automatically load `.env` files when running commands with `pipenv run`. diff --git a/ingestion_server/.env.docker b/ingestion_server/env.docker similarity index 100% rename from ingestion_server/.env.docker rename to ingestion_server/env.docker diff --git a/ingestion_server/.env.stencil b/ingestion_server/env.template similarity index 100% rename from ingestion_server/.env.stencil rename to ingestion_server/env.template diff --git a/justfile b/justfile index 8717813baef..c9a0c6c749d 100644 --- a/justfile +++ b/justfile @@ -1,58 +1,77 @@ set dotenv-load := false -DOCKER_FILE := "-f docker-compose.yml" - +# Show all available recipes +default: + @just --list --unsorted -install: - #! /usr/bin/env sh - cd openverse_api - pipenv install --dev - pipenv run pre-commit install +########## +# Docker # +########## -lint: - #! /usr/bin/env sh - cd openverse_api - pipenv run pre-commit run --all-files - - -env: - #! /usr/bin/env sh - cp openverse_api/.env.stencil openverse_api/.env - cp ingestion_server/.env.stencil ingestion_server/.env - +DOCKER_FILE := "-f docker-compose.yml" +# Bring all Docker services up up: docker-compose {{ DOCKER_FILE }} up -d - +# Take all Docker services down down args="": docker-compose {{ DOCKER_FILE }} down {{ args }} +# Show logs of all, or named, Docker services +logs services="": + docker-compose {{ DOCKER_FILE }} logs -f {{ services }} + +######## +# Init # +######## + +# Create .env files from stencils +env: + cp openverse_api/env.template openverse_api/.env + cp ingestion_server/env.template ingestion_server/.env + +# Load sample data into the Docker Compose services init: up ./load_sample_data.sh - +# Make a test cURL request to the API healthcheck: curl "http://localhost:8000/v1/images/stats/" -test: up - docker-compose exec web ./test/run_test.sh +####### +# Dev # +####### +# Install Python dependencies in Pipenv environments +install: + cd openverse_api && pipenv install --dev + cd ingestion_server && pipenv install --dev -testlocal: - #! /usr/bin/env sh - cd openverse_api - pipenv run ./test/run_test.sh +# Setup pre-commit as a Git hook +precommit: + cd openverse_api && pipenv run pre-commit install +# Run pre-commit to lint and reformat all files +lint: + cd openverse_api && pipenv run pre-commit run --all-files + + +####### +# API # +####### -logs service="": - docker-compose {{ DOCKER_FILE }} logs -f {{ service }} +# Run API tests inside Docker +test: up + docker-compose exec web ./test/run_test.sh +# Run API tests locally +testlocal: + cd openverse_api && pipenv run ./test/run_test.sh +# Run Django administrative commands dj args="": - #! /usr/bin/env sh - cd openverse_api - pipenv run python manage.py {{ args }} + cd openverse_api && pipenv run python manage.py {{ args }} diff --git a/openverse_api/README.md b/openverse_api/README.md index e7b3863e79a..1d79a636e0e 100644 --- a/openverse_api/README.md +++ b/openverse_api/README.md @@ -54,7 +54,7 @@ You can view the custom administration views at the `/admin/` endpoint. You can ## Configuration -All configuration is performed through environment variables. See the `.env.stencil` file for a comprehensive list of all environment variables. The ones with sane defaults have been commented out. +All configuration is performed through environment variables. See the `env.template` file for a comprehensive list of all environment variables. The ones with sane defaults have been commented out. Pipenv will automatically load `.env` files when running commands with `pipenv run`. diff --git a/openverse_api/.env.docker b/openverse_api/env.docker similarity index 100% rename from openverse_api/.env.docker rename to openverse_api/env.docker diff --git a/openverse_api/.env.stencil b/openverse_api/env.template similarity index 100% rename from openverse_api/.env.stencil rename to openverse_api/env.template diff --git a/postgres/.env.docker b/postgres/env.docker similarity index 100% rename from postgres/.env.docker rename to postgres/env.docker