Skip to content

Commit

Permalink
dev env polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
Wirewraith committed Dec 8, 2024
1 parent 41ad9df commit e0d8b57
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 45 deletions.
5 changes: 3 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml}]
[*.{yml,yaml,json}]
indent_size = 2

[docker-compose.yml]
Expand Down
6 changes: 5 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -58,3 +59,6 @@ VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

INCLUDE_FRONTEND=true

WWWGROUP=1000
WWWUSER=1000
42 changes: 42 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -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
}
]
}
16 changes: 16 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
51 changes: 13 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
6 changes: 3 additions & 3 deletions docker/8.3/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 \
Expand Down

0 comments on commit e0d8b57

Please sign in to comment.