diff --git a/docker-compose/README.md b/docker-compose/README.md index cbc07d2621503e10ac5572c42b4ec377bdf0776b..188921786ff7bdebc763f5eaebe24521e9bdc945 100644 --- a/docker-compose/README.md +++ b/docker-compose/README.md @@ -6,6 +6,8 @@ the symfony app. ## Setup * `sudo apt install docker-compose` to install docker-compose on Debian/Ubuntu +* `sudo ./build.sh` - to build the docker images and install the PHP dependencies +* `sudo docker-compose up` - to run the server: http://127.0.0.1:8000 ## Running the Server @@ -17,7 +19,7 @@ the symfony app. ## Executing Symfony commands -* `./run` to start a shell in the php-fpm container. +* `./run.sh` to start a shell in the php-fpm container. * After this you can run symfony/composer commands like: * `./bin/console debug:config` * `composer install` diff --git a/docker-compose/build.sh b/docker-compose/build.sh new file mode 100755 index 0000000000000000000000000000000000000000..91968e8a5bbe1778086d7bb02ab5e181a0883198 --- /dev/null +++ b/docker-compose/build.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# We need to creat the user inside the container with the same ID as the host user +docker-compose build --build-arg "UID=${SUDO_UID:-$UID}" + +# Install dependencies +docker-compose run --rm --entrypoint composer php-fpm install \ No newline at end of file diff --git a/docker-compose/php-fpm/Dockerfile b/docker-compose/php-fpm/Dockerfile index b2e792ce79e89b00fcbc22a0739158881c4911d0..1a3571580c875a7b95efa3af4a5266635e547c95 100644 --- a/docker-compose/php-fpm/Dockerfile +++ b/docker-compose/php-fpm/Dockerfile @@ -38,7 +38,8 @@ RUN wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg STOPSIGNAL SIGQUIT -RUN useradd -u 1000 -ms /bin/bash user +ARG UID +RUN useradd -u "$UID" -ms /bin/bash user RUN echo 'user ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers USER user diff --git a/docker-compose/run b/docker-compose/run.sh similarity index 80% rename from docker-compose/run rename to docker-compose/run.sh index 79363b1c61f0fb60dde4422854ac6acf6ee3252b..adef6ef8b27d12640ab5f1aec52f90c0b2c1cb3f 100755 --- a/docker-compose/run +++ b/docker-compose/run.sh @@ -1,3 +1,3 @@ -#!/bin/sh +#!/bin/bash docker-compose run --rm --entrypoint bash php-fpm