├── .gitignore ├── .data ├── .gitignore ├── mysql │ └── .gitignore └── redis │ └── .gitignore ├── workspace ├── .gitignore └── Dockerfile ├── .config └── .gitignore ├── .logs └── nginx │ └── .gitignore ├── redis └── Dockerfile ├── .stubs └── mysql │ └── docker-entrypoint-initdb.d │ ├── .gitignore │ └── createdb.sql.example ├── grafana └── Dockerfile ├── prometheus └── Dockerfile ├── portainer └── Dockerfile ├── .editorconfig ├── mariadb ├── Dockerfile └── my.cnf ├── mysql ├── Dockerfile └── my.cnf ├── nginx └── Dockerfile ├── LICENSE ├── php-fpm └── Dockerfile ├── composer.json ├── CONTRIBUTING.md ├── .env.example ├── CODE_OF_CONDUCT.md ├── docker-compose.yml └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | -------------------------------------------------------------------------------- /.data/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /workspace/.gitignore: -------------------------------------------------------------------------------- 1 | .internal 2 | -------------------------------------------------------------------------------- /.config/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /.data/mysql/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /.data/redis/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /.logs/nginx/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /redis/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG REDIS_VERSION=alpine 2 | FROM redis:${REDIS_VERSION} 3 | -------------------------------------------------------------------------------- /.stubs/mysql/docker-entrypoint-initdb.d/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | !createdb.sql.example 4 | -------------------------------------------------------------------------------- /grafana/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG GRAFANA_VERSION=latest 2 | FROM grafana/grafana-oss:${GRAFANA_VERSION} 3 | -------------------------------------------------------------------------------- /prometheus/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG PROMETHEUS_VERSION=latest 2 | FROM prom/prometheus:${PROMETHEUS_VERSION} 3 | -------------------------------------------------------------------------------- /portainer/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG PORTAINER_VERSION=latest 2 | FROM portainer/portainer-ce:${PORTAINER_VERSION} 3 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | end_of_line = lf 7 | indent_style = space 8 | insert_final_newline = true 9 | max_line_length = 80 10 | trim_trailing_whitespace = true 11 | 12 | [*.md] 13 | max_line_length = 0 14 | trim_trailing_whitespace = false 15 | 16 | [COMMIT_EDITMSG] 17 | max_line_length = 0 18 | -------------------------------------------------------------------------------- /mariadb/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG MARIADB_VERSION=latest 2 | FROM mariadb:${MARIADB_VERSION} 3 | 4 | # Set Timezone 5 | ARG TZ=${TZ} 6 | ENV TZ ${TZ} 7 | RUN ln -snf /usr/share/zoneinfo/${TZ} /etc/localtime \ 8 | && echo ${TZ} > /etc/timezone 9 | 10 | # Fix filesystem permissions 11 | RUN chown -R mysql:root /var/lib/mysql/ 12 | 13 | # Copy config file 14 | COPY ./my.cnf /etc/mysql/conf.d/my.cnf 15 | -------------------------------------------------------------------------------- /mysql/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG MYSQL_VERSION=latest 2 | FROM mysql/mysql-server:${MYSQL_VERSION} 3 | 4 | # Set Timezone 5 | ARG TZ=${TZ} 6 | ENV TZ ${TZ} 7 | RUN ln -snf /usr/share/zoneinfo/${TZ} /etc/localtime \ 8 | && echo ${TZ} > /etc/timezone 9 | 10 | # Fix filesystem permissions 11 | RUN chown -R mysql:root /var/lib/mysql/ 12 | 13 | # Copy config file 14 | COPY ./my.cnf /etc/mysql/conf.d/my.cnf 15 | -------------------------------------------------------------------------------- /mysql/my.cnf: -------------------------------------------------------------------------------- 1 | # The MySQL Client configuration file. 2 | # 3 | # For explanations see 4 | # http://dev.mysql.com/doc/mysql/en/server-system-variables.html 5 | 6 | [client] 7 | default-character-set=utf8mb4 8 | 9 | [mysql] 10 | default-character-set=utf8mb4 11 | 12 | [mysqld] 13 | sql-mode="STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION" 14 | collation-server=utf8mb4_unicode_ci 15 | character-set-server=utf8mb4 16 | 17 | default_authentication_plugin=mysql_native_password 18 | lower_case_table_names=2 19 | -------------------------------------------------------------------------------- /nginx/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG NGINX_VERSION=alpine 2 | FROM nginx:${NGINX_VERSION} 3 | 4 | ARG PHP_UPSTREAM_PORT=${PHP_UPSTREAM_PORT} 5 | ARG PHP_UPSTREAM_CONTAINER=${PHP_UPSTREAM_CONTAINER} 6 | 7 | # ensure www-data user exists 8 | RUN adduser -u 82 -D -S -G www-data www-data 9 | 10 | # Set upstream conf and remove the default conf 11 | RUN echo "upstream php-upstream { server ${PHP_UPSTREAM_CONTAINER}:${PHP_UPSTREAM_PORT}; }" > /etc/nginx/conf.d/upstream.conf \ 12 | && rm /etc/nginx/conf.d/default.conf 13 | 14 | WORKDIR /var/www 15 | -------------------------------------------------------------------------------- /mariadb/my.cnf: -------------------------------------------------------------------------------- 1 | # The MySQL Client configuration file. 2 | # 3 | # For explanations see 4 | # http://dev.mysql.com/doc/mysql/en/server-system-variables.html 5 | 6 | [client] 7 | default-character-set=utf8mb4 8 | 9 | [mysql] 10 | default-character-set=utf8mb4 11 | 12 | [mysqld] 13 | sql-mode="STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION" 14 | collation-server=utf8mb4_unicode_ci 15 | init-connect='SET NAMES utf8mb4' 16 | character-set-server=utf8mb4 17 | 18 | default_authentication_plugin=mysql_native_password 19 | lower_case_table_names=2 20 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016-2018, Rinvex LLC, 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /.stubs/mysql/docker-entrypoint-initdb.d/createdb.sql.example: -------------------------------------------------------------------------------- 1 | # 2 | # Copy createdb.sql.example to createdb.sql 3 | # then uncomment then set database name and username to create you need databases 4 | # 5 | # example: .env MYSQL_USER=appuser and need db name is myshop_db 6 | # 7 | # CREATE DATABASE IF NOT EXISTS `myshop_db` ; 8 | # GRANT ALL ON `myshop_db`.* TO 'appuser'@'%' ; 9 | # 10 | # 11 | # this sql script will auto run when the mysql container starts and the $MYSQL_DATA_PATH not found. 12 | # 13 | # if your $MYSQL_DATA_PATH exists and you do not want to delete it, you can run by manual execution: 14 | # 15 | # docker-compose exec mysql bash 16 | # mysql -u root -p < /docker-entrypoint-initdb.d/createdb.sql 17 | # 18 | 19 | #CREATE DATABASE IF NOT EXISTS `dev_db_1` COLLATE 'utf8_general_ci' ; 20 | #GRANT ALL ON `dev_db_1`.* TO 'default'@'%' ; 21 | 22 | #CREATE DATABASE IF NOT EXISTS `dev_db_2` COLLATE 'utf8_general_ci' ; 23 | #GRANT ALL ON `dev_db_2`.* TO 'default'@'%' ; 24 | 25 | #CREATE DATABASE IF NOT EXISTS `dev_db_3` COLLATE 'utf8_general_ci' ; 26 | #GRANT ALL ON `dev_db_3`.* TO 'default'@'%' ; 27 | 28 | CREATE USER 'root'@'%' IDENTIFIED BY 'root'; GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION; 29 | 30 | FLUSH PRIVILEGES ; 31 | -------------------------------------------------------------------------------- /php-fpm/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG PHP_VERSION=fpm-alpine 2 | FROM php:${PHP_VERSION} 3 | 4 | # Set Environment Variables 5 | ENV DEBIAN_FRONTEND noninteractive 6 | 7 | # Set Timezone 8 | ARG TZ=${TZ} 9 | ENV TZ ${TZ} 10 | 11 | RUN ln -snf /usr/share/zoneinfo/${TZ} /etc/localtime && echo ${TZ} > /etc/timezone 12 | 13 | RUN apt-get update \ 14 | && apt-get install -y --no-install-recommends \ 15 | apt-utils nano libz-dev libpq-dev libpng-dev \ 16 | git libjpeg-dev libmcrypt-dev libfreetype6-dev \ 17 | libzip-dev libicu-dev jpegoptim optipng pngquant gifsicle \ 18 | libmagickwand-dev imagemagick libxml2-dev libxslt1-dev \ 19 | libc-client-dev libkrb5-dev 20 | 21 | RUN pecl channel-update pecl.php.net \ 22 | && pecl install -o -f redis \ 23 | && docker-php-ext-configure intl \ 24 | && docker-php-ext-configure gd --with-jpeg --with-freetype \ 25 | && docker-php-ext-configure imap --with-kerberos --with-imap-ssl \ 26 | && docker-php-ext-install zip gd pdo_mysql calendar imap pcntl \ 27 | exif opcache bcmath mysqli intl sockets gettext soap xsl \ 28 | && docker-php-ext-enable redis 29 | 30 | 31 | # Start Workaround: Get Imagick Extension 32 | RUN git clone https://github.com/Imagick/imagick \ 33 | && cd imagick \ 34 | && phpize && ./configure \ 35 | && make \ 36 | && make install 37 | 38 | # Move the imagick extension 39 | RUN cd imagick \ 40 | && EXTENSION_DIR="$( php -i | grep ^extension_dir | awk -F '=>' '{print $2}' | xargs )" \ 41 | && if [ ! -d "${EXTENSION_DIR}" ]; then mkdir -p "${EXTENSION_DIR}"; fi \ 42 | && cp ./modules/imagick.so "${EXTENSION_DIR}/imagick.so" \ 43 | && cd ../ \ 44 | && rm -rf imagick 45 | 46 | # Enable the module 47 | RUN docker-php-ext-enable imagick 48 | # End Workaround: Get Imagick Extension 49 | 50 | 51 | # Clean up 52 | RUN apt-get clean && rm -rf /tmp/pear && \ 53 | rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \ 54 | rm /var/log/lastlog /var/log/faillog 55 | 56 | WORKDIR /var/www 57 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rinvex/punnet", 3 | "description": "Rinvex Punnet is a polymorphic Laravel package, for addressbook management. You can add addresses to any eloquent model with ease.", 4 | "keywords": [ 5 | "rinvex", 6 | "punnet", 7 | "laravel" 8 | ], 9 | "license": "MIT", 10 | "homepage": "https://rinvex.com", 11 | "support": { 12 | "email": "help@rinvex.com", 13 | "issues": "https://github.com/rinvex/punnet/issues", 14 | "source": "https://github.com/rinvex/punnet", 15 | "docs": "https://github.com/rinvex/punnet/blob/master/README.md" 16 | }, 17 | "authors": [ 18 | { 19 | "name": "Rinvex LLC", 20 | "homepage": "https://rinvex.com", 21 | "email": "help@rinvex.com" 22 | }, 23 | { 24 | "name": "Abdelrahman Omran", 25 | "homepage": "https://omranic.com", 26 | "email": "me@omranic.com", 27 | "role": "Project Lead" 28 | }, 29 | { 30 | "name": "The Generous Laravel Community", 31 | "homepage": "https://github.com/rinvex/punnet/contributors" 32 | } 33 | ], 34 | "require": { 35 | "php": "^8.2.0" 36 | }, 37 | "require-dev": { 38 | "codedungeon/phpunit-result-printer": "^0.26.0", 39 | "phpunit/phpunit": "^7.0.0" 40 | }, 41 | "autoload": { 42 | "classmap": [ 43 | "database" 44 | ], 45 | "psr-4": { 46 | "Rinvex\\Addresses\\": "src/" 47 | } 48 | }, 49 | "autoload-dev": { 50 | "psr-4": { 51 | "Rinvex\\Addresses\\Tests\\": "tests" 52 | } 53 | }, 54 | "config": { 55 | "sort-packages": true, 56 | "preferred-install": "dist", 57 | "optimize-autoloader": true 58 | }, 59 | "extra": { 60 | "branch-alias": { 61 | "dev-master": "1.0-dev" 62 | }, 63 | "laravel": { 64 | "providers": [ 65 | "Rinvex\\Addresses\\Providers\\AddressesServiceProvider" 66 | ] 67 | } 68 | }, 69 | "minimum-stability": "dev", 70 | "prefer-stable": true 71 | } 72 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contribution Guide 2 | 3 | This project adheres to the following standards and practices. 4 | 5 | 6 | ## Versioning 7 | 8 | This project is versioned under the [Semantic Versioning](http://semver.org/) guidelines as much as possible. 9 | 10 | Releases will be numbered with the following format: 11 | 12 | - `..` 13 | - `..` 14 | 15 | And constructed with the following guidelines: 16 | 17 | - Breaking backward compatibility bumps the major and resets the minor and patch. 18 | - New additions without breaking backward compatibility bumps the minor and resets the patch. 19 | - Bug fixes and misc changes bumps the patch. 20 | 21 | 22 | ## Pull Requests 23 | 24 | The pull request process differs for new features and bugs. 25 | 26 | Pull requests for bugs may be sent without creating any proposal issue. If you believe that you know of a solution for a bug that has been filed, please leave a comment detailing your proposed fix or create a pull request with the fix mentioning that issue id. 27 | 28 | 29 | ## Coding Standards 30 | 31 | This project follows the FIG PHP Standards Recommendations compliant with the [PSR-1: Basic Coding Standard](http://www.php-fig.org/psr/psr-1/), [PSR-2: Coding Style Guide](http://www.php-fig.org/psr/psr-2/) and [PSR-4: Autoloader](http://www.php-fig.org/psr/psr-4/) to ensure a high level of interoperability between shared PHP code. If you notice any compliance oversights, please send a patch via pull request. 32 | 33 | 34 | ## Feature Requests 35 | 36 | If you have a proposal or a feature request, you may create an issue with `[Proposal]` in the title. 37 | 38 | The proposal should also describe the new feature, as well as implementation ideas. The proposal will then be reviewed and either approved or denied. Once a proposal is approved, a pull request may be created implementing the new feature. 39 | 40 | 41 | ## Git Flow 42 | 43 | This project follows [Git-Flow](http://nvie.com/posts/a-successful-git-branching-model/), and as such has `master` (latest stable releases), `develop` (latest WIP development) and X.Y support branches (when there's multiple major versions). 44 | 45 | Accordingly all pull requests MUST be sent to the `develop` branch. 46 | 47 | > **Note:** Pull requests which do not follow these guidelines will be closed without any further notice. 48 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | ########################################################### 2 | ###################### General Setup ###################### 3 | ########################################################### 4 | 5 | # Rinvex: 6 | # docker-compose up -d redis mysql mariadb portainer workspace php-fpm nginx 7 | 8 | # Paths 9 | WEB_DATA_PATH=../ 10 | 11 | # Orbstack Local Domains 12 | LOCAL_DOMAINS=phpmyadmin.local,portainer.local,grafana.local,prometheus.local,*.rinvex.local,*.tenant.local,*.dev.local 13 | 14 | # Drivers 15 | NETWORKS_DRIVER=bridge 16 | 17 | # Docker compose config 18 | 19 | # Which docker-compose files to include. 20 | # If using docker-sync append `:docker-compose.sync.yml` at the end 21 | COMPOSE_FILE=docker-compose.yml 22 | 23 | # Change the separator from : to ; on Windows 24 | COMPOSE_PATH_SEPARATOR=: 25 | 26 | # Define the prefix of container names. This is useful if you have multiple projects that use punnet to have seperate containers per project. 27 | COMPOSE_PROJECT_NAME=punnet 28 | 29 | 30 | ########################################################### 31 | ################ Containers Customization ################# 32 | ########################################################### 33 | 34 | # GLOBAL 35 | TZ=UTC 36 | 37 | # WORKSPACE 38 | NODE_VERSION=stable 39 | 40 | # NGINX 41 | NGINX_VERSION=alpine 42 | NGINX_HOST_HTTP_PORT=80 43 | NGINX_HOST_HTTPS_PORT=443 44 | NGINX_LOG_PATH=./.logs/nginx/ 45 | NGINX_CONFIG_PATH=./.config/nginx/ 46 | PHP_UPSTREAM_CONTAINER=php-fpm 47 | PHP_UPSTREAM_PORT=9000 48 | 49 | # PHP 50 | PHP_VERSION=8.3-fpm 51 | PHP_CONFIG_PATH=./.config/php/ 52 | 53 | # MYSQL 54 | MYSQL_VERSION=latest 55 | MYSQL_PORT=3306 56 | MYSQL_ROOT_PASSWORD=root 57 | MYSQL_DATA_PATH=./.data/mysql 58 | MYSQL_ENTRYPOINT_INITDB=./.stubs/mysql/docker-entrypoint-initdb.d 59 | 60 | # MARIADB 61 | MARIADB_VERSION=latest 62 | MARIADB_PORT=3306 63 | MARIADB_ROOT_PASSWORD=root 64 | MARIA_DATA_PATH=./.data/maria 65 | MARIADB_ENTRYPOINT_INITDB=./.stubs/mysql/docker-entrypoint-initdb.d 66 | 67 | # REDIS 68 | REDIS_VERSION=alpine 69 | REDIS_PORT=6379 70 | REDIS_DATA_PATH=./.data/redis 71 | 72 | # PORTAINER 73 | PORTAINER_VERSION=latest 74 | PORTAINER_DATA_PATH=./.data/portainer 75 | 76 | # PROMETHEUS 77 | PROMETHEUS_VERSION=latest 78 | PROMETHEUS_PORT=9090 79 | PROMETHEUS_DATA_PATH=./.data/prometheus 80 | PROMETHEUS_CONFIG_PATH=./.config/prometheus/ 81 | 82 | # GRAFANA 83 | GRAFANA_VERSION=latest 84 | GRAFANA_PORT=3000 85 | GRAFANA_DATA_PATH=./.data/grafana/ 86 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, gender identity and expression, level of experience, 9 | nationality, personal appearance, race, religion, or sexual identity and 10 | orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at [help@rinvex.com](mailto:help@rinvex.com). All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at [http://contributor-covenant.org/version/1/4][version] 72 | 73 | [homepage]: http://contributor-covenant.org 74 | [version]: http://contributor-covenant.org/version/1/4/ 75 | -------------------------------------------------------------------------------- /workspace/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG PHP_VERSION=fpm 2 | FROM php:${PHP_VERSION} 3 | 4 | # Set Environment Variables 5 | ENV DEBIAN_FRONTEND noninteractive 6 | 7 | # Set Timezone 8 | ARG TZ=${TZ} 9 | ENV TZ ${TZ} 10 | 11 | RUN ln -snf /usr/share/zoneinfo/${TZ} /etc/localtime && echo ${TZ} > /etc/timezone 12 | 13 | COPY ./.internal/.gitignore_global /root/.gitignore_global 14 | COPY ./.internal/.gitconfig /root/.gitconfig 15 | COPY ./.internal/auth.json /root/.composer/ 16 | COPY ./.internal/.bashrc /root/.bashrc 17 | COPY ./.internal/.ssh/ /root/.ssh/ 18 | 19 | RUN apt-get update \ 20 | && apt-get install -y --no-install-recommends locales\ 21 | git git-flow zip unzip curl ntp whois dnsutils \ 22 | libmcrypt4 libpcre3-dev bash-completion locate \ 23 | apt-utils nano libz-dev libpq-dev libpng-dev \ 24 | libjpeg-dev libmcrypt-dev libfreetype6-dev \ 25 | libzip-dev libicu-dev jpegoptim optipng pngquant gifsicle \ 26 | python3 python3-dev python3-setuptools pipx build-essential \ 27 | libmagickwand-dev imagemagick libxml2-dev libxslt1-dev \ 28 | libc-client-dev libkrb5-dev openssh-client gnupg \ 29 | && pipx ensurepath 30 | 31 | # Set Locale (after installing locales) 32 | RUN echo "LC_ALL=en_US.UTF-8" >> /etc/default/locale 33 | RUN locale-gen en_US.UTF-8 34 | 35 | RUN pecl channel-update pecl.php.net \ 36 | && pecl install -o -f redis xdebug \ 37 | && docker-php-ext-configure intl \ 38 | && docker-php-ext-configure gd --with-jpeg --with-freetype \ 39 | && docker-php-ext-configure imap --with-kerberos --with-imap-ssl \ 40 | && docker-php-ext-install zip gd pdo_mysql calendar imap pcntl \ 41 | exif opcache bcmath mysqli intl sockets gettext soap xsl \ 42 | && docker-php-ext-enable redis xdebug 43 | 44 | 45 | # Start Workaround: Get Imagick Extension 46 | RUN git clone https://github.com/Imagick/imagick \ 47 | && cd imagick \ 48 | && phpize && ./configure \ 49 | && make \ 50 | && make install 51 | 52 | # Move the imagick extension 53 | RUN cd imagick \ 54 | && EXTENSION_DIR="$( php -i | grep ^extension_dir | awk -F '=>' '{print $2}' | xargs )" \ 55 | && if [ ! -d "${EXTENSION_DIR}" ]; then mkdir -p "${EXTENSION_DIR}"; fi \ 56 | && cp ./modules/imagick.so "${EXTENSION_DIR}/imagick.so" \ 57 | && cd ../ \ 58 | && rm -rf imagick 59 | 60 | # Enable the module 61 | RUN docker-php-ext-enable imagick 62 | # End Workaround: Get Imagick Extension 63 | 64 | 65 | # Install Composer 66 | ENV COMPOSER_DIR /root/.composer 67 | RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \ 68 | && printf "\nPATH=\"$COMPOSER_DIR/vendor/bin:\$PATH\"\n" | tee -a /root/.bashrc 69 | 70 | 71 | # Node / NVM 72 | ARG NODE_VERSION=stable 73 | ENV NODE_VERSION ${NODE_VERSION} 74 | ENV NVM_DIR /root/.nvm 75 | 76 | RUN mkdir -p ${NVM_DIR} \ 77 | && curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.38.0/install.sh | bash \ 78 | && . ${NVM_DIR}/nvm.sh \ 79 | && nvm install ${NODE_VERSION} \ 80 | && nvm use ${NODE_VERSION} \ 81 | && nvm alias ${NODE_VERSION} 82 | 83 | # Wouldn't execute when added to the RUN statement in the above block 84 | # Source NVM when loading bash since /root/.profile isn't loaded on non-login shell 85 | RUN echo "" >> /root/.bashrc \ 86 | && echo 'export NVM_DIR="${NVM_DIR}/.nvm"' >> /root/.bashrc \ 87 | && echo '[ -s "${NVM_DIR}/nvm.sh" ] && . "${NVM_DIR}/nvm.sh" # This loads nvm' >> /root/.bashrc \ 88 | && printf "\nPATH=\"${NVM_DIR}/vendor/bin:\$PATH\"\n" | tee -a /root/.bashrc \ 89 | && exec bash && . /root/.bashrc && npm install -g svgo 90 | 91 | 92 | # Update nano config 93 | RUN sed -i "s/# set linenumbers/set linenumbers/" /etc/nanorc 94 | 95 | # Clean up 96 | RUN apt-get clean && rm -rf /tmp/pear && \ 97 | rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \ 98 | rm /var/log/lastlog /var/log/faillog 99 | 100 | WORKDIR /var/www 101 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | networks: 2 | punnet: 3 | driver: ${NETWORKS_DRIVER} 4 | 5 | services: 6 | 7 | ### WORKSPACE ### 8 | workspace: 9 | hostname: workspace 10 | build: 11 | context: ./workspace 12 | args: 13 | - TZ=${TZ} 14 | - PHP_VERSION=${PHP_VERSION} 15 | - NODE_VERSION=${NODE_VERSION} 16 | volumes: 17 | - ${PHP_CONFIG_PATH}:/usr/local/etc 18 | - ${WEB_DATA_PATH}:/var/www:cached 19 | tty: true 20 | networks: 21 | - punnet 22 | ports: 23 | - 8089:8089 24 | - 8090:8090 25 | 26 | ### PHP-FPM ### 27 | php-fpm: 28 | hostname: php-fpm 29 | build: 30 | context: ./php-fpm 31 | args: 32 | - TZ=${TZ} 33 | - PHP_VERSION=${PHP_VERSION} 34 | volumes: 35 | - ${PHP_CONFIG_PATH}:/usr/local/etc 36 | - ${WEB_DATA_PATH}:/var/www:cached 37 | expose: 38 | - ${PHP_UPSTREAM_PORT} 39 | networks: 40 | - punnet 41 | 42 | ### NGINX ### 43 | nginx: 44 | hostname: nginx 45 | build: 46 | context: ./nginx 47 | args: 48 | - NGINX_VERSION=${NGINX_VERSION} 49 | - PHP_UPSTREAM_PORT=${PHP_UPSTREAM_PORT} 50 | - PHP_UPSTREAM_CONTAINER=${PHP_UPSTREAM_CONTAINER} 51 | volumes: 52 | - ${WEB_DATA_PATH}:/var/www:cached 53 | - ${NGINX_LOG_PATH}:/var/log/nginx/ 54 | - ${NGINX_CONFIG_PATH}:/etc/nginx/ 55 | ports: 56 | - ${NGINX_HOST_HTTP_PORT}:80 57 | - ${NGINX_HOST_HTTPS_PORT}:443 58 | depends_on: 59 | - php-fpm 60 | networks: 61 | - punnet 62 | labels: 63 | - dev.orbstack.domains=${LOCAL_DOMAINS} 64 | 65 | ### MYSQL ### 66 | mysql: 67 | hostname: mysql 68 | build: 69 | context: ./mysql 70 | args: 71 | - TZ=${TZ} 72 | - MYSQL_VERSION=${MYSQL_VERSION} 73 | environment: 74 | - MYSQL_ROOT_HOST='%' 75 | - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} 76 | volumes: 77 | - ${MYSQL_DATA_PATH}:/var/lib/mysql 78 | - ${MYSQL_ENTRYPOINT_INITDB}:/docker-entrypoint-initdb.d 79 | ports: 80 | - ${MYSQL_PORT}:3306 81 | networks: 82 | - punnet 83 | 84 | ### REDIS ### 85 | redis: 86 | hostname: redis 87 | build: 88 | context: ./redis 89 | args: 90 | - REDIS_VERSION=${REDIS_VERSION} 91 | volumes: 92 | - ${REDIS_DATA_PATH}:/data 93 | ports: 94 | - ${REDIS_PORT}:6379 95 | networks: 96 | - punnet 97 | 98 | ### MARIADB ### 99 | mariadb: 100 | hostname: mariadb 101 | build: 102 | context: ./mariadb 103 | args: 104 | - TZ=${TZ} 105 | - MARIADB_VERSION=${MARIADB_VERSION} 106 | environment: 107 | - MARIADB_ROOT_PASSWORD=${MARIADB_ROOT_PASSWORD} 108 | volumes: 109 | - ${MARIA_DATA_PATH}:/var/lib/mysql 110 | - ${MARIADB_ENTRYPOINT_INITDB}:/docker-entrypoint-initdb.d 111 | ports: 112 | - ${MARIADB_PORT}:3306 113 | networks: 114 | - punnet 115 | 116 | ### PORTAINER ### 117 | portainer: 118 | hostname: portainer 119 | build: 120 | context: ./portainer 121 | volumes: 122 | - ${PORTAINER_DATA_PATH}:/data 123 | - /var/run/docker.sock:/var/run/docker.sock 124 | networks: 125 | - punnet 126 | 127 | ### PROMETHEUS ### 128 | prometheus: 129 | hostname: prometheus 130 | build: 131 | context: ./prometheus 132 | args: 133 | - PROMETHEUS_VERSION=${PROMETHEUS_VERSION} 134 | volumes: 135 | - ${PROMETHEUS_CONFIG_PATH}:/etc/prometheus/ 136 | - ${PROMETHEUS_DATA_PATH}:/prometheus 137 | networks: 138 | - punnet 139 | # ports: 140 | # - ${PROMETHEUS_PORT}:9090 141 | # labels: 142 | # - dev.orbstack.domains=prometheus.local 143 | 144 | ### GRAFANA ### 145 | grafana: 146 | hostname: grafana 147 | build: 148 | context: ./grafana 149 | args: 150 | - GRAFANA_VERSION=${GRAFANA_VERSION} 151 | volumes: 152 | - ${GRAFANA_DATA_PATH}:/var/lib/grafana 153 | networks: 154 | - punnet 155 | # ports: 156 | # - ${GRAFANA_PORT}:3000 157 | # labels: 158 | # - dev.orbstack.domains=grafana.local 159 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Rinvex Punnet 2 | 3 | **Rinvex Punnet** is opinionated, lightweight, yet powerful, and performant light speed docker environment for PHP applications. 4 | 5 | [![Packagist](https://img.shields.io/packagist/v/rinvex/punnet.svg?label=Packagist&style=flat-square)](https://packagist.org/packages/rinvex/punnet) 6 | [![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/rinvex/punnet.svg?label=Scrutinizer&style=flat-square)](https://scrutinizer-ci.com/g/rinvex/punnet/) 7 | [![Code Climate](https://img.shields.io/codeclimate/github/rinvex/punnet.svg?label=CodeClimate&style=flat-square)](https://codeclimate.com/github/rinvex/punnet) 8 | [![Travis](https://img.shields.io/travis/rinvex/punnet.svg?label=TravisCI&style=flat-square)](https://travis-ci.org/rinvex/punnet) 9 | [![StyleCI](https://styleci.io/repos/87485079/shield)](https://styleci.io/repos/87485079) 10 | [![License](https://img.shields.io/packagist/l/rinvex/punnet.svg?label=License&style=flat-square)](https://github.com/rinvex/punnet/blob/develop/LICENSE) 11 | 12 | 13 | It's a full PHP development environment based on [Docker](https://www.docker.com). 14 | 15 | This environment includes pre-packaged Docker images, all pre-configured to provide a wonderful PHP development environment, with flexibility, and performance in mind. 16 | 17 | 18 | 19 | ## Features 20 | 21 | - Easy switch between PHP versions: 7.4, 7.3, 7.2, 7.1... 22 | - Choose your favorite database engine: MySQL 23 | - Every software runs on a separate container: PHP-FPM, NGINX, PHP-CLI... 24 | - Easy to customize any container, with simple edit to the `Dockerfile`. 25 | - All Images extends from an official base Image. (Trusted base Images). 26 | - Pre-configured NGINX to host any code at your root directory. 27 | - Can use **Rinvex Punnet** per project, or single **Rinvex Punnet** instance for all projects. 28 | - Easy to install/remove software in Containers using environment variables. 29 | - Clean and well structured Dockerfiles (`Dockerfile`). 30 | - Latest version of the Docker Compose file (`docker-compose`). 31 | - Everything is visible and editable. 32 | - Fast Images Builds. 33 | - More to come! 34 | 35 | 36 | ## Getting Started 37 | 38 | 39 | ### Requirements 40 | 41 | - [Git](https://git-scm.com/downloads) 42 | - [Docker](https://www.docker.com/products/docker/) `>= 18.00.0` 43 | 44 | 45 | 46 | ### Installation 47 | 48 | Follow these steps if you want a one docker environment for multiple projects. 49 | 50 | Let's see how easy it is to install **NGINX**, **PHP**, **Composer**, **MySQL**, and **Redis**, all at once: 51 | 52 | 53 | 1. Install **Rinvex Punnet** outside the project directory: 54 | 55 | Clone this repository anywhere on your machine: 56 | 57 | ```bash 58 | git clone https://github.com/rinvex/punnet.git 59 | ``` 60 | 61 | Your folder structure should look like this: 62 | 63 | ``` 64 | + punnet 65 | + project-a 66 | + project-b 67 | ``` 68 | 69 | 70 | 2. Prepare your docker environment config: 71 | 72 | ``` 73 | cp .env.example .env 74 | ``` 75 | 76 | At the top of your docker `.env` file, change the `WEB_DATA_PATH` variable to your project path: 77 | 78 | ``` 79 | WEB_DATA_PATH=../project-a/ 80 | ``` 81 | 82 | Make sure to replace `project-a` with your project folder name. 83 | 84 | You can edit the docker environment config `.env` file to choose which software you want to be installed in your environment. You can always refer to the `docker-compose.yml` file to see how those variables have been used. 85 | 86 | Depending on the host's operating system you may need to change the value given to `COMPOSE_FILE`. When you are running **Rinvex Punnet** on Mac OS the correct file separator to use is `:`. When running Punnet from a Windows environment multiple files must be separated with `;`. 87 | 88 | 89 | 3. Build and run your containers: 90 | 91 | ```shell 92 | docker-compose up -d redis mysql portainer workspace php-fpm nginx 93 | ``` 94 | 95 | **Note**: All the web server containers `nginx` depends on `php-fpm`, which means if you run any of them, they will automatically launch the `php-fpm` container for you, so no need to explicitly specify it in the `up` command. If you have to do so, you may need to run them as follows: `docker-compose up -d nginx php-fpm mysql`. 96 | 97 | *(Please note that sometimes we forget to update the docs, so check the `docker-compose.yml` file to see an updated list of all available containers).* 98 | 99 | 100 | 4. Configure your PHP project to use `mysql` and `redis` service containers. 101 | 102 | Open your PHP project's `.env` file or whichever configuration file you are reading from, and set the database host `DB_HOST` to `mysql`, and `REDIS_HOST` to `redis`: 103 | 104 | ```shell 105 | DB_HOST=mysql 106 | REDIS_HOST=redis 107 | ``` 108 | 109 | 110 | 5. Go to your hosts file `/etc/hosts` and add your local domains: 111 | 112 | ```shell 113 | 127.0.0.1 cortex.rinvex.test 114 | 127.0.0.1 custom-project.test 115 | ``` 116 | 117 | If you use Chrome 63 or above for development, don't use `.dev`. [Why?](https://laravel-news.com/chrome-63-now-forces-dev-domains-https). Instead use `.localhost`, `.invalid`, `.test`, or `.example`. 118 | 119 | 120 | 6. Go to `/PATH/TO/PUNNET/.config/nginx/sites/` and create config files to point to different project directory when visiting different domains. 121 | 122 | **Rinvex Punnet** by default includes `app.conf.example`, `laravel.conf.example` as working samples. NGINX local domain config could be like the following example: 123 | 124 | ```shell 125 | server { 126 | 127 | listen 80; 128 | listen [::]:80; 129 | 130 | server_name .cortex.rinvex.test; 131 | root /var/www/rinvex/cortex/public; 132 | index index.php index.html index.htm; 133 | 134 | location / { 135 | try_files $uri $uri/ /index.php$is_args$args; 136 | } 137 | 138 | location ~ \.php$ { 139 | try_files $uri /index.php =404; 140 | fastcgi_pass php-upstream; 141 | fastcgi_index index.php; 142 | fastcgi_buffering off; 143 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 144 | #fixes timeouts 145 | fastcgi_read_timeout 600; 146 | include fastcgi_params; 147 | } 148 | 149 | location ~ /\.ht { 150 | deny all; 151 | } 152 | 153 | error_log /var/log/nginx/rinvex/cortex/error.log; 154 | access_log /var/log/nginx/rinvex/cortex/access.log; 155 | } 156 | ``` 157 | 158 | You can rename the config files, project folders and local domains as you like, just make sure the `root` in the config files, is pointing to the correct project folder name. 159 | 160 | 161 | 7. To enter the Workspace container, and execute commands like (Artisan, Composer, PHPUnit, ...) 162 | 163 | ```bash 164 | docker-compose exec workspace /bin/bash 165 | ``` 166 | 167 | Some helpful commands: 168 | 169 | ```bash 170 | docker-compose logs CONTAINER_NAME 171 | ``` 172 | 173 | 174 | 8. Now you can browse your local sites in your browser, like: `http://cortex.rinvex.test`. 175 | 176 | 177 | 178 | ## Supported Software (Images) 179 | 180 | In adhering to the separation of concerns principle as promoted by Docker, Punnet runs each software on its own Container. 181 | You can turn On/Off as many instances of as any container without worrying about the configurations, everything works like a charm. 182 | 183 | - **Database Engines:** MySQL 184 | - **Cache Engines:** Redis 185 | - **PHP Servers:** NGINX 186 | - **PHP Compilers:** PHP FPM 187 | - **Random Tools:** Portainer 188 | 189 | Punnet introduces the **Workspace** Image, as a development environment. 190 | It contains a rich set of helpful tools, all pre-configured to work and integrate with almost any combination of Containers and tools you may choose. 191 | 192 | **Workspace Image Tools** 193 | PHP CLI - Composer - Git - Node - SQLite - xDebug - Envoy - Deployer, Laravel installer, PHP codesniffer, PHP CS Fixer, and many more... 194 | 195 | You can choose, which tools to install in your workspace container and other containers, from the `.env` file. 196 | 197 | > If you modify `docker-compose.yml`, `.env` or any `dockerfile` file, you must re-build your containers, to see those effects in the running instance. 198 | 199 | If you can't find your Software in the list, build it yourself and submit it. Contributions are welcomed :) 200 | 201 | 202 | 203 | ## What is Docker? 204 | 205 | [Docker](https://www.docker.com) is an open platform for developing, shipping, and running applications. 206 | Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. 207 | With Docker, you can manage your infrastructure in the same ways you manage your applications. 208 | By taking advantage of Docker’s methodologies for shipping, testing, and deploying code quickly, you can significantly reduce the delay between writing code and running it in production. 209 | 210 | 211 | 212 | ## Why Docker not Vagrant!? 213 | 214 | [Vagrant](https://www.vagrantup.com) creates Virtual Machines in minutes while Docker creates Virtual Containers in seconds. 215 | 216 | Instead of providing a full Virtual Machines, like you get with Vagrant, Docker provides you **lightweight** Virtual Containers, that share the same kernel and allow to safely execute independent processes. 217 | 218 | In addition to the speed, Docker gives tons of features that cannot be achieved with Vagrant. 219 | 220 | Most importantly Docker can run on Development and on Production (same environment everywhere). While Vagrant is designed for Development only, (so you have to re-provision your server on Production every time). 221 | 222 | 223 | ## Changelog 224 | 225 | Refer to the [Changelog](CHANGELOG.md) for a full history of the project. 226 | 227 | 228 | ## Support 229 | 230 | The following support channels are available at your fingertips: 231 | 232 | - [Chat on Slack](https://bit.ly/rinvex-slack) 233 | - [Help on Email](mailto:help@rinvex.com) 234 | - [Follow on Twitter](https://twitter.com/rinvex) 235 | 236 | 237 | ## Contributing & Protocols 238 | 239 | Thank you for considering contributing to this project! The contribution guide can be found in [CONTRIBUTING.md](CONTRIBUTING.md). 240 | 241 | Bug reports, feature requests, and pull requests are very welcome. 242 | 243 | - [Versioning](CONTRIBUTING.md#versioning) 244 | - [Pull Requests](CONTRIBUTING.md#pull-requests) 245 | - [Coding Standards](CONTRIBUTING.md#coding-standards) 246 | - [Feature Requests](CONTRIBUTING.md#feature-requests) 247 | - [Git Flow](CONTRIBUTING.md#git-flow) 248 | 249 | 250 | ## Security Vulnerabilities 251 | 252 | If you discover a security vulnerability within this project, please send an e-mail to [help@rinvex.com](help@rinvex.com). All security vulnerabilities will be promptly addressed. 253 | 254 | 255 | ## About Rinvex 256 | 257 | Rinvex is a software solutions startup, specialized in integrated enterprise solutions for SMEs established in Alexandria, Egypt since June 2016. We believe that our drive The Value, The Reach, and The Impact is what differentiates us and unleash the endless possibilities of our philosophy through the power of software. We like to call it Innovation At The Speed Of Life. That’s how we do our share of advancing humanity. 258 | 259 | 260 | ## License 261 | 262 | This software is released under [The MIT License (MIT)](LICENSE). 263 | 264 | (c) 2016-2020 Rinvex LLC, Some rights reserved. 265 | --------------------------------------------------------------------------------