mirror of
https://github.com/kevinveenbirkenbach/homepage.veen.world.git
synced 2026-05-14 09:15:32 +00:00
build(compose): run npm install in container, persist deps in named volumes
Replace the host-side `make npm-install` step with a compose-level `command:` override that runs `npm install` inside the container on every start. Back node_modules and static/vendor with named volumes so the bind-mounted source tree no longer shadows the install while state still survives container restarts. Drop the now-redundant npm-install target and its references in up/dev/prod/test-e2e. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
13
Makefile
13
Makefile
@@ -22,7 +22,7 @@ build-no-cache:
|
|||||||
docker build --no-cache -t application-portfolio .
|
docker build --no-cache -t application-portfolio .
|
||||||
|
|
||||||
.PHONY: up
|
.PHONY: up
|
||||||
up: npm-install
|
up:
|
||||||
# Start the application using docker-compose with build.
|
# Start the application using docker-compose with build.
|
||||||
docker-compose up -d --build --force-recreate
|
docker-compose up -d --build --force-recreate
|
||||||
|
|
||||||
@@ -58,12 +58,12 @@ logs:
|
|||||||
docker logs -f portfolio
|
docker logs -f portfolio
|
||||||
|
|
||||||
.PHONY: dev
|
.PHONY: dev
|
||||||
dev: npm-install
|
dev:
|
||||||
# Start the application in development mode using docker-compose.
|
# Start the application in development mode using docker-compose.
|
||||||
FLASK_ENV=development docker-compose up -d
|
FLASK_ENV=development docker-compose up -d
|
||||||
|
|
||||||
.PHONY: prod
|
.PHONY: prod
|
||||||
prod: npm-install
|
prod:
|
||||||
# Start the application in production mode using docker-compose (with build).
|
# Start the application in production mode using docker-compose (with build).
|
||||||
docker-compose up -d --build
|
docker-compose up -d --build
|
||||||
|
|
||||||
@@ -92,11 +92,6 @@ install-dev:
|
|||||||
# Install runtime and developer dependencies from pyproject.toml.
|
# Install runtime and developer dependencies from pyproject.toml.
|
||||||
$(PYTHON) -m pip install -e ".[dev]"
|
$(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
|
.PHONY: lint-actions
|
||||||
lint-actions:
|
lint-actions:
|
||||||
# Lint GitHub Actions workflows.
|
# Lint GitHub Actions workflows.
|
||||||
@@ -145,7 +140,7 @@ security: install-dev test-security
|
|||||||
$(PYTHON) -m pip_audit -r /tmp/portfolio-runtime-requirements.txt
|
$(PYTHON) -m pip_audit -r /tmp/portfolio-runtime-requirements.txt
|
||||||
|
|
||||||
.PHONY: test-e2e
|
.PHONY: test-e2e
|
||||||
test-e2e: npm-install
|
test-e2e:
|
||||||
# Run Cypress end-to-end tests via act (stop portfolio container to free port first).
|
# Run Cypress end-to-end tests via act (stop portfolio container to free port first).
|
||||||
-docker stop portfolio 2>/dev/null || true
|
-docker stop portfolio 2>/dev/null || true
|
||||||
$(ACT) workflow_dispatch -W .github/workflows/tests.yml -j e2e
|
$(ACT) workflow_dispatch -W .github/workflows/tests.yml -j e2e
|
||||||
|
|||||||
@@ -12,4 +12,13 @@ services:
|
|||||||
- .env
|
- .env
|
||||||
volumes:
|
volumes:
|
||||||
- ./app:/app
|
- ./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
|
restart: unless-stopped
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
node_modules:
|
||||||
|
vendor:
|
||||||
|
|||||||
Reference in New Issue
Block a user