diff --git a/Makefile b/Makefile index 9aefc94..282c13f 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ build-no-cache: docker build --no-cache -t application-portfolio . .PHONY: up -up: npm-install +up: # Start the application using docker-compose with build. docker-compose up -d --build --force-recreate @@ -58,12 +58,12 @@ logs: docker logs -f portfolio .PHONY: dev -dev: npm-install +dev: # Start the application in development mode using docker-compose. FLASK_ENV=development docker-compose up -d .PHONY: prod -prod: npm-install +prod: # Start the application in production mode using docker-compose (with build). docker-compose up -d --build @@ -92,11 +92,6 @@ install-dev: # Install runtime and developer dependencies from pyproject.toml. $(PYTHON) -m pip install -e ".[dev]" -.PHONY: npm-install -npm-install: - # Install Node.js dependencies for browser tests. - cd app && npm install - .PHONY: lint-actions lint-actions: # Lint GitHub Actions workflows. @@ -145,7 +140,7 @@ security: install-dev test-security $(PYTHON) -m pip_audit -r /tmp/portfolio-runtime-requirements.txt .PHONY: test-e2e -test-e2e: npm-install +test-e2e: # Run Cypress end-to-end tests via act (stop portfolio container to free port first). -docker stop portfolio 2>/dev/null || true $(ACT) workflow_dispatch -W .github/workflows/tests.yml -j e2e diff --git a/docker-compose.yml b/docker-compose.yml index 1559a0c..49ba860 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,4 +12,13 @@ services: - .env volumes: - ./app:/app + - node_modules:/app/node_modules + - vendor:/app/static/vendor + # Run `npm install` on every container start so the named volumes + # reflect the current package.json (postinstall regenerates vendor/). + command: sh -c "npm install --prefix /app --no-audit --no-fund && python app.py" restart: unless-stopped + +volumes: + node_modules: + vendor: