Skip to content

Commit

Permalink
Dx 469/test devenv (#1162)
Browse files Browse the repository at this point in the history
* Add link, seperate services and fix grammar

* WIP tabs

* Adminer path changed

* Add port info and redis error

* Add correct caddy url

* Update tabs since links are not possible

* Change port config
  • Loading branch information
Isengo1989 authored Nov 9, 2023
1 parent 6b06502 commit dec286b
Showing 1 changed file with 98 additions and 32 deletions.
130 changes: 98 additions & 32 deletions guides/installation/devenv.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ You probably won't be able to use the commands below. Use the following steps to
```

* Copy these lines and delete them from this file.
* Open `~/.zshrc` and add the above copied lines to the end of this file.
* Open `~/.zshrc` and add the above-copied lines to the end of this file.
* Initiate the terminal with `source ~/.zshrc` or reboot your terminal for nix to work.

[Credits: "nixos installation issue,'command not found: nix'", StackOverflow](https://stackoverflow.com/a/70822086/982278)
Expand Down Expand Up @@ -127,13 +127,17 @@ You can find the whole installation guide for devenv in their official documenta

### Shopware

Depending on whether you want to set up a fresh Shopware project or contribute to the Shopware core, choose between:
Depending on whether you want to set up a fresh Shopware project or contribute to the Shopware core, you have to choose between the [Symfony Flex template](template) or the Shopware project.

<Tabs>
<Tab title="Symfony Flex">
If you are already using Symfony Flex, you require a Composer package to get a basic devenv configuration:
If you are already using our Symfony Flex template, you require a Composer package to get a basic devenv configuration:

```bash
```shell
cd <YOUR_SHOPWARE_FLEX_PROJECT_ROOT>
```

```shell
composer require devenv
```

Expand All @@ -160,6 +164,26 @@ devenv up
Make sure that the ports for the services are not already in use, or else the command will fail.
:::

Check your default web services with the following commands:

<Tabs>
<Tab title="macOS">

```bash
netstat -p tcp -van | grep '^Proto\|LISTEN'
```

</Tab>

<Tab title="Ubuntu">

```bash
ss -tulpn | grep ':80\|:3306\|:6379'
```

</Tab>
</Tabs>

Ensure to change your `.env` file to have the database connect using localhost's IP address instead of the default MySQL socket:

```txt
Expand Down Expand Up @@ -212,7 +236,7 @@ The installation instructions for other OS are available on direnv's [official d
</Tab>
</Tabs>

Afterwards, add the following hook to your shell:
Afterward, add the following hook to your shell:

<Tabs>

Expand Down Expand Up @@ -261,13 +285,27 @@ direnv allow

Here is an overview of services Shopware provides by default and how you can access them:

| Service | Access |
|------------------|------------------------------------------------|
| MySQL | `mysql://shopware:[email protected]:3306` |
| Caddy | [http://localhost:8000](http://localhost:8000) |
| Adminer | [http://localhost:9080](http://localhost:9080) |
| Mailhog (SMTP) | `smtp://127.0.0.1:1025` |
| Mailhog (Web UI) | [http://localhost:8025](http://localhost:8025) |
| Service | Access |
|----------------|-------------------------------------------------|
| MySQL | `mysql://shopware:[email protected]:3306` |
| Mailhog (SMTP) | `smtp://127.0.0.1:1025` |
| Redis (TCP) | `tcp://127.0.0.1:6379` |

### Caddy
Caddy is a powerful, enterprise-ready, open-source web server with automatic HTTPS written in Go.

[http://127.0.0.1:8000](http://127.0.0.1:8000)

### Adminer
Adminer is a full-featured database management tool written in PHP.

[http://localhost:8010](http://localhost:8010)

### Mailhog
MailHog is an email testing tool for developers.

[http://localhost:8025](http://localhost:8025)


## Customize your setup

Expand Down Expand Up @@ -301,7 +339,7 @@ After changing `devenv.local.nix`, please [reload your environment](#manually-re
};
# Override an environment variable
env.APP_URL = "http://shopware.swag";
env.APP_URL = "http://shopware.swag:YOUR_CADDY_PORT";
}
```

Expand Down Expand Up @@ -370,30 +408,46 @@ Refer to the official devenv documentation to get a complete list of all availab

### Use customized VirtualHosts port for Caddy

<Tabs>
<Tab title="Port">

```nix
// <PROJECT_ROOT>/devenv.local.nix
{ pkgs, config, lib, ... }:
{
services.caddy.virtualHosts = lib.mkForce {
":8029" = lib.mkDefault {
extraConfig = lib.mkDefault ''
@default {
not path /theme/* /media/* /thumbnail/* /bundles/* /css/* /fonts/* /js/* /sitemap/*
}
root * public
php_fastcgi @default unix/${config.languages.php.fpm.pools.web.socket} {
trusted_proxies private_ranges
}
file_server
'';
};
};
services.caddy.virtualHosts.":8029" = {
extraConfig = ''
root * public
php_fastcgi unix/${config.languages.php.fpm.pools.web.socket}
file_server
'';
};
}
```

</Tab>

<Tab title="Port and virtual host">

```nix
// <PROJECT_ROOT>/devenv.local.nix
{ pkgs, config, lib, ... }:
{
services.caddy.virtualHosts."http://shopware.swag:8029" = {
extraConfig = ''
root * public
php_fastcgi unix/${config.languages.php.fpm.pools.web.socket}
file_server
'';
};
```

</Tab>
</Tabs>


### Use customized Adminer port

```nix
Expand All @@ -417,16 +471,28 @@ devenv shell

### Direnv slow in big projects

The bigger your project directory is getting over time (e.g. cache files piling up), the slower direnv will be.
This is a known issue and the devenv developers are working on a solution.
The bigger your project directory is getting over time (e.g., cache files piling up), the slower direnv will be.
This is a known issue, and the devenv developers are working on a solution.

<PageRef page="https://github.com/cachix/devenv/issues/257" title="Devenv slows down with big code repositories #257" target="_blank" />

### Fail to start Redis with locale other than en_US

```shell
14:04:52 redis.1 | 364812:M 07 Nov 2023 14:04:52.999 # Failed to configure LOCALE for invalid locale name.
```

You can export a different locale to your shell with the following command:

```shell
export LANG=en_US.UTF8;
```

## FAQ

### How do I clean up devenv?

Periodically run `devenv gc` to remove orphaned services, packages and processes and free up disk space.
Periodically run `devenv gc` to remove orphaned services, packages and processes and free-up disk space.

### How do I access the database?

Expand Down

0 comments on commit dec286b

Please sign in to comment.