diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 4d10a2f..61d161c 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -22,14 +22,15 @@ "esbenp.prettier-vscode", "georgykurian.laravel-ide-helper", "open-southeners.laravel-pint", - "eamodio.gitlens" + "eamodio.gitlens", + "oven.bun-vscode" ], "settings": {} } }, "remoteUser": "sail", "initializeCommand": "sh .devcontainer/init.sh", - "postCreateCommand": "chown -R 1000:1000 /var/www/html 2>/dev/null || true && composer install" + "postCreateCommand": "chown -R 1000:1000 /var/www/html 2>/dev/null || true && composer install && bun install" // "forwardPorts": [], // "runServices": [], // "shutdownAction": "none", diff --git a/.editorconfig b/.editorconfig index 5c25b55..d17b931 100644 --- a/.editorconfig +++ b/.editorconfig @@ -11,7 +11,7 @@ trim_trailing_whitespace = true [*.md] trim_trailing_whitespace = false -[*.{yml,yaml}] +[*.{yml,yaml,json}] indent_size = 2 [docker-compose.yml] diff --git a/.env.example b/.env.example index 81fd3da..2aaa4ad 100644 --- a/.env.example +++ b/.env.example @@ -3,6 +3,7 @@ APP_ENV=local APP_KEY= APP_DEBUG=true APP_URL=http://localhost +API_URL=http://api.localhost LOG_CHANNEL=stack LOG_DEPRECATIONS_CHANNEL=null @@ -16,7 +17,7 @@ DB_USERNAME=sail DB_PASSWORD=password BROADCAST_DRIVER=log -CACHE_DRIVER=memcached +CACHE_DRIVER=redis FILESYSTEM_DISK=local QUEUE_CONNECTION=database SESSION_DRIVER=database @@ -58,3 +59,6 @@ VITE_PUSHER_SCHEME="${PUSHER_SCHEME}" VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" INCLUDE_FRONTEND=true + +WWWGROUP=1000 +WWWUSER=1000 diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..b7d9a68 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,42 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "type": "bun", + "internalConsoleOptions": "openOnSessionStart", + "request": "launch", + "name": "Serve Frontend", + "program": "dev", + "cwd": "${workspaceFolder}", + "stopOnEntry": false + }, + { + "type": "bun", + "internalConsoleOptions": "neverOpen", + "request": "launch", + "name": "Debug File", + "program": "${file}", + "cwd": "${workspaceFolder}", + "stopOnEntry": false, + "watchMode": false + }, + { + "type": "bun", + "internalConsoleOptions": "neverOpen", + "request": "launch", + "name": "Run File", + "program": "${file}", + "cwd": "${workspaceFolder}", + "noDebug": true, + "watchMode": false + }, + { + "type": "bun", + "internalConsoleOptions": "neverOpen", + "request": "attach", + "name": "Attach Bun", + "url": "ws://localhost:6499/", + "stopOnEntry": false + } + ] +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..8c9684b --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,16 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "type": "shell", + "command": "bun run build", + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": ["$vite"], + "label": "Build Frontend", + "detail": "vite build" + } + ] +} diff --git a/README.md b/README.md index 6730c43..3e2ab82 100644 --- a/README.md +++ b/README.md @@ -2,63 +2,38 @@ ## Development -Uses docker via Laravel Sail. https://laravel.com/docs/11.x/installation#laravel-and-docker +Uses Docker via Laravel Sail. https://laravel.com/docs/11.x/installation#laravel-and-docker On Windows, I highly suggest doing all development on WSL 2, using VSCode with the remote development extension. -Automatically generated docs will be available at `http://localhost/docs/api`, and the Laravel development assistance thing will be at `http://localhost/telescope`. +Also install the VSCode devcontainers extension for the easiest possible development environment setup. -### Initial setup - -- Navigate to your project root -- Create a shared docker network: +Automatically generated docs will be available at http://localhost/docs/api, and the Laravel development assistance thing will be at http://localhost/telescope. -```bash -docker network create sail -``` +### Environment -- Install dependencies: +Docker should be installed on your host machine. On Windows, install "Docker Desktop". -```bash -docker run --rm \ - -u "$(id -u):$(id -g)" \ - -v "$(pwd):/var/www/html" \ - -w /var/www/html \ - laravelsail/php83-composer:latest \ - composer install --ignore-platform-reqs -``` +### Initial setup -- Prepare your environment: +- Open the project root in VSCode. +- When prompted, reopen the project in a devcontainer. -```bash -echo -e "\nalias sail='sh $([ -f sail ] && echo sail || echo vendor/bin/sail)'" >> ~/.bashrc -source ~/.bashrc -``` - -- Bootstrap your application: - This might take a while as it builds the docker containers. -```bash -sail up -d -sail artisan initial-setup -``` - -The above will initialize the database, guide you through creating a user, and then guide you through creating an API token. - -- Start the frontend +- Open a VSCode terminal and initiate the first setup command to bootstrap the database: ```bash -sail npm i -sail npm run dev +php artisan initial-setup ``` -The above will install the frontend packages and start the dev server, allowing you to access the web UI at `http://localhost`. +### Tasks + +To build the frontend in development mode, press F5 to run the "Serve Frontend" debug task. This boots the Vite server and opens the debug console. Given the default `.env` file, you can now visit http://localhost. ### Limitations There are some external services that the API relies on that are not yet public/integrated. As such, the following features are unavailable during development: -- Any communication with game servers - Map switches - VPN checking (unless you configure with your own IPQualityScore credentials) diff --git a/docker/8.3/Dockerfile b/docker/8.3/Dockerfile index ae44ac6..596a5e3 100644 --- a/docker/8.3/Dockerfile +++ b/docker/8.3/Dockerfile @@ -3,7 +3,7 @@ FROM ubuntu:22.04 LABEL maintainer="Taylor Otwell" ARG WWWGROUP -ARG NODE_VERSION=20 +ARG NODE_VERSION=23 ARG POSTGRES_VERSION=16 WORKDIR /var/www/html @@ -35,8 +35,8 @@ RUN apt-get update \ php8.3-msgpack php8.3-igbinary php8.3-redis php8.3-swoole \ php8.3-memcached php8.3-pcov php8.3-imagick php8.3-xdebug \ && curl -sLS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer \ - && curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \ - && echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_VERSION.x nodistro main" > /etc/apt/sources.list.d/nodesource.list \ + && curl -fsSL "https://deb.nodesource.com/setup_$NODE_VERSION.x" -o nodesource_setup.sh \ + && bash nodesource_setup.sh \ && apt-get update \ && apt-get install -y nodejs \ && npm install -g npm \