diff --git a/.docker/php/Dockerfile b/.docker/php/Dockerfile new file mode 100644 index 0000000..90737d0 --- /dev/null +++ b/.docker/php/Dockerfile @@ -0,0 +1,43 @@ +FROM php:8.3-fpm + +ARG NODE_MAJOR=20 + +RUN apt-get update \ + && apt-get install -y \ + git \ + espeak-ng \ + # Install node + ca-certificates \ + curl \ + gnupg \ + # see https://github.com/nodesource/distributions + && mkdir -p /etc/apt/keyrings \ + && curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \ + && echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list \ + && apt-get update \ + && apt-get install nodejs -y \ + && node --version \ + && npm --version \ + # Clean package cache + && rm -rf /var/lib/apt/lists/* + +# Install PHP extensions and Composer +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 \ + gd \ + xdebug \ + zip \ + @composer \ + && rm /usr/local/bin/install-php-extensions + +COPY xdebug.ini /usr/local/etc/php/conf.d/ + +RUN echo "alias jigsaw=./vendor/bin/jigsaw" >> /etc/bash.bashrc && \ + echo "alias compile='./vendor/bin/jigsaw build'" >> /etc/bash.bashrc && \ + /bin/bash -c "source /etc/bash.bashrc" + +WORKDIR /var/www/html + +COPY entrypoint.sh /var/www/scripts/ +ENTRYPOINT [ "bash", "/var/www/scripts/entrypoint.sh" ] \ No newline at end of file diff --git a/.docker/php/entrypoint.sh b/.docker/php/entrypoint.sh index 5a28780..2ba26ba 100644 --- a/.docker/php/entrypoint.sh +++ b/.docker/php/entrypoint.sh @@ -1,15 +1,14 @@ #!/bin/bash -# Set uid of host machine -usermod --non-unique --uid "${HOST_UID}" www-data -groupmod --non-unique --gid "${HOST_GID}" www-data - +# Composer if [ ! -d "vendor" ]; then - composer i + composer global require hirak/prestissimo +fi +composer install + +# NPM +. $NVM_DIR/nvm.sh +if [ ! -d "node_modules" ]; then + npm install fi -php-fpm & -if [[ "$SERVER_MODE" == 'watch' ]]; then - npm run watch -else - php ./vendor/bin/jigsaw serve --host 0.0.0.0 --port 3000 -fi \ No newline at end of file +npm run watch \ No newline at end of file diff --git a/.docker/php7/Dockerfile b/.docker/php7/Dockerfile deleted file mode 100644 index 4b5947f..0000000 --- a/.docker/php7/Dockerfile +++ /dev/null @@ -1,27 +0,0 @@ -FROM php:7.4 - -RUN apt-get update - -RUN apt-get install -y \ - git \ - unzip - -RUN pecl install xdebug-2.9.4 \ - && docker-php-ext-enable xdebug - -RUN curl https://getcomposer.org/composer.phar --output /usr/bin/composer -RUN chmod +x /usr/bin/composer - -ENV NVM_DIR=/opt/nvm -RUN git clone https://github.com/nvm-sh/nvm.git $NVM_DIR -RUN cd $NVM_DIR && \ - git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)` && \ - . $NVM_DIR/nvm.sh && \ - nvm install 13 && \ - nvm use node -RUN echo "source ${NVM_DIR}/nvm.sh" > $HOME/.bashrc - -WORKDIR /jigsaw - -COPY entrypoint.sh /usr/local/bin/entrypoint.sh -ENTRYPOINT ["bash", "/usr/local/bin/entrypoint.sh"] diff --git a/docker-compose.yml b/docker-compose.yml index 0a67fa8..127bd96 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,6 @@ -version: '3.3' services: - php7: - build: .docker/php7 + php: + build: .docker/php ports: - 80:3000 volumes: