Make WordPress Core

Opened 3 years ago

Last modified 12 months ago

#52668 new enhancement

Make it easier to override the built-in docker environment's config

Reported by: timothyblynjacobs's profile TimothyBlynJacobs Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: has-patch
Focuses: Cc:

Description

Core currently ships with a .env file to provide a default configuration to the built-in Docker environment. If you want to override some of these variables you can setup values as environment variables before invoking the npm run env:* commands.

It can be a somewhat frustrating DUX if you need to consistently override these values, and not just once for testing some specific configuration. For instance if you need to use mariadb for ARM support, or making sure the correct port is used.

One possibility to make this more permanent is to modify the .env file itself, but then you need to remember to exclude changes to that file when committing which is a bit annoying.

There is the ability to create a docker-compose override file. But IMO that is a bit of overkill if just using the existing environment variable configuration would be sufficient.

One way I think we could solve this would be to change the .env file to .env.example and then in a post install routine copy the file from .env.example to .env if a .env file does not already exist. That way, if a user wants to they can customize that .env file without any fear that a future pull will overwrite their changes or that their changes would be accidentally included in a commit.

Attachments (1)

52668.diff (480 bytes) - added by h71 12 months ago.

Download all attachments as: .zip

Change History (5)

#1 @johnbillion
3 years ago

  • Keywords needs-patch added
  • Version trunk deleted

#2 @afragen
3 years ago

Just to chime in. For Macs you can determine the chip architecture using uname -m.

Intel based Macs

$ uname -m
x86_64

M1 based Mac

$ uname -m
arm64

It might be useful in a setup script.

This ticket was mentioned in PR #4593 on WordPress/wordpress-develop by @h71.


12 months ago
#3

  • Keywords has-patch added; needs-patch removed

Trac ticket: https://core.trac.wordpress.org/ticket/52668

Review notes:
A separate commit is present for adding EOF to .gitignore and it is not directly related to 52668 but it is very small and good to have, without side effects.

@h71
12 months ago

#4 @h71
12 months ago

The provided patch renames .env to .env.example without any changes in the file content.
It also adds .env to .gitignore to make sure it won't be committed to the repository again.
Also, an empty line is added to the .gitignore file.

Note: See TracTickets for help on using tickets.