From 5b3b63d952e8e3d5f8aac15a5ff29c9e9b922366 Mon Sep 17 00:00:00 2001 From: Giovanni Martins Date: Mon, 27 Nov 2023 18:19:42 -0300 Subject: [PATCH 1/2] making some changes on docker stuffs --- .docker/Dockerfile | 13 +++++++++++++ .docker/entrypoint.sh | 3 +++ config.php | 4 ++-- docker-compose.yml | 8 ++++++++ 4 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 .docker/Dockerfile create mode 100644 .docker/entrypoint.sh create mode 100644 docker-compose.yml diff --git a/.docker/Dockerfile b/.docker/Dockerfile new file mode 100644 index 0000000..00e9472 --- /dev/null +++ b/.docker/Dockerfile @@ -0,0 +1,13 @@ +FROM php:8.2 + +COPY --from=composer:2.6.5 /usr/bin/composer /usr/bin/composer + +RUN apt-get update && \ + apt-get install git -y + +RUN echo "alias jigsaw=./vendor/bin/jigsaw" >> ~/.bashrc && \ + echo "alias compile='./vendor/bin/jigsaw build'" >> ~/.bashrc && \ + /bin/bash -c "source ~/.bashrc" + +COPY entrypoint.sh /var/www/scripts/ +ENTRYPOINT [ "bash", "/var/www/scripts/entrypoint.sh" ] diff --git a/.docker/entrypoint.sh b/.docker/entrypoint.sh new file mode 100644 index 0000000..47d7ec0 --- /dev/null +++ b/.docker/entrypoint.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +php /var/www/html/vendor/bin/jigsaw serve --host=0.0.0.0 diff --git a/config.php b/config.php index 5aa1813..d9d0aa1 100644 --- a/config.php +++ b/config.php @@ -3,7 +3,7 @@ return [ 'production' => false, 'baseUrl' => '', - 'title' => 'Jigsaw', - 'description' => 'Website description.', + 'title' => 'PHP Rio', + 'description' => 'Site do grupo de usuário de PHP do Rio de Janeiro.', 'collections' => [], ]; diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..89daa6b --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,8 @@ +services: + + backend: + build: .docker + ports: + - "127.0.0.1:${HTTP_PORT:-8000}:8000" + volumes: + - .:/var/www/html From c2b80d57a12b845df166915967250e19de9cef50 Mon Sep 17 00:00:00 2001 From: Giovanni Martins Date: Mon, 27 Nov 2023 18:40:46 -0300 Subject: [PATCH 2/2] some updates installing nodejs and adding some more useful stuffs --- .docker/Dockerfile | 19 +++++++++++++++++-- .docker/entrypoint.sh | 4 ++++ .env.example | 8 ++++++++ docker-compose.yml | 5 +++++ 4 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 .env.example diff --git a/.docker/Dockerfile b/.docker/Dockerfile index 00e9472..851435b 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -2,8 +2,23 @@ FROM php:8.2 COPY --from=composer:2.6.5 /usr/bin/composer /usr/bin/composer -RUN apt-get update && \ - apt-get install git -y +RUN apt-get update \ + && apt-get install -y \ + git \ + # Install node + && curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \ + && apt-get install --no-install-recommends -y nodejs \ + && node --version \ + && npm --version + +# Install PHP extensions +ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ +RUN chmod uga+x /usr/local/bin/install-php-extensions && sync \ + && install-php-extensions \ + xdebug \ + zip \ + @composer \ + && rm /usr/local/bin/install-php-extensions RUN echo "alias jigsaw=./vendor/bin/jigsaw" >> ~/.bashrc && \ echo "alias compile='./vendor/bin/jigsaw build'" >> ~/.bashrc && \ diff --git a/.docker/entrypoint.sh b/.docker/entrypoint.sh index 47d7ec0..25beaf9 100644 --- a/.docker/entrypoint.sh +++ b/.docker/entrypoint.sh @@ -1,3 +1,7 @@ #!/bin/bash +# Set uid of host machine +usermod --non-unique --uid "${HOST_UID}" www-data +groupmod --non-unique --gid "${HOST_GID}" www-data + php /var/www/html/vendor/bin/jigsaw serve --host=0.0.0.0 diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..276c64a --- /dev/null +++ b/.env.example @@ -0,0 +1,8 @@ +HTTP_PORT=80 + +HOST_UID=1000 +HOST_GID=1000 + +TZ=America/Sao_Paulo + +XDEBUG_CONFIG="client_host=172.17.0.1 client_port=9003 start_with_request=yes" diff --git a/docker-compose.yml b/docker-compose.yml index 89daa6b..9508e71 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,3 +6,8 @@ services: - "127.0.0.1:${HTTP_PORT:-8000}:8000" volumes: - .:/var/www/html + environment: + - HOST_UID=${HOST_UID:-1000} + - HOST_GID=${HOST_GID:-1000} + - TZ=${TZ:-America/Sao_Paulo} + - XDEBUG_CONFIG=${XDEBUG_CONFIG:-"client_host=172.17.0.1 client_port=9003 start_with_request=yes"}