Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions .docker/dev/dev-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/bin/sh
set -eu

APP_DIR="/var/www/html"
DEV_HOME="/var/www/partdb-dev-home"

prepare_runtime()
{
# Development-only: newly created files are writable by all users,
# and newly created directories are writable/traversable by all users.
umask 000

mkdir -p \
"$DEV_HOME" \
"$DEV_HOME/.composer" \
"$DEV_HOME/.cache/composer" \
"$DEV_HOME/.cache/yarn" \
"$APP_DIR/vendor" \
"$APP_DIR/node_modules" \
"$APP_DIR/var/cache" \
"$APP_DIR/var/log" \
"$APP_DIR/var/db" \
"$APP_DIR/var/share" \
"$APP_DIR/uploads" \
"$APP_DIR/public/media" \
"$APP_DIR/public/build" \
"$APP_DIR/public/bundles"

chown -R www-data:www-data "$DEV_HOME"

# Development-only permission workaround for Linux bind mounts.
chmod 777 \
"$APP_DIR/vendor" \
"$APP_DIR/node_modules" \
"$APP_DIR/var/cache" \
"$APP_DIR/var/log" \
"$APP_DIR/var/db" \
"$APP_DIR/var/share" \
"$APP_DIR/uploads" \
"$APP_DIR/public/media" \
"$APP_DIR/public/build" \
"$APP_DIR/public/bundles"

export HOME="$DEV_HOME"
export COMPOSER_HOME="$DEV_HOME/.composer"
export COMPOSER_CACHE_DIR="$DEV_HOME/.cache/composer"
export YARN_CACHE_FOLDER="$DEV_HOME/.cache/yarn"

mkdir -p \
"$DEV_HOME" \
"$DEV_HOME/.composer" \
"$DEV_HOME/.cache/composer" \
"$DEV_HOME/.cache/yarn"

chown -R www-data:www-data "$DEV_HOME"

git config --system --get-all safe.directory 2>/dev/null \
| grep -Fxq "$APP_DIR" \
|| git config --system --add safe.directory "$APP_DIR"
}

start_server()
{
"php-fpm${PHP_VERSION}" -F &
exec /usr/local/bin/apache2-foreground
}

prepare_runtime

case "${1:-}" in
apache2-foreground|/usr/local/bin/apache2-foreground)
start_server
;;

*)
exec gosu www-data "$@"
;;
esac
5 changes: 4 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ Interesting folders are:
* `tests/`: Tests that can be run by PHPUnit.

## Development environment
For setting up a development environment, you will need to install PHP, Composer, a database server (MySQL or MariaDB) and yarn (which needs a Node.js environment).
For contributors who prefer a Docker-based development environment, see
[DEVELOPMENT.md](DEVELOPMENT.md).

For setting up a native PHP development environment, you will need to install PHP, Composer, a database server (MySQL or MariaDB) and yarn (which needs a Node.js environment).
* Copy `.env` to `.env.local` and change `APP_ENV` to `APP_ENV=dev`. That way you will get development tools (Symfony profiler) and other features that
will simplify development.
* Run `composer install` (without -o) to install PHP dependencies and `yarn install` to install frontend dependencies.
Expand Down
Loading
Loading