Skip to content

Full Windows Dev Env

waffle-lord edited this page Nov 26, 2024 · 1 revision

Install WSL2

Open PowerShell and run the following command to install Ubuntu WSL2:

wsl --install -d Ubuntu

Full documentation for installing WSL2 can be found here:
https://learn.microsoft.com/en-us/windows/wsl/basic-commands#install

Install Docker

Download and install Docker Desktop:
https://www.docker.com/products/docker-desktop/

Open Docker Desktop and browse to Settings, Resources, WSL Integration. Ensure that the enable integration with my default WSL distro is enabled.

Note

Previous to installing Docker, if you had a WSL2 shell open, you will need to restart it to be able to interact with Docker from WSL2.

Note

If you are running hyper-v you may want to check that your dynamic port ranges are set higher than the default. This is because hyper-v will reserve ports when the system boots, and it may include the ports needed by our containers. More details about the solution below can be found here

# check dynamic port ranges for ipv4 and 6
netsh int ipv4 show dynamicport tcp
netsh int ipv4 show dynamicport tcp

# update ranges to reserve 16384 port numbers starting at 49152
netsh int ipv4 set dynamic tcp start=49152 num=16384
netsh int ipv6 set dynamic tcp start=49152 num=16384

Install Git & Git LFS

Within your Ubuntu WSL2 environment:

sudo apt-get update
sudo apt-get -y install git git-lfs

Clone Forge

Pull down a clone of the Forge source locally within your WSL2 environment:

Warning

Using a windows drive mount such as /mnt/c/ will greatly reduce performance and may even prevent the project from running correctly. Please make sure to clone the repo to a location inside the wsl environment, such as ~/Code/forge

mkdir ~/Code
cd ~/Code
git clone https://github.com/sp-tarkov/forge.git forge
cd ~/Code/forge
git checkout develop
git lfs pull

Install Laravel Sail

Within your Ubuntu WSL2 environment:

# Copy the example full environment file over into the active environment file:  
cp .env.full .env

# Pull down a docker container that will install the project's composer dependencies:  
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

You should now have the sail script installed.

For simplicity, anything below that refers to running a sail command is actually referring to the script located here: ./vendor/bin/sail. For example, sail up -d actually refers to running ./vendor/bin/sail up -d. It's highly recommended to configure an alias to make running sail commands easier:

echo "alias sail='sh \$([ -f sail ] && echo sail || echo vendor/bin/sail)'" >> ~/.bashrc
source ~/.bashrc

Run Forge

Within your Ubuntu WSL2 environment:

Install Laravel Octane

# Start the containers in detached mode:
sail up -d

# Install NPM dependencies (includes file watcher for Octane)
sail npm install

# Install composer dependencies
sail composer install

# Generate a new application key:
sail artisan key:generate

# Test that octane workers can be reloaded
sail artisan octane:reload

# If you get an error reloading the workers, start octane to install FrankenPHP. If prompted, select 'yes' to install.
# sail artisan octane:start

# Restart containers
sail down
sail up -d

Create & Populate Database Tables

Run the following command to create each of the database tables and seed them with fake testing data.

sail artisan migrate:fresh --seed

Populate Meilisearch Indexes

In order to populate the Meilisearch search indexes you must have a queue worker running. We use Horizon for this.

Tip

You will need to open another console to run horizon, as it will block that console from running any more commands

# Start the queue workers (run this command in a new console):
sail artisan horizon

Vite Development Server

There is a front-end development server that manages hot-injecting files as they're updated so that you rarely have to refresh the page after a file is updated to see your changes. Start it with the following command:

sail npm run dev

Finished!

You should now be able to access the Forge:
http://localhost

<3