chore: add node docker service for vite dev server and prod build
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -13,3 +13,5 @@
|
|||||||
/.phpunit.cache/
|
/.phpunit.cache/
|
||||||
###< phpunit/phpunit ###
|
###< phpunit/phpunit ###
|
||||||
/.idea/
|
/.idea/
|
||||||
|
/node_modules/
|
||||||
|
/public/build/
|
||||||
|
|||||||
9
Makefile
9
Makefile
@@ -55,6 +55,15 @@ symfony\:cache-clear: ## Vide le cache Symfony
|
|||||||
test: ## Lance les tests PHPUnit
|
test: ## Lance les tests PHPUnit
|
||||||
docker compose exec app php bin/phpunit
|
docker compose exec app php bin/phpunit
|
||||||
|
|
||||||
|
node\:shell: ## Ouvre un shell dans le conteneur node
|
||||||
|
docker compose exec node sh
|
||||||
|
|
||||||
|
node\:install: ## Installe les dépendances npm
|
||||||
|
docker compose exec node npm install
|
||||||
|
|
||||||
|
node\:build: ## Build les assets pour la production
|
||||||
|
docker compose exec node npm run build
|
||||||
|
|
||||||
help: ## Affiche cette aide
|
help: ## Affiche cette aide
|
||||||
@grep -E '^[a-zA-Z_\\:-]+:.*## ' $(MAKEFILE_LIST) \
|
@grep -E '^[a-zA-Z_\\:-]+:.*## ' $(MAKEFILE_LIST) \
|
||||||
| awk 'BEGIN {FS = "## "} {gsub(/\\:/, ":", $$1); sub(/:[^:]*$$/, "", $$1); printf "\033[36m%-25s\033[0m %s\n", $$1, $$2}'
|
| awk 'BEGIN {FS = "## "} {gsub(/\\:/, ":", $$1); sub(/:[^:]*$$/, "", $$1); printf "\033[36m%-25s\033[0m %s\n", $$1, $$2}'
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ services:
|
|||||||
target: dev
|
target: dev
|
||||||
environment:
|
environment:
|
||||||
APP_ENV: dev
|
APP_ENV: dev
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
- .:/app
|
- .:/app
|
||||||
- vendor:/app/vendor
|
- vendor:/app/vendor
|
||||||
@@ -17,6 +16,17 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- "0.0.0.0:5432:5432"
|
- "0.0.0.0:5432:5432"
|
||||||
|
|
||||||
|
node:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: docker/node/Dockerfile
|
||||||
|
target: dev
|
||||||
|
volumes:
|
||||||
|
- .:/app
|
||||||
|
- node_modules:/app/node_modules
|
||||||
|
ports:
|
||||||
|
- "5173:5173"
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
vendor:
|
vendor:
|
||||||
|
node_modules:
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ services:
|
|||||||
context: .
|
context: .
|
||||||
dockerfile: docker/app/Dockerfile
|
dockerfile: docker/app/Dockerfile
|
||||||
target: prod
|
target: prod
|
||||||
|
additional_contexts:
|
||||||
|
node-build: docker/node
|
||||||
image: git.lclr.dev/thibaud-lclr/ltbxd-actorle/app:latest
|
image: git.lclr.dev/thibaud-lclr/ltbxd-actorle/app:latest
|
||||||
ports:
|
ports:
|
||||||
- "80:80"
|
- "80:80"
|
||||||
|
|||||||
@@ -30,6 +30,21 @@ ENV APP_ENV=dev \
|
|||||||
POSTGRES_USER=app \
|
POSTGRES_USER=app \
|
||||||
POSTGRES_PASSWORD=pwd
|
POSTGRES_PASSWORD=pwd
|
||||||
|
|
||||||
|
###
|
||||||
|
# Node build stage (for prod assets)
|
||||||
|
###
|
||||||
|
FROM node:22-alpine AS node-build
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY package.json package-lock.json* ./
|
||||||
|
RUN npm install
|
||||||
|
|
||||||
|
COPY assets/ ./assets/
|
||||||
|
COPY vite.config.js ./
|
||||||
|
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
###
|
###
|
||||||
# Prod stage
|
# Prod stage
|
||||||
###
|
###
|
||||||
@@ -40,6 +55,9 @@ RUN composer install --no-dev --no-scripts --no-autoloader --prefer-dist
|
|||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
# Copy Vite-built assets
|
||||||
|
COPY --from=node-build /app/public/build /app/public/build
|
||||||
|
|
||||||
RUN APP_ENV=prod composer dump-autoload --classmap-authoritative \
|
RUN APP_ENV=prod composer dump-autoload --classmap-authoritative \
|
||||||
&& APP_ENV=prod composer run-script post-install-cmd \
|
&& APP_ENV=prod composer run-script post-install-cmd \
|
||||||
&& chown -R www-data:www-data var/
|
&& chown -R www-data:www-data var/
|
||||||
|
|||||||
24
docker/node/Dockerfile
Normal file
24
docker/node/Dockerfile
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
FROM node:22-alpine AS base
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
###
|
||||||
|
# Dev stage
|
||||||
|
###
|
||||||
|
FROM base AS dev
|
||||||
|
|
||||||
|
# Dependencies are mounted via volume, install at startup
|
||||||
|
CMD ["sh", "-c", "npm install && npx vite"]
|
||||||
|
|
||||||
|
###
|
||||||
|
# Build stage (used by app prod image)
|
||||||
|
###
|
||||||
|
FROM base AS build
|
||||||
|
|
||||||
|
COPY package.json package-lock.json* ./
|
||||||
|
RUN npm install
|
||||||
|
|
||||||
|
COPY assets/ ./assets/
|
||||||
|
COPY vite.config.js ./
|
||||||
|
|
||||||
|
RUN npm run build
|
||||||
Reference in New Issue
Block a user