docker compose overlay file for running run_pyl equivalents (#1100)

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit is contained in:
jbirddog 2024-02-27 09:13:02 -05:00 committed by GitHub
parent b210b84b3a
commit 2469941ea6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 61 additions and 7 deletions

View File

@ -2,6 +2,11 @@ MY_USER := $(shell id -u)
MY_GROUP := $(shell id -g) MY_GROUP := $(shell id -g)
ME := $(MY_USER):$(MY_GROUP) ME := $(MY_USER):$(MY_GROUP)
SUDO ?= sudo
ARENA_CONTAINER ?= spiff-arena
ARENA_DEV_OVERLAY ?= dev.docker-compose.yml
BACKEND_CONTAINER ?= spiffworkflow-backend BACKEND_CONTAINER ?= spiffworkflow-backend
BACKEND_DEV_OVERLAY ?= spiffworkflow-backend/dev.docker-compose.yml BACKEND_DEV_OVERLAY ?= spiffworkflow-backend/dev.docker-compose.yml
@ -9,14 +14,16 @@ FRONTEND_CONTAINER ?= spiffworkflow-frontend
FRONTEND_DEV_OVERLAY ?= spiffworkflow-frontend/dev.docker-compose.yml FRONTEND_DEV_OVERLAY ?= spiffworkflow-frontend/dev.docker-compose.yml
DOCKER_COMPOSE ?= RUN_AS=$(ME) docker compose $(YML_FILES) DOCKER_COMPOSE ?= RUN_AS=$(ME) docker compose $(YML_FILES)
IN_ARENA ?= $(DOCKER_COMPOSE) run $(ARENA_CONTAINER)
IN_BACKEND ?= $(DOCKER_COMPOSE) run $(BACKEND_CONTAINER) IN_BACKEND ?= $(DOCKER_COMPOSE) run $(BACKEND_CONTAINER)
IN_FRONTEND ?= $(DOCKER_COMPOSE) run $(FRONTEND_CONTAINER) IN_FRONTEND ?= $(DOCKER_COMPOSE) run $(FRONTEND_CONTAINER)
YML_FILES := -f docker-compose.yml \ YML_FILES := -f docker-compose.yml \
-f $(BACKEND_DEV_OVERLAY) \ -f $(BACKEND_DEV_OVERLAY) \
-f $(FRONTEND_DEV_OVERLAY) -f $(FRONTEND_DEV_OVERLAY) \
-f $(ARENA_DEV_OVERLAY)
all: dev-env start-dev be-tests-par all: dev-env start-dev run-pyl
@/bin/true @/bin/true
build-images: build-images:
@ -31,16 +38,25 @@ start-dev: stop-dev
stop-dev: stop-dev:
$(DOCKER_COMPOSE) down $(DOCKER_COMPOSE) down
be-clear-log-file:
$(IN_BACKEND) rm -f log/unit_testing.log
be-mypy:
$(IN_BACKEND) poetry run mypy src tests
be-recreate-db: be-recreate-db:
$(IN_BACKEND) ./bin/recreate_db clean $(IN_BACKEND) ./bin/recreate_db clean
be-ruff:
$(IN_BACKEND) poetry run ruff --fix .
be-sh: be-sh:
$(IN_BACKEND) /bin/bash $(IN_BACKEND) /bin/bash
be-tests: be-tests: be-clear-log-file
$(IN_BACKEND) poetry run pytest $(IN_BACKEND) poetry run pytest
be-tests-par: be-tests-par: be-clear-log-file
$(IN_BACKEND) poetry run pytest -n auto -x --random-order $(IN_BACKEND) poetry run pytest -n auto -x --random-order
fe-lint-fix: fe-lint-fix:
@ -52,11 +68,21 @@ fe-npm-i:
fe-sh: fe-sh:
$(IN_FRONTEND) /bin/bash $(IN_FRONTEND) /bin/bash
pre-commit:
$(IN_ARENA) poetry run pre-commit run --verbose --all-files
run-pyl: fe-lint-fix pre-commit be-mypy be-tests-par
@/bin/true
sh:
$(IN_ARENA) /bin/bash
take-ownership: take-ownership:
sudo chown -R $(ME) . $(SUDO) chown -R $(ME) .
.PHONY: build-images dev-env \ .PHONY: build-images dev-env \
start-dev stop-dev \ start-dev stop-dev \
be-recreate-db be-sh be-tests be-tests-par \ be-clear-log-file be-recreate-db be-ruff be-sh be-tests be-tests-par \
fe-lint-fix fe-npm-i fe-sh \ fe-lint-fix fe-npm-i fe-sh \
pre-commit run-pyl \
take-ownership take-ownership

16
dev.Dockerfile Normal file
View File

@ -0,0 +1,16 @@
FROM python:3.12.1-slim-bookworm
WORKDIR /app
RUN apt-get update \
&& apt-get install -y -q git-core curl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN git config --global --add safe.directory /app
RUN pip install --upgrade pip
RUN pip install poetry==1.6.1
COPY pyproject.toml poetry.lock .
RUN poetry install --no-root

12
dev.docker-compose.yml Normal file
View File

@ -0,0 +1,12 @@
services:
spiff-arena:
build:
context: .
dockerfile: dev.Dockerfile
#
# TODO: would like to figure out the permissions issue that is preventing this
#
#user: "${RUN_AS}"
volumes:
- ./:/app