From 09f2a93801fdca73708c4199b60ce2218f9c8826 Mon Sep 17 00:00:00 2001 From: Joel Clermont Date: Wed, 12 Jun 2024 08:35:22 -0500 Subject: [PATCH 01/12] ci: use volta npm when running tests --- .github/workflows/ci.yml | 4 ++-- README_TEMPLATE.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 04412ed..f6ae6f2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -65,8 +65,8 @@ jobs: - name: Install JS dependencies run: npm install && npm run build - - name: Cache routes - run: docker exec "$PROJECT_NAME-php-fpm" ./artisan route:cache + - name: Run JS test suite + run: LARAVEL_BYPASS_ENV_CHECK=1 npm test - name: Cache views run: docker exec "$PROJECT_NAME-php-fpm" ./artisan view:cache diff --git a/README_TEMPLATE.md b/README_TEMPLATE.md index 38ce672..d180ff2 100644 --- a/README_TEMPLATE.md +++ b/README_TEMPLATE.md @@ -97,7 +97,7 @@ And then open `auth.json` and fill out the username and password values. **Normal project setup** With the certificates, our environment, and Docker setup, the rest of these steps will be typical steps for any Laravel -project. The one key difference is that instead of running tools like npm, composer and artisan directly, we need to run +project. The one key difference is that instead of running tools like composer and artisan directly, we need to run them from inside the container. This is very important. If we run the tools from our host environment, all the guarantees about versions of tooling will no longer apply. From 3c4847a3e490d93b026a7bedcc2ea533afc034b9 Mon Sep 17 00:00:00 2001 From: Joel Clermont Date: Wed, 12 Jun 2024 08:35:44 -0500 Subject: [PATCH 02/12] ci: use composer caching script --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f6ae6f2..3611d91 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -68,8 +68,8 @@ jobs: - name: Run JS test suite run: LARAVEL_BYPASS_ENV_CHECK=1 npm test - - name: Cache views - run: docker exec "$PROJECT_NAME-php-fpm" ./artisan view:cache + - name: Laravel caching + run: docker exec "$PROJECT_NAME-php-fpm" composer run laravel-cache - name: Cache Larastan result cache uses: actions/cache@v3 From 64d9aaa75cfb6940a96bdbd42777b89a038b7e2f Mon Sep 17 00:00:00 2001 From: Joel Clermont Date: Wed, 12 Jun 2024 08:35:56 -0500 Subject: [PATCH 03/12] add missing composer version --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index 87124a8..0b6e3c2 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,6 @@ { "name": "nocompromises/my-project", + "version": "1.0.0", "type": "project", "license": "proprietary", "require": { From 0af6139b5102607360b09352a0205137bd5212bc Mon Sep 17 00:00:00 2001 From: Joel Clermont Date: Wed, 12 Jun 2024 08:45:36 -0500 Subject: [PATCH 04/12] remove obsolete docker compose version --- docker-compose.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index b355282..bbc933c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,8 +14,6 @@ ## - Make sure to enable the performance optimization for Macs, if you're running on macOS 12.2 or higher. ## From Docker Desktop, go to Settings, Experimental Features and enable both settings for virtualization and VirtioFS. ######################################################################################################################## -version: "3.9" - services: ## The App database From f93feff626f986108416967b83ee17324be7ecd5 Mon Sep 17 00:00:00 2001 From: Joel Clermont Date: Wed, 12 Jun 2024 10:23:13 -0500 Subject: [PATCH 05/12] mysql version bump, normalize env, simplify config as default --- docker-compose.yml | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index bbc933c..9c89d5e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -19,37 +19,43 @@ services: ## The App database mysql: container_name: "${COMPOSE_PROJECT_NAME}-mysql" - image: mysql:8.0.35 + image: mysql:8.0.37 volumes: - mysql-data:/var/lib/mysql + # Uncomment the next line if you need scripts to run on mysql initialization, like creating multiple databases + # - ./docker/mysql/init:/docker-entrypoint-initdb.d environment: - - MYSQL_ROOT_PASSWORD=password - - MYSQL_DATABASE=app # update .env and .env.example if you change any of these values - - MYSQL_USER=app - - MYSQL_PASSWORD=app + MYSQL_ROOT_PASSWORD: password + MYSQL_DATABASE: app # update .env and .env.example if you change any of these values + MYSQL_USER: app + MYSQL_PASSWORD: app ports: - "${DOCKER_MYSQL_LOCAL_PORT}:3306" - command: - - "--character-set-server=utf8mb4" - - "--collation-server=utf8mb4_unicode_ci" - - "--default-authentication-plugin=mysql_native_password" + # Uncomment the command section if you need to deviate from MySQL defaults (like on a legacy database schema) + # command: + # - "--character-set-server=utf8mb4" + # - "--collation-server=utf8mb4_0900_ai_ci" + # - "--default-authentication-plugin=caching_sha2_password" restart: unless-stopped ## MySQL just for Unit Tests mysql-test: container_name: "${COMPOSE_PROJECT_NAME}-mysql-test" - image: mysql:8.0.35 + image: mysql:8.0.37 volumes: - mysql-test-data:/var/lib/mysql + # Uncomment the next line if you need scripts to run on mysql initialization, like creating multiple databases + # - ./docker/mysql/init:/docker-entrypoint-initdb.d environment: - - MYSQL_ROOT_PASSWORD=password - - MYSQL_DATABASE=apptest # update phpunit.xml if you change any of these values - - MYSQL_USER=app - - MYSQL_PASSWORD=app - command: - - "--character-set-server=utf8mb4" - - "--collation-server=utf8mb4_unicode_ci" - - "--default-authentication-plugin=mysql_native_password" + MYSQL_ROOT_PASSWORD: password + MYSQL_DATABASE: apptest # update phpunit.xml if you change any of these values + MYSQL_USER: app + MYSQL_PASSWORD: app + # Uncomment the command section if you need to deviate from MySQL defaults (like on a legacy database schema) + # command: + # - "--character-set-server=utf8mb4" + # - "--collation-server=utf8mb4_0900_ai_ci" + # - "--default-authentication-plugin=caching_sha2_password" restart: unless-stopped redis: From 2fb7bf93493602340a13592c1f09311dadc9cf0a Mon Sep 17 00:00:00 2001 From: Joel Clermont Date: Wed, 12 Jun 2024 10:23:24 -0500 Subject: [PATCH 06/12] redis version bump --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 9c89d5e..534eddd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -60,7 +60,7 @@ services: redis: container_name: "${COMPOSE_PROJECT_NAME}-redis" - image: redis:7.0.5-alpine3.17 + image: redis:7.2.5-alpine3.20 ports: - "${DOCKER_REDIS_LOCAL_PORT}:6379" restart: unless-stopped From 655c57b365f49b34381dcf7dc86d637fa18c40f0 Mon Sep 17 00:00:00 2001 From: Joel Clermont Date: Wed, 12 Jun 2024 10:31:24 -0500 Subject: [PATCH 07/12] update domains for orbstack .local --- .env.example | 4 ++-- README_TEMPLATE.md | 12 ++++++------ docker-compose.yml | 2 ++ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.env.example b/.env.example index 24c20d2..87bfc8b 100644 --- a/.env.example +++ b/.env.example @@ -2,13 +2,13 @@ APP_NAME=Laravel APP_ENV=local APP_KEY= APP_DEBUG=true -APP_URL=https://my-project.test:30080 +APP_URL=https://my-project.local:30080 COMPOSE_PROJECT_NAME=my-project DOCKER_MYSQL_LOCAL_PORT=33306 DOCKER_NGINX_LOCAL_PORT=30080 DOCKER_REDIS_LOCAL_PORT=36379 -DOCKER_SERVER_NAME=my-project.test +DOCKER_SERVER_NAME=my-project.local SENTRY_LARAVEL_DSN= SENTRY_TRACES_SAMPLE_RATE=1.0 diff --git a/README_TEMPLATE.md b/README_TEMPLATE.md index d180ff2..19bdf1d 100644 --- a/README_TEMPLATE.md +++ b/README_TEMPLATE.md @@ -24,17 +24,17 @@ To get started with local development, follow these steps. Make sure you run all ### DNS resolution -> Decide on a local domain to use for this project. Substitute that any place you see `my-project.test` or `my-project` below. +> Decide on a local domain to use for this project. Substitute that any place you see `my-project.local` or `my-project` below. -By default, this project will run on the host `my-project.test`. This requires some sort of local DNS resolution for that hostname -to your localhost IP address. One easy way to do this for the entire `.test` top-level domain, is to run a lightweight tool +By default, this project will run on the host `my-project.local`. This requires some sort of local DNS resolution for that hostname +to your localhost IP address. One easy way to do this for the entire `.local` top-level domain, is to run a lightweight tool called `dnsmasq`. You can install it via Homebrew on a Mac with: `brew install dnsmasq`. > If you've ever setup Valet, it already installed dnsmasq for you. You can verify if it's already installed by running > `brew services` and see if `dnsmasq` is listed. If you don't want to run `dnsmasq`, you can also add a manual DNS entry to your `/etc/hosts` file in the form: -`127.0.0.1 my-project.test` +`127.0.0.1 my-project.local` ### Setting up an SSL certificate @@ -56,7 +56,7 @@ Once `mkcert` is installed, we need to generate our local development root certi Then, generate the certificates for this project and put them into a location accessible to your docker setup: -`mkcert -cert-file docker/nginx/ssl.pem -key-file docker/nginx/key.pem my-project.test` +`mkcert -cert-file docker/nginx/ssl.pem -key-file docker/nginx/key.pem my-project.local` ### Node environment The best option to ensure you're using the correct versions of Node and npm with this project is to install [Volta](https://volta.sh). Volta will read the pinned versions of Node and npm from the `package.json` so you can be sure you're using the correct versions. @@ -112,7 +112,7 @@ Run these commands to finish the local development setup * `docker/bin/artisan horizon:install` * `docker/bin/artisan migrate --seed` -You're good to go - surf to https://my-project.test:30080 (or a different host/port if you've configured it) +You're good to go - surf to https://my-project.local:30080 (or a different host/port if you've configured it) You can also use any normal database management tools and connect to the database using the port specified in `.env`. diff --git a/docker-compose.yml b/docker-compose.yml index 534eddd..68bfc62 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -75,6 +75,8 @@ services: working_dir: /app volumes: - .:/app + labels: + - "dev.orbstack.domains=${DOCKER_SERVER_NAME}" ports: - "${DOCKER_NGINX_LOCAL_PORT}:443" depends_on: From 4347c6cbb5224c4567b37f2b06811e99a640aa80 Mon Sep 17 00:00:00 2001 From: Joel Clermont Date: Wed, 12 Jun 2024 11:02:07 -0500 Subject: [PATCH 08/12] more orbstack updates --- .env.example | 19 ++++++++----------- README.md | 2 +- README_TEMPLATE.md | 22 +++++++++++++--------- docker-compose.yml | 6 ------ 4 files changed, 22 insertions(+), 27 deletions(-) diff --git a/.env.example b/.env.example index 87bfc8b..b97f9e5 100644 --- a/.env.example +++ b/.env.example @@ -1,18 +1,11 @@ +COMPOSE_PROJECT_NAME=my-project +DOCKER_SERVER_NAME=my-project.local + APP_NAME=Laravel APP_ENV=local APP_KEY= APP_DEBUG=true -APP_URL=https://my-project.local:30080 - -COMPOSE_PROJECT_NAME=my-project -DOCKER_MYSQL_LOCAL_PORT=33306 -DOCKER_NGINX_LOCAL_PORT=30080 -DOCKER_REDIS_LOCAL_PORT=36379 -DOCKER_SERVER_NAME=my-project.local - -SENTRY_LARAVEL_DSN= -SENTRY_TRACES_SAMPLE_RATE=1.0 -SENTRY_SEND_DEFAULT_PII=true +APP_URL=https://my-project.local LOG_CHANNEL=stack LOG_DEPRECATIONS_CHANNEL=null @@ -66,3 +59,7 @@ VITE_PUSHER_HOST="${PUSHER_HOST}" VITE_PUSHER_PORT="${PUSHER_PORT}" VITE_PUSHER_SCHEME="${PUSHER_SCHEME}" VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" + +SENTRY_LARAVEL_DSN= +SENTRY_TRACES_SAMPLE_RATE=1.0 +SENTRY_SEND_DEFAULT_PII=true diff --git a/README.md b/README.md index f364007..cd712ad 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ You can also remove: Modifications are needed to the following files already in a default Laravel install: * `.env.example` and `.env` - * copy from `APP_URL`, `COMPOSER_PROJECT_NAME`, `DOCKER_MYSQL_LOCAL_PORT`, `DOCKER_NGINX_LOCAL_PORT`, and `DOCKER_SERVER_NAME` + * copy from `APP_URL`, `COMPOSE_PROJECT_NAME`, and `DOCKER_SERVER_NAME` * copy `DB_HOST`, `DB_DATABASE`, `DB_USERNAME`, and `DB_PASSWORD` Update your Composer packages and scripts: diff --git a/README_TEMPLATE.md b/README_TEMPLATE.md index 19bdf1d..e79786e 100644 --- a/README_TEMPLATE.md +++ b/README_TEMPLATE.md @@ -26,9 +26,12 @@ To get started with local development, follow these steps. Make sure you run all > Decide on a local domain to use for this project. Substitute that any place you see `my-project.local` or `my-project` below. -By default, this project will run on the host `my-project.local`. This requires some sort of local DNS resolution for that hostname -to your localhost IP address. One easy way to do this for the entire `.local` top-level domain, is to run a lightweight tool -called `dnsmasq`. You can install it via Homebrew on a Mac with: `brew install dnsmasq`. +By default, this project will run on the host `my-project.local`. +OrbStack (see below) is already configured to serve on this top-level domain. + +If you're not using OrbStack, you will need some sort of local DNS resolution for that hostname to your localhost IP address. +One easy way to do this for the entire `.local` top-level domain, is to run a lightweight tool called `dnsmasq`. +You can install it via Homebrew on a Mac with: `brew install dnsmasq`. > If you've ever setup Valet, it already installed dnsmasq for you. You can verify if it's already installed by running > `brew services` and see if `dnsmasq` is listed. @@ -59,19 +62,20 @@ Then, generate the certificates for this project and put them into a location ac `mkcert -cert-file docker/nginx/ssl.pem -key-file docker/nginx/key.pem my-project.local` ### Node environment -The best option to ensure you're using the correct versions of Node and npm with this project is to install [Volta](https://volta.sh). Volta will read the pinned versions of Node and npm from the `package.json` so you can be sure you're using the correct versions. +The best option to ensure you're using the correct versions of Node and npm with this project is to install [Volta](https://volta.sh). +Volta will read the pinned versions of Node and npm from the `package.json` so you can be sure you're using the correct versions. ### Get the project running in Docker Docker is used for local development. It's self-contained, easy to set up, and matches the exact versions of key services -running in production. It requires that you have [Docker Desktop](https://www.docker.com/products/docker-desktop/) installed. +running in production. We use [OrbStack](https://orbstack.dev) as our Docker engine, since it handles domain resolution and port mapping. +This config also works with [Docker Desktop](https://www.docker.com/products/docker-desktop/), but you may need to add explicit port mappings. **Setup the environment** -Make a copy of the example env file: `cp .env.example .env` +Open the `.env.example` file and update the `COMPOSE_PROJECT_NAME` and `DOCKER_SERVER_NAME` settings to match your project. -Open the `.env` file and review the settings prefixed with `DOCKER_`. The defaults should work, but if you want a different -host name, or to change the port numbers, make those modifications before continuing with the Docker setup. +Make a copy of the example env file: `cp .env.example .env` **Get Docker running** @@ -112,7 +116,7 @@ Run these commands to finish the local development setup * `docker/bin/artisan horizon:install` * `docker/bin/artisan migrate --seed` -You're good to go - surf to https://my-project.local:30080 (or a different host/port if you've configured it) +You're good to go - surf to https://my-project.local You can also use any normal database management tools and connect to the database using the port specified in `.env`. diff --git a/docker-compose.yml b/docker-compose.yml index 68bfc62..b2eb426 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -29,8 +29,6 @@ services: MYSQL_DATABASE: app # update .env and .env.example if you change any of these values MYSQL_USER: app MYSQL_PASSWORD: app - ports: - - "${DOCKER_MYSQL_LOCAL_PORT}:3306" # Uncomment the command section if you need to deviate from MySQL defaults (like on a legacy database schema) # command: # - "--character-set-server=utf8mb4" @@ -61,8 +59,6 @@ services: redis: container_name: "${COMPOSE_PROJECT_NAME}-redis" image: redis:7.2.5-alpine3.20 - ports: - - "${DOCKER_REDIS_LOCAL_PORT}:6379" restart: unless-stopped ## NGINX to support the app, configured to use the php-fpm-debug server @@ -77,8 +73,6 @@ services: - .:/app labels: - "dev.orbstack.domains=${DOCKER_SERVER_NAME}" - ports: - - "${DOCKER_NGINX_LOCAL_PORT}:443" depends_on: - php-fpm-debug restart: unless-stopped From 298ab66ffe13434c4cc6cf04f9314b0b47e41220 Mon Sep 17 00:00:00 2001 From: Joel Clermont Date: Wed, 12 Jun 2024 15:54:29 -0500 Subject: [PATCH 09/12] more orbstack tweaks and php, nginx version bumps --- docker/nginx/Dockerfile | 4 +--- docker/nginx/nginx.conf | 19 +++++++++++++------ docker/php-fpm/Dockerfile | 6 +++--- docker/php-fpm/docker-php-ext-xdebug.ini | 2 +- docker/vite/.gitignore | 1 + vite.config.js | 6 ++---- 6 files changed, 21 insertions(+), 17 deletions(-) create mode 100644 docker/vite/.gitignore diff --git a/docker/nginx/Dockerfile b/docker/nginx/Dockerfile index 86dedad..37fdce5 100644 --- a/docker/nginx/Dockerfile +++ b/docker/nginx/Dockerfile @@ -1,5 +1,3 @@ -FROM nginx:1.22.0-alpine +FROM nginx:1.27.0-alpine3.19 COPY nginx.conf /etc/nginx/conf.d/default.conf -COPY ssl.pem /etc/nginx/ssl.pem -COPY key.pem /etc/nginx/key.pem diff --git a/docker/nginx/nginx.conf b/docker/nginx/nginx.conf index 3dd45d5..5069a1c 100644 --- a/docker/nginx/nginx.conf +++ b/docker/nginx/nginx.conf @@ -1,19 +1,26 @@ server { - listen 443 ssl; - ssl_certificate /etc/nginx/ssl.pem; - ssl_certificate_key /etc/nginx/key.pem; + listen 80; root /app/public; + add_header X-Frame-Options "SAMEORIGIN"; + add_header X-Content-Type-Options "nosniff"; index index.php; - if (!-e $request_filename) { - rewrite ^.*$ /index.php last; + charset utf-8; + location / { + try_files $uri $uri/ /index.php?$query_string; } + location = /favicon.ico { access_log off; log_not_found off; } + location = /robots.txt { access_log off; log_not_found off; } + error_page 404 /index.php; location ~ \.php$ { fastcgi_pass php-fpm-debug:9000; fastcgi_index index.php; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; include fastcgi_params; fastcgi_read_timeout 300; } + location ~ /\.(?!well-known).* { + deny all; + } } diff --git a/docker/php-fpm/Dockerfile b/docker/php-fpm/Dockerfile index 139bdfe..7101069 100644 --- a/docker/php-fpm/Dockerfile +++ b/docker/php-fpm/Dockerfile @@ -1,4 +1,4 @@ -FROM php:8.2.12-fpm-alpine3.18 as base +FROM php:8.3.8-fpm-alpine3.20 as base RUN apk add --no-cache $PHPIZE_DEPS \ freetype-dev \ @@ -17,7 +17,7 @@ RUN docker-php-ext-configure gd --with-freetype --with-jpeg \ RUN pecl install redis-6.0.2 && docker-php-ext-enable redis # install composer from the composer image -COPY --from=composer:2.6.5 /usr/bin/composer /usr/bin/composer +COPY --from=composer:2.7.7 /usr/bin/composer /usr/bin/composer COPY docker-php-file-uploads.ini /usr/local/etc/php/conf.d/docker-php-file-uploads.ini @@ -25,5 +25,5 @@ FROM base as debug # Supports xdebug RUN apk add --update linux-headers -RUN pecl install xdebug-3.2.2 && docker-php-ext-enable xdebug +RUN pecl install xdebug-3.3.2 && docker-php-ext-enable xdebug COPY docker-php-ext-xdebug.ini /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini diff --git a/docker/php-fpm/docker-php-ext-xdebug.ini b/docker/php-fpm/docker-php-ext-xdebug.ini index 69b8397..63e4b0f 100644 --- a/docker/php-fpm/docker-php-ext-xdebug.ini +++ b/docker/php-fpm/docker-php-ext-xdebug.ini @@ -1,5 +1,5 @@ zend_extension=xdebug -xdebug.mode=debug +xdebug.mode=debug,develop xdebug.idekey=PHPSTORM xdebug.client_host=docker.for.mac.localhost memory_limit=512M diff --git a/docker/vite/.gitignore b/docker/vite/.gitignore new file mode 100644 index 0000000..cfaad76 --- /dev/null +++ b/docker/vite/.gitignore @@ -0,0 +1 @@ +*.pem diff --git a/vite.config.js b/vite.config.js index 463a7fb..8b80956 100644 --- a/vite.config.js +++ b/vite.config.js @@ -26,12 +26,10 @@ export default defineConfig(({ mode }) => { if (mode === "development") { config.server = { - port: 30098, - strictPort: true, host: true, https: { - key: readFileSync("docker/nginx/key.pem"), - cert: readFileSync("docker/nginx/ssl.pem"), + key: readFileSync("docker/vite/key.pem"), + cert: readFileSync("docker/vite/ssl.pem"), }, hmr: { host: "project.domain", From f28639b8071e41ceebb58d65d8c962fd0fc1308f Mon Sep 17 00:00:00 2001 From: Joel Clermont Date: Wed, 12 Jun 2024 15:59:54 -0500 Subject: [PATCH 10/12] allow js tests to pass nothing defined, action bumps for node 20 --- .github/workflows/ci.yml | 12 ++++++------ package.json | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3611d91..880e754 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,10 +17,10 @@ jobs: run: cp .env.example .env - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Build Docker images - uses: docker/bake-action@v3 + uses: docker/bake-action@v4 with: load: true files: | @@ -36,7 +36,7 @@ jobs: run: docker compose up -d mysql mysql-test php-fpm --wait --no-build - name: Cache composer dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: vendor key: composer-${{ hashFiles('composer.lock') }} @@ -54,7 +54,7 @@ jobs: docker inspect "$PROJECT_NAME-mysql" - name: Cache npm dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: node_modules key: npm-${{ hashFiles('package-lock.json') }} @@ -72,7 +72,7 @@ jobs: run: docker exec "$PROJECT_NAME-php-fpm" composer run laravel-cache - name: Cache Larastan result cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: .phpstan.cache key: "phpstan-result-cache-${{ github.run_id }}" # always unique key - always writes a new cache @@ -80,7 +80,7 @@ jobs: phpstan-result-cache- - name: Cache php-cs-fixer result cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: .php-cs-fixer.cache key: "php-cs-fixer-result-cache-${{ github.run_id }}" # always unique key - always writes a new cache diff --git a/package.json b/package.json index e479854..4a64e50 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,8 @@ "dev": "vite", "build": "vite build", "lint": "eslint ./resources/js", - "test": "vitest", - "test-with-coverage": "vitest run --coverage" + "test": "vitest --passWithNoTests", + "test-with-coverage": "vitest run --coverage --passWithNoTests" }, "devDependencies": { "@vitejs/plugin-vue": "^4.5.2", From cd6042a35e67ddb96862b71e348199470aa24429 Mon Sep 17 00:00:00 2001 From: Joel Clermont Date: Wed, 12 Jun 2024 16:09:56 -0500 Subject: [PATCH 11/12] tweak caching in ci --- .github/workflows/ci.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 880e754..1a7eabe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -68,8 +68,11 @@ jobs: - name: Run JS test suite run: LARAVEL_BYPASS_ENV_CHECK=1 npm test - - name: Laravel caching - run: docker exec "$PROJECT_NAME-php-fpm" composer run laravel-cache + - name: Cache routes + run: docker exec "$PROJECT_NAME-php-fpm" ./artisan route:cache + + - name: Cache views + run: docker exec "$PROJECT_NAME-php-fpm" ./artisan view:cache - name: Cache Larastan result cache uses: actions/cache@v4 From 955c7565e09d0ee889251191e38b965b5427e1d2 Mon Sep 17 00:00:00 2001 From: Joel Clermont Date: Wed, 12 Jun 2024 16:25:16 -0500 Subject: [PATCH 12/12] pr fixes --- README_TEMPLATE.md | 2 +- docker-compose.yml | 6 ++---- vite.config.js | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/README_TEMPLATE.md b/README_TEMPLATE.md index e79786e..36bc587 100644 --- a/README_TEMPLATE.md +++ b/README_TEMPLATE.md @@ -59,7 +59,7 @@ Once `mkcert` is installed, we need to generate our local development root certi Then, generate the certificates for this project and put them into a location accessible to your docker setup: -`mkcert -cert-file docker/nginx/ssl.pem -key-file docker/nginx/key.pem my-project.local` +`mkcert -cert-file docker/vite/ssl.pem -key-file docker/vite/key.pem my-project.test` ### Node environment The best option to ensure you're using the correct versions of Node and npm with this project is to install [Volta](https://volta.sh). diff --git a/docker-compose.yml b/docker-compose.yml index b2eb426..b1599d3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -22,8 +22,7 @@ services: image: mysql:8.0.37 volumes: - mysql-data:/var/lib/mysql - # Uncomment the next line if you need scripts to run on mysql initialization, like creating multiple databases - # - ./docker/mysql/init:/docker-entrypoint-initdb.d + - ./docker/mysql/init:/docker-entrypoint-initdb.d environment: MYSQL_ROOT_PASSWORD: password MYSQL_DATABASE: app # update .env and .env.example if you change any of these values @@ -42,8 +41,7 @@ services: image: mysql:8.0.37 volumes: - mysql-test-data:/var/lib/mysql - # Uncomment the next line if you need scripts to run on mysql initialization, like creating multiple databases - # - ./docker/mysql/init:/docker-entrypoint-initdb.d + - ./docker/mysql/init:/docker-entrypoint-initdb.d environment: MYSQL_ROOT_PASSWORD: password MYSQL_DATABASE: apptest # update phpunit.xml if you change any of these values diff --git a/vite.config.js b/vite.config.js index 8b80956..ed780b4 100644 --- a/vite.config.js +++ b/vite.config.js @@ -32,7 +32,7 @@ export default defineConfig(({ mode }) => { cert: readFileSync("docker/vite/ssl.pem"), }, hmr: { - host: "project.domain", + host: "my-project.test", }, }; }