docker compose overlay file for editable backend container (#1098)

Co-authored-by: burnettk <burnettk@users.noreply.github.com>
This commit is contained in:
jbirddog 2024-02-23 19:13:16 -05:00 committed by GitHub
parent 336f559e68
commit ea9336e625
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 90 additions and 18 deletions

View File

@ -1,26 +1,62 @@
MY_USER := $(shell id -u)
MY_GROUP := $(shell id -g)
ME := $(MY_USER):$(MY_GROUP)
BACKEND_CONTAINER ?= spiffworkflow-backend
BACKEND_DEV_OVERLAY ?= spiffworkflow-backend/dev.docker-compose.yml
FRONTEND_CONTAINER ?= spiffworkflow-frontend FRONTEND_CONTAINER ?= spiffworkflow-frontend
FRONTEND_DEV_OVERLAY ?= spiffworkflow-frontend/dev.docker-compose.yml FRONTEND_DEV_OVERLAY ?= spiffworkflow-frontend/dev.docker-compose.yml
dev-env: DOCKER_COMPOSE ?= RUN_AS=$(ME) docker compose $(YML_FILES)
docker compose -f docker-compose.yml \ IN_BACKEND ?= $(DOCKER_COMPOSE) run $(BACKEND_CONTAINER)
-f $(FRONTEND_DEV_OVERLAY) \ IN_FRONTEND ?= $(DOCKER_COMPOSE) run $(FRONTEND_CONTAINER)
build
start-dev: YML_FILES := -f docker-compose.yml \
docker compose -f docker-compose.yml \ -f $(BACKEND_DEV_OVERLAY) \
-f $(FRONTEND_DEV_OVERLAY) \ -f $(FRONTEND_DEV_OVERLAY)
up -d
all: dev-env start-dev be-tests-par
@/bin/true
build-images:
$(DOCKER_COMPOSE) build
dev-env: build-images fe-npm-i be-recreate-db
@/bin/true
start-dev: stop-dev
$(DOCKER_COMPOSE) up -d
stop-dev: stop-dev:
docker compose -f docker-compose.yml \ $(DOCKER_COMPOSE) down
-f $(FRONTEND_DEV_OVERLAY) \
down be-recreate-db:
$(IN_BACKEND) ./bin/recreate_db clean
be-sh:
$(IN_BACKEND) /bin/bash
be-tests:
$(IN_BACKEND) poetry run pytest
be-tests-par:
$(IN_BACKEND) poetry run pytest -n auto -x --random-order
fe-lint-fix: fe-lint-fix:
docker exec -it $(FRONTEND_CONTAINER) npm run lint:fix $(IN_FRONTEND) npm run lint:fix
fe-npm-i:
$(IN_FRONTEND) npm i
fe-sh: fe-sh:
docker exec -it $(FRONTEND_CONTAINER) /bin/bash $(IN_FRONTEND) /bin/bash
.PHONY: dev-env start-dev stop-dev \ take-ownership:
fe-lint-fix fe-sh sudo chown -R $(ME) .
.PHONY: build-images dev-env \
start-dev stop-dev \
be-recreate-db be-sh be-tests be-tests-par \
fe-lint-fix fe-npm-i fe-sh \
take-ownership

View File

@ -0,0 +1,19 @@
FROM python:3.12.1-slim-bookworm
WORKDIR /app
RUN apt-get update \
&& apt-get install -y -q \
gcc libssl-dev libpq-dev default-libmysqlclient-dev \
pkg-config libffi-dev git-core curl
RUN pip install --upgrade pip
RUN pip install poetry==1.6.1 pytest-xdist
COPY pyproject.toml poetry.lock .
RUN poetry install --no-root
COPY ./ ./
RUN poetry install --only-root
CMD ["./bin/run_server_locally"]

View File

@ -0,0 +1,17 @@
services:
spiffworkflow-backend:
build:
context: spiffworkflow-backend
dockerfile: dev.Dockerfile
#
# TODO: would like to figure out the permissions issue that is preventing this
#
#user: "${RUN_AS}"
environment:
FLASK_DEBUG: "1"
SPIFFWORKFLOW_BACKEND_DATABASE_URI: ""
SPIFFWORKFLOW_BACKEND_ENV: "local_development"
SPIFFWORKFLOW_BACKEND_LOAD_FIXTURE_DATA: ""
volumes:
- ./spiffworkflow-backend:/app

View File

@ -5,10 +5,9 @@ from os import environ
TESTING = True TESTING = True
SPIFFWORKFLOW_BACKEND_LOG_TO_FILE = environ.get("SPIFFWORKFLOW_BACKEND_LOG_TO_FILE", default="true") == "true" SPIFFWORKFLOW_BACKEND_LOG_TO_FILE = environ.get("SPIFFWORKFLOW_BACKEND_LOG_TO_FILE", default="true") == "true"
SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME = environ.get( SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME = "unit_testing.yml"
"SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME", default="unit_testing.yml"
)
SPIFFWORKFLOW_BACKEND_URL = "http://localhost:7000"
SPIFFWORKFLOW_BACKEND_OPEN_ID_SERVER_URL = "http://localhost:7000/openid" SPIFFWORKFLOW_BACKEND_OPEN_ID_SERVER_URL = "http://localhost:7000/openid"
SPIFFWORKFLOW_BACKEND_OPEN_ID_CLIENT_ID = "spiffworkflow-backend" SPIFFWORKFLOW_BACKEND_OPEN_ID_CLIENT_ID = "spiffworkflow-backend"
SPIFFWORKFLOW_BACKEND_OPEN_ID_CLIENT_SECRET_KEY = "JXeQExm0JhQPLumgHtIIqf52bDalHz0q" # noqa: S105 SPIFFWORKFLOW_BACKEND_OPEN_ID_CLIENT_SECRET_KEY = "JXeQExm0JhQPLumgHtIIqf52bDalHz0q" # noqa: S105

View File

@ -3,6 +3,7 @@ services:
build: build:
context: spiffworkflow-frontend context: spiffworkflow-frontend
dockerfile: dev.Dockerfile dockerfile: dev.Dockerfile
user: "${RUN_AS}"
environment: environment:
HOST: "0.0.0.0" HOST: "0.0.0.0"
PORT: "${SPIFFWORKFLOW_FRONTEND_PORT:-8001}" PORT: "${SPIFFWORKFLOW_FRONTEND_PORT:-8001}"