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
10 changes: 2 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,8 @@ Interesting folders are:
* `templates`: The templates (HTML) that are used by Twig to render the different pages. Email templates are also saved here.
* `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).
* 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.
* Run `yarn watch`. The program will run in the background and compile the frontend files whenever you change something in the CSS or TypeScript files.
* For running Part-DB, it is recommended to use [Symfony CLI](https://symfony.com/download).
That way you can run a correctly configured webserver with `symfony serve`.
# Development environment
See [DEVELOPMENT.md](DEVELOPMENT.md) for setting up a development environment.

## Coding style
Code should follow the [PSR-12 Standard](https://www.php-fig.org/psr/psr-12/) and Symfony's [coding standards](https://symfony.com/doc/current/contributing/code/standards.html).
Expand Down
Loading
Loading