mirror of
https://github.com/grocy/grocy.git
synced 2026-04-05 20:36:15 +02:00
Docker(-Compose) setup to aid local development.
This commit is contained in:
parent
4ea20ce076
commit
ea769c3069
40
.docker/README.md
Normal file
40
.docker/README.md
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
# Docker to aid local development
|
||||||
|
|
||||||
|
1. Copy `.docker/example.env` to `.env` (in project's root directory), change its contents to reflect your user's UID
|
||||||
|
and GID respectively. This will make try to force container to not create any files as root.
|
||||||
|
2. Copy `.docker/example.docker-compose.override.yml` to `docker-compose.override.yml` in application's root directory.
|
||||||
|
You may alter the HOST port (first one, as they're defined as `HOST:CONTAINER`) leaving container's port as `80`.
|
||||||
|
3. Run `docker-compose up` (or `start`) and wait for fetching, extracting and building process to complete (this will
|
||||||
|
happen only once or every time you'd like to rebuild the image)
|
||||||
|
4. Open separate terminal (or not, if you used `docker-compose start` before) and install project's dependencies like
|
||||||
|
this:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ .docker/composer.sh install
|
||||||
|
```
|
||||||
|
5. Visit `http://localhost` (or `http://localhost:8080` if you have altered `HOST`'s port to `8080` in step 2) to see
|
||||||
|
Grocy ready for your hacking.
|
||||||
|
6. Every time you need Composer for something use:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ .docker/composer.sh [require|update|etc] [other arguments]
|
||||||
|
```
|
||||||
|
7. You may also use PHP the same way:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ .docker/php.sh -v
|
||||||
|
```
|
||||||
|
|
||||||
|
Enjoy!
|
||||||
|
|
||||||
|
## BONUS
|
||||||
|
|
||||||
|
Would you like to see what happens to the app when launched on PHP 7.4 or 8.1? Edit `.docker/apache-php/Dockerfile` and
|
||||||
|
change image tag in the first line from `php:8.0-apache` to `php:7.4-apache` or `php:8.1-apache`. Then make
|
||||||
|
`docker-compose` rebuild the container for you:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ docker-compose build
|
||||||
|
```
|
||||||
|
|
||||||
|
And voila! After `docker-compose up` (or `start`) check what works and what breaks!
|
||||||
18
.docker/apache-php/Dockerfile
Normal file
18
.docker/apache-php/Dockerfile
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
# Application's image will be based on...
|
||||||
|
FROM php:8.0-apache
|
||||||
|
|
||||||
|
# Since web application should be served from `/public` subdirectory change the document root in Apache configuration
|
||||||
|
ENV APACHE_DOCUMENT_ROOT /var/www/html/public
|
||||||
|
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
|
||||||
|
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
|
||||||
|
|
||||||
|
# Make Rewrite engine enabled in Apache
|
||||||
|
RUN ln -s -t /etc/apache2/mods-enabled ../mods-available/rewrite.load
|
||||||
|
|
||||||
|
# Install Composer into the image
|
||||||
|
COPY --from=composer /usr/bin/composer /usr/bin/composer
|
||||||
|
|
||||||
|
# Install PHP dependencies using helper from https://github.com/mlocati/docker-php-extension-installer
|
||||||
|
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
|
||||||
|
RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"
|
||||||
|
RUN install-php-extensions gd intl xdebug zip
|
||||||
9
.docker/composer.sh
Executable file
9
.docker/composer.sh
Executable file
|
|
@ -0,0 +1,9 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
pushd "$(dirname "$0")" > /dev/null
|
||||||
|
pushd .. > /dev/null
|
||||||
|
|
||||||
|
docker-compose exec apache-php composer "$@"
|
||||||
|
|
||||||
|
popd > /dev/null
|
||||||
|
popd > /dev/null
|
||||||
6
.docker/example.docker-compose.override.yml
Normal file
6
.docker/example.docker-compose.override.yml
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
version: '3'
|
||||||
|
|
||||||
|
services:
|
||||||
|
apache-php:
|
||||||
|
ports:
|
||||||
|
- 80:80
|
||||||
2
.docker/example.env
Normal file
2
.docker/example.env
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
USER_ID=1000
|
||||||
|
GROUP_ID=1000
|
||||||
9
.docker/php.sh
Executable file
9
.docker/php.sh
Executable file
|
|
@ -0,0 +1,9 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
pushd "$(dirname "$0")" > /dev/null
|
||||||
|
pushd .. > /dev/null
|
||||||
|
|
||||||
|
docker-compose exec apache-php php "$@"
|
||||||
|
|
||||||
|
popd > /dev/null
|
||||||
|
popd > /dev/null
|
||||||
|
|
@ -6,3 +6,7 @@ indent_size = 4
|
||||||
charset = utf-8
|
charset = utf-8
|
||||||
trim_trailing_whitespace = true
|
trim_trailing_whitespace = true
|
||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
|
|
||||||
|
[*.yml]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
|
||||||
5
.gitignore
vendored
5
.gitignore
vendored
|
|
@ -1,4 +1,7 @@
|
||||||
/public/node_modules
|
/public/node_modules
|
||||||
/vendor
|
/vendor
|
||||||
/.release
|
/.release
|
||||||
embedded.txt
|
embedded.txt
|
||||||
|
/.idea
|
||||||
|
/.env
|
||||||
|
/docker-compose.override.yml
|
||||||
|
|
|
||||||
14
docker-compose.yml
Normal file
14
docker-compose.yml
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
version: '3'
|
||||||
|
|
||||||
|
services:
|
||||||
|
apache-php:
|
||||||
|
build: .docker/apache-php
|
||||||
|
environment:
|
||||||
|
DOCKER: "true"
|
||||||
|
COMPOSER_HOME: /tmp
|
||||||
|
XDEBUG_CONFIG: "client_host=host.docker.internal"
|
||||||
|
user: ${USER_ID:-1000}:${GROUP_ID:-1000}
|
||||||
|
volumes:
|
||||||
|
- .:/var/www/html
|
||||||
|
extra_hosts:
|
||||||
|
- host.docker.internal:host-gateway
|
||||||
Loading…
Reference in New Issue
Block a user