From 61722d57cc72ba10ef9e373f000751570b40fc2d Mon Sep 17 00:00:00 2001 From: Philipp Scheit Date: Fri, 8 Mar 2024 14:24:35 +0100 Subject: [PATCH 1/2] add node/npm to seperate docker file --- README.md | 7 ++++--- docker-compose.node.yaml | 7 +++++++ docker-compose.yaml | 7 +------ 3 files changed, 12 insertions(+), 9 deletions(-) create mode 100644 docker-compose.node.yaml diff --git a/README.md b/README.md index 88632a0bf..87a91b06c 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ These steps are provided for development purposes only. ### Requirements - **PHP** for the web app -- **NPM** for the frontend build +- **NPM** (or Docker) for the frontend build - **[Symfony CLI](https://symfony.com/download)** to run the web server - **MySQL** (or Docker) for the main data store - **Redis** (or Docker) for some functionality (favorites, download statistics) @@ -39,8 +39,9 @@ These steps are provided for development purposes only. ``` 4. Start MySQL & Redis: ```bash - docker-compose up -d # or somehow run MySQL & Redis on localhost without docker + docker compose up -d # or somehow run MySQL & Redis on localhost without Docker ``` + This mounts the current working directory into the node container and runs npm install and npm run build automatically. 5. Create 2 databases: - `packagist` - for the web app - `packagist_test` - for running the tests @@ -53,7 +54,7 @@ These steps are provided for development purposes only. bin/console doctrine:schema:create ``` 7. Run a CRON job `bin/console packagist:run-workers` to make sure packages update. -8. Run `npm run build` or `npm run dev` to build (or build&watch) css/js files. +8. Run `npm run build` or `npm run dev` to build (or build&watch) css/js files. When using Docker run `docker-compose run node npm run dev` to watch css/js files. You should now be able to access the site, create a user, etc. diff --git a/docker-compose.node.yaml b/docker-compose.node.yaml new file mode 100644 index 000000000..d90d7d7a2 --- /dev/null +++ b/docker-compose.node.yaml @@ -0,0 +1,7 @@ +services: + node: + image: 'node:20-alpine' + command: ['sh', '-c', 'npm install && npm run build'] + working_dir: '/app' + volumes: + - .:/app diff --git a/docker-compose.yaml b/docker-compose.yaml index 619a8c2b7..f167911a8 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,5 +1,3 @@ -version: '3' - services: database: image: mysql:8.0 @@ -9,12 +7,9 @@ services: MYSQL_ALLOW_EMPTY_PASSWORD: 1 MYSQL_DATABASE: packagist volumes: - - data:/var/lib/mysql + - /var/lib/mysql redis: image: redis:6.2-alpine ports: - 6379:6379 - -volumes: - data: From 7d0689ccca55a2d592e421a48601851144201533 Mon Sep 17 00:00:00 2001 From: Philipp Scheit Date: Tue, 12 Mar 2024 10:36:11 +0100 Subject: [PATCH 2/2] docker compose instead of docker-compose Co-authored-by: Jordi Boggiano --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 87a91b06c..95cf24ffa 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ These steps are provided for development purposes only. bin/console doctrine:schema:create ``` 7. Run a CRON job `bin/console packagist:run-workers` to make sure packages update. -8. Run `npm run build` or `npm run dev` to build (or build&watch) css/js files. When using Docker run `docker-compose run node npm run dev` to watch css/js files. +8. Run `npm run build` or `npm run dev` to build (or build&watch) css/js files. When using Docker run `docker compose run node npm run dev` to watch css/js files. You should now be able to access the site, create a user, etc.