diff --git a/.editorconfig b/.editorconfig index 077fa1b..978c784 100755 --- a/.editorconfig +++ b/.editorconfig @@ -13,3 +13,6 @@ indent_size = 2 [*.yaml.j2] indent_size = 2 + +[Makefile] +indent_style = tab diff --git a/.ansible-lint b/.github/.ansible-lint.yml similarity index 70% rename from .ansible-lint rename to .github/.ansible-lint.yml index 24b9671..e2f880a 100644 --- a/.ansible-lint +++ b/.github/.ansible-lint.yml @@ -5,4 +5,8 @@ skip_list: - experimental +exclude_paths: + - ./contrib + - ./.venv + ... diff --git a/.github/.commitlint.config.mjs b/.github/.commitlint.config.mjs new file mode 100644 index 0000000..49f1f95 --- /dev/null +++ b/.github/.commitlint.config.mjs @@ -0,0 +1,44 @@ +// More info: https://github.com/wayofdev/npm-shareable-configs/blob/master/packages/commitlint-config/src/index.js +const automaticCommitPattern = /^chore\(release\):.*\[skip ci]/ + +export default { + extends: ['@commitlint/config-conventional'], + /* + This resolves a linting conflict between commitlint's body-max-line-length + due to @semantic-release/git putting release notes in the commit body + https://github.com/semantic-release/git/issues/331 + */ + ignores: [(commitMessage) => automaticCommitPattern.test(commitMessage)], + rules: { + 'body-leading-blank': [1, 'always'], + 'body-max-line-length': [2, 'always', 120], + 'footer-leading-blank': [1, 'always'], + 'footer-max-line-length': [2, 'always', 120], + 'header-max-length': [2, 'always', 100], + 'scope-case': [2, 'always', 'lower-case'], + 'subject-case': [2, 'never', ['sentence-case', 'start-case', 'pascal-case', 'upper-case']], + 'subject-empty': [2, 'never'], + 'subject-full-stop': [2, 'never', '.'], + 'type-case': [2, 'always', 'lower-case'], + 'type-empty': [2, 'never'], + 'type-enum': [ + 2, + 'always', + [ + 'feat', // New feature + 'fix', // Bug fix + 'perf', // Performance improvement + 'docs', // Documentation changes + 'style', // Code style update (formatting, missing semi colons, etc) + 'deps', // Dependency updates + 'refactor', // Code refactoring + 'ci', // Continuous integration changes + 'test', // Adding missing tests + 'revert', // Revert to a previous commit + 'build', // Changes that affect the build system + 'chore', // Other changes that don't modify src or test files + 'security', // Security improvements + ], + ], + }, +} diff --git a/.github/.cz.config.js b/.github/.cz.config.js new file mode 100644 index 0000000..5f951c6 --- /dev/null +++ b/.github/.cz.config.js @@ -0,0 +1,65 @@ +// @see https://cz-git.qbb.sh/config/#configure-template +module.exports = { + alias: { fd: 'docs: fix typos' }, + messages: { + type: 'Select the type of change that you\'re committing:', + scope: 'Denote the SCOPE of this change (optional):', + customScope: 'Denote the SCOPE of this change:', + subject: 'Write a SHORT, IMPERATIVE tense description of the change:\n', + body: 'Provide a LONGER description of the change (optional). Use "|" to break new line:\n', + breaking: 'List any BREAKING CHANGES (optional). Use "|" to break new line:\n', + footerPrefixesSelect: 'Select the ISSUES type of changeList by this change (optional):', + customFooterPrefix: 'Input ISSUES prefix:', + footer: 'List any ISSUES by this change. E.g.: #31, #34:\n', + generatingByAI: 'Generating your AI commit subject...', + generatedSelectByAI: 'Select suitable subject by AI generated:', + confirmCommit: 'Are you sure you want to proceed with the commit above?' + }, + types: [ + { value: 'feat', name: 'feat: A new feature', emoji: ':sparkles:' }, + { value: 'fix', name: 'fix: A bug fix', emoji: ':bug:' }, + { value: 'perf', name: 'perf: A code change that improves performance', emoji: ':zap:' }, + { value: 'docs', name: 'docs: Documentation only changes', emoji: ':memo:' }, + { value: 'style', name: 'style: Changes that do not affect the meaning of the code', emoji: ':lipstick:' }, + { value: 'deps', name: 'deps: A dependency update', emoji: ':package:' }, + { value: 'refactor', name: 'refactor: A code change that neither fixes a bug nor adds a feature', emoji: ':recycle:' }, + { value: 'ci', name: 'ci: Changes to our CI configuration files and scripts', emoji: ':ferris_wheel:' }, + { value: 'test', name: 'test: Adding missing tests or correcting existing tests', emoji: ':white_check_mark:' }, + { value: 'revert', name: 'revert: Reverts a previous commit', emoji: ':rewind:' }, + { value: 'build', name: 'build: Changes that affect the build system or external dependencies', emoji: ':package:' }, + { value: 'chore', name: 'chore: Other changes that don\'t modify src or test files', emoji: ':hammer:' }, + { value: 'security', name: 'security: A code change that fixes a security issue', emoji: ':lock:' } + ], + useEmoji: false, + emojiAlign: 'center', + useAI: false, + aiNumber: 1, + themeColorCode: '', + scopes: [], + allowCustomScopes: true, + allowEmptyScopes: true, + customScopesAlign: 'bottom', + customScopesAlias: 'custom', + emptyScopesAlias: 'empty', + upperCaseSubject: false, + markBreakingChangeMode: false, + allowBreakingChanges: ['feat', 'fix'], + breaklineNumber: 100, + breaklineChar: '|', + skipQuestions: [], + issuePrefixes: [{ value: 'closed', name: 'closed: ISSUES has been processed' }], + customIssuePrefixAlign: 'top', + emptyIssuePrefixAlias: 'skip', + customIssuePrefixAlias: 'custom', + allowCustomIssuePrefix: true, + allowEmptyIssuePrefix: true, + confirmColorize: true, + maxHeaderLength: Infinity, + maxSubjectLength: Infinity, + minSubjectLength: 0, + scopeOverrides: undefined, + defaultBody: '', + defaultIssues: '', + defaultScope: '', + defaultSubject: '' +} diff --git a/.github/.hadolint.yaml b/.github/.hadolint.yaml new file mode 100644 index 0000000..17ad135 --- /dev/null +++ b/.github/.hadolint.yaml @@ -0,0 +1,7 @@ +--- + +trustedRegistries: + - docker.io + - "*.gcr.io" + +... diff --git a/.github/.markdownlint.json b/.github/.markdownlint.json new file mode 100644 index 0000000..77f382d --- /dev/null +++ b/.github/.markdownlint.json @@ -0,0 +1,7 @@ +{ + "$schema": "https://raw.githubusercontent.com/DavidAnson/markdownlint/main/schema/markdownlint-config-schema.json", + "line-length": false, + "no-inline-html": false, + "first-line-h1": false, + "no-duplicate-heading": false +} diff --git a/.github/.release-please-config.json b/.github/.release-please-config.json new file mode 100644 index 0000000..4ac7ad6 --- /dev/null +++ b/.github/.release-please-config.json @@ -0,0 +1,73 @@ +{ + "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json", + "release-type": "php", + "packages": { + ".": { + "package-name": "docker-nginx", + "changelog-path": "/CHANGELOG.md" + } + }, + "include-component-in-tag": false, + "changelog-sections": [ + { + "type": "feat", + "section": "Features", + "hidden": false + }, + { + "type": "fix", + "section": "Bug Fixes", + "hidden": false + }, + { + "type": "perf", + "section": "Performance Improvements", + "hidden": false + }, + { + "type": "docs", + "section": "Documentation", + "hidden": false + }, + { + "type": "deps", + "section": "Dependencies", + "hidden": false + }, + { + "type": "refactor", + "section": "Code Refactoring", + "hidden": false + }, + { + "type": "test", + "section": "Tests", + "hidden": true + }, + { + "type": "build", + "section": "Build System", + "hidden": true + }, + { + "type": "ci", + "section": "Continuous Integration", + "hidden": true + }, + { + "type": "chore", + "section": "Miscellaneous", + "hidden": true + }, + { + "type": "style", + "section": "Styles", + "hidden": true + }, + { + "type": "revert", + "section": "Reverts", + "hidden": true + } + ] +} diff --git a/.github/.release-please-manifest.json b/.github/.release-please-manifest.json new file mode 100644 index 0000000..ce276fa --- /dev/null +++ b/.github/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "1.4.1" +} diff --git a/.github/.yamllint.yaml b/.github/.yamllint.yaml new file mode 100644 index 0000000..d9d0fed --- /dev/null +++ b/.github/.yamllint.yaml @@ -0,0 +1,57 @@ +--- + +extends: default + +rules: + braces: + # Defaults + # min-spaces-inside: 0 + # max-spaces-inside: 0 + + # Keep 0 min-spaces to not error on empty {} collection definitions + min-spaces-inside: 0 + + # Allow one space inside braces to improve code readability + max-spaces-inside: 1 + + brackets: + # Defaults + # min-spaces-inside: 0 + # max-spaces-inside: 0 + + # Keep 0 min-spaces to not error on empty [] collection definitions + min-spaces-inside: 0 + + # Allow one space inside braces to improve code readability + max-spaces-inside: 1 + + colons: + # Defaults + # min-spaces-before: 0 + # max-spaces-after: 1 + + # Allow multiple spaces after a colon to allow indentation of YAML + # dictionary values + max-spaces-after: -1 + + commas: + # Defaults + # max-spaces-after: 1 + + # Allow multiple spaces after a comma to allow indentation of YAML + # dictionary values + max-spaces-after: -1 + + comments: + require-starting-space: true + min-spaces-from-content: 1 + + comments-indentation: false + + line-length: disable + + octal-values: + forbid-implicit-octal: true + forbid-explicit-octal: true + +... diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..98af7f9 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,3 @@ +# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners + +* @lotyp diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..804d96c --- /dev/null +++ b/.github/CODE_OF_CONDUCT.md @@ -0,0 +1,128 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, religion, or sexual identity +and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the + overall community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or + advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email + address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series +of actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or +permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within +the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.0, available at +. + +Community Impact Guidelines were inspired by [Mozilla's code of conduct +enforcement ladder](https://github.com/mozilla/diversity). + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see the FAQ at +. Translations are available at +. diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000..5c91abe --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,334 @@ +# Contributing + +Welcome to the docker-nginx project! + +We appreciate your interest in contributing. This guide will help you get started, ensuring an effective collaboration. + +## ๐Ÿ—‚ Table of Contents + +* [Introduction](#-introduction) +* [Development Requirements](#-development-requirements) +* [Quick Project Setup](#-quick-project-setup) +* [Using the Makefile](#-using-the-makefile) +* [Workflow](#-workflow) +* [Docker Support](#-docker-support) +* [Continuous Integration with GitHub Actions](#-continuous-integration-with-github-actions) +* [Before You Contribute](#-before-you-contribute) +* [Commit Message Guidelines](#-commit-message-guidelines) +* [Coding Standards](#-coding-standards) +* [Tests](#-tests) +* [Pre-commit Hooks](#-pre-commit-hooks) + +
+ +## ๐Ÿ‘‹ Introduction + +If you would like to contribute, please **open an issue** or a pull request. We are always looking for ways to improve the project and would love to hear your ideas. + +The latest changes are always in the **`master`** branch, so please make your Pull Request against that branch. + +
+ +## ๐Ÿšฉ Development Requirements + +Before you begin, you will need to set up your local development environment. Here is what you'll need: + +* **Operating System**: macOS Monterey+, Linux, or Windows with WSL2. +* **Docker**: Version 26.0.0 or newer. +* **Ansible**: For generating Dockerfiles and configurations. +* **goss and dgoss**: For testing Docker images. + +Optional tools: + +* **Pre-commit**: For running git pre-commit hooks. +* **Cz-git**: For formatting git commits. + +
+ +## ๐Ÿš€ Quick Project Setup + +Clone the repository: + +```bash +git clone git@github.com:wayofdev/docker-nginx.git && \ +cd docker-nginx +``` + +
+ +## ๐Ÿ”ง Using the Makefile + +This project uses a Makefile to streamline common development tasks. To see available commands, run: + +```bash +make help +``` + +![Screenshot](./assets/screenshot.png) + +Key commands include: + +* `make generate`: Generates Dockerfiles from Ansible templates. +* `make build`: Builds the Docker image. +* `make test`: Runs tests on the Docker image. +* `make lint`: Executes all linting procedures. +* `make lint-yaml`: Lints YAML files. +* `make lint-docker`: Lints Dockerfiles. +* `make lint-ansible`: Lints Ansible files. +* `make analyze`: Analyzes the Docker image using dive. +* `make commit`: Runs cz-git, a commitizen adapter for commit message formatting in a native environment. + +
+ +## ๐Ÿ’ป Workflow + +> [!IMPORTANT] +> +> Please feature/fix/update... into individual PRs (not one changing everything) + +* **Fork the Repository**: Start by forking the repository to your GitHub account. +* **Create a Branch**: In your fork, create a new branch for your work. Name it appropriately based on the feature, fix, or update you're working on. +* **Make Your Changes**: Implement your changes +* **Run Tests**: Ensure all tests pass by running `make test`. +* **Update Documentation**: If you've made changes that affect the project's documentation, ensure it is updated. +* **Run Linters**: Ensure your code passes all linting checks using `make lint`. +* **Commit Your Changes**: Use the [Conventional Commits](#-commit-message-guidelines) standard for your commit messages. You can use `make commit` to assist in creating commit messages. +* **Push Your Changes**: Push your branch to your fork on GitHub. +* **Open a Pull Request**: Submit a pull request to the `master` branch of the original repository. Ensure your PR is focused, addressing a single feature, fix, or improvement. + +
+ +## ๐Ÿณ Docker Support + +This project heavily relies on Docker. To build and test images: + +```bash +make build +make test +``` + +
+ +## ๐Ÿ”จ Continuous Integration with GitHub Actions + +Our project employs [GitHub Actions](https://github.com/features/actions) for continuous integration, ensuring code quality and reliability. We encourage contributors to review our workflow configurations to understand the CI processes: + +| Workflow | Description | +|--------------------------------------------------------------|--------------------------------------------------------------| +| [`apply-labels.yml`](workflows/apply-labels.yml) | Auto labels PRs based on rules. | +| [`auto-merge-release.yml`](workflows/auto-merge-release.yml) | Automatically merges release PRs. | +| [`build.yml`](workflows/build.yml) | Builds Docker images. | +| [`coding-standards.yml`](workflows/coding-standards.yml) | Checks `yaml`, `md`, `composer` and commit coding standards. | +| [`create-release.yml`](workflows/create-release.yml) | Creates a release on GitHub. | +| [`merge.yml`](workflows/merge.yml) | Automatically merges PRs. | +| [`shellcheck.yml`](workflows/shellcheck.yml) | Checks shell scripts. | +| [`test.yml`](workflows/test.yml) | Runs tests on Docker images. | +| [`upload-assets.yml`](workflows/upload-assets.yml) | Uploads dist assets to GitHub releases. | + +
+ +## ๐Ÿ“ Before You Contribute + +* **Tests**: Include tests that cover any new features or bug fixes. +* **Code Quality**: Utilize `make lint` for code style checks. +* **Documentation**: Update relevant documentation to reflect your changes, ensuring other developers can understand and use your contributions effectively. +* **Commits**: use Conventional Commits standard to create a commit + +
+ +## ๐Ÿ“ฉ Commit Message Guidelines + +We follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) standard. Please structure your commit messages as follows, using the appropriate prefix: + +**Examples:** + +```bash +git commit -am 'feat: some feature was introduced' +git commit -am 'fix: something has been fixed' +``` + +**Allowed Prefixes:** + +| Prefix | Purpose | +|-------------|---------------------------------------------------------------| +| `feat:` | Introduces a new feature | +| `fix:` | Fixes a bug | +| `perf:` | Improves performance | +| `docs:` | Documentation only changes | +| `style:` | Code style changes (formatting, missing semi-colons, etc.) | +| `deps:` | Updates dependencies | +| `refactor:` | Code changes that neither fixes a bug nor adds a feature | +| `ci:` | Changes to our CI configuration files and scripts | +| `test:` | Adding missing tests or correcting existing tests | +| `revert:` | Reverts a previous commit | +| `build:` | Changes that affect the build system or external dependencies | +| `chore:` | Other changes that don't modify src or test files | +| `security:` | A code change that fixes a security issue | + +
+ +## ๐Ÿ” Coding Standards + +We use various tools to maintain code quality: + +* YAML Lint for YAML files +* Hadolint for Dockerfiles +* Ansible Lint for Ansible files + +Run `make lint-yaml`, `make lint-docker`, and `make lint-ansible` to check your code. + +Here's a list of tools we use: + +### โ†’ Yaml Lint + +We use [`yamllint`](https://github.com/adrienverge/yamllint) to enforce coding standards in YAML files. + +To lint yaml files run: + +```bash +make lint-yaml +``` + +by default, [`cytopia/yamllint`](https://github.com/cytopia/docker-yamllint) Docker image will be used to run linter. + +### โ†’ Action Lint + +We use [`actionlint`](https://github.com/rhysd/actionlint) to enforce coding standards in GitHub Actions workflows. + +To lint GitHub Actions run: + +```bash +make lint-actions +``` + +by default, [`rhysd/actionlint`](https://hub.docker.com/r/rhysd/actionlint/tags) Docker image will be used to run linter. + +### โ†’ Markdown Lint + +We use [`markdownlint-cli2`](https://github.com/davidanson/markdownlint-cli2) to enforce coding standards in Markdown files. + +To lint markdown files run: + +```bash +make lint-md-dry +make lint-md +``` + +### โ†’ Ansible Lint + +We use [`ansible-lint`](https://github.com/ansible/ansible-lint) to check Ansible playbooks for practices and behavior that could potentially be improved. + +To lint Ansible files, run: + +```bash +make lint-ansible +``` + +
+ +## ๐Ÿงช Tests + +We use [goss](https://github.com/goss-org/goss) and [dgoss](https://github.com/aelsabbahy/goss/tree/master/extras/dgoss) for testing our Docker images. These tools allow us to validate the state and behavior of our containers. + +### โ†’ Running Tests + +To run tests on the Docker images, use the following command: + +```bash +make test +``` + +This command will build the default image (specified by the `IMAGE_TEMPLATE` variable in the Makefile) and run the goss tests against it. + +### โ†’ Testing Specific Images + +To test a specific image variant, you can specify the `IMAGE_TEMPLATE` variable: + +```bash +make test IMAGE_TEMPLATE="8.3-fpm-alpine" +``` + +Replace `8.3-fpm-alpine` with the desired PHP version, type, and OS. + +### โ†’ Testing All Images + +To test all supported image variants, run: + +```bash +make test IMAGE_TEMPLATE="8.1-cli-alpine" +make test IMAGE_TEMPLATE="8.1-fpm-alpine" +make test IMAGE_TEMPLATE="8.1-supervisord-alpine" +make test IMAGE_TEMPLATE="8.2-cli-alpine" +make test IMAGE_TEMPLATE="8.2-fpm-alpine" +make test IMAGE_TEMPLATE="8.2-supervisord-alpine" +make test IMAGE_TEMPLATE="8.3-cli-alpine" +make test IMAGE_TEMPLATE="8.3-fpm-alpine" +make test IMAGE_TEMPLATE="8.3-supervisord-alpine" +``` + +### โ†’ Test Configuration + +The goss test configurations are generated from a Jinja2 template located at `src/Dockerfiles/base/goss.yaml.j2`. This template is used by Ansible to generate specific test configurations for each PHP version, type, and OS combination. + +### โ†’ Writing and Updating Tests + +When contributing new features or making changes, please update the `src/Dockerfiles/base/goss.yaml.j2` file. This Jinja2 template defines the tests that will be generated for all image variants. When editing this file: + +1. Use Jinja2 syntax for dynamic content that should change based on PHP version, type, or OS. +2. Ensure your tests cover: + * Presence and correctness of installed PHP extensions + * Proper configuration of PHP and its extensions + * Correct functioning of the PHP environment (CLI, FPM, or Supervisord) + * Any additional features or configurations specific to your changes + +After updating the template, regenerate the Dockerfiles and test configurations: + +```bash +make generate +``` + +This command will use Ansible to process the updated template and generate new test configurations for all image variants. + +### โ†’ Continuous Integration + +Our GitHub Actions workflow (`test.yml`) automatically runs these tests for each pull request and push to the main branch. Ensure that all tests pass in your local environment before submitting a pull request. + +Remember, thorough testing is crucial for maintaining the reliability and consistency of our Docker images across different PHP versions and configurations. By updating the central Jinja2 template, we ensure consistency across all our image variants. + +
+ +## ๐Ÿ“ฆ Pre-commit Hooks + +Pre-commit hooks are an optional but highly recommended way to automate the linting and quality checks before committing changes to the repository. This project provides a predefined configuration that helps in maintaining code quality and consistency. + +### โ†’ Configured Hooks + +Our pre-commit configuration includes several hooks: + +* **Trailing Whitespace**: Removes unnecessary trailing spaces. +* **End-of-File Fixer**: Ensures that files end with a newline. +* **Fix Encoding Pragma**: Adds or removes the coding pragma line at the top of Python files. +* **Check Added Large Files**: Prevents accidentally adding large files to the git repository, with a current limit set to 600 KB. +* **YAML Lint**: Checks YAML files for syntax errors and enforces coding standards using a custom configuration. +* **Commitizen**: Ensures commit messages meet the conventional commit format. This hook is triggered at the commit message stage. +* **Action Validator**: Validates GitHub Actions workflow files. +* **Ansible Lint**: Checks Ansible playbooks for practices and behavior that could potentially be improved. +* **Ansible Role Checks**: Several hooks to find issues in Ansible roles: + * Find unused variables + * Find empty files + * Find empty directories + * Fix readability issues + * Find undefined handlers + * Find unquoted values + +These hooks help maintain code quality, consistency, and prevent common issues before they are committed to the repository. + +### โ†’ Installing Pre-commit Hooks + +To utilize these hooks, you first need to install them using the command provided by the Makefile: + +```bash +make hooks +``` + +
diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..1d7f6ba --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,5 @@ +--- + +github: wayofdev + +... diff --git a/.github/ISSUE_TEMPLATE/1-bug-report.yml b/.github/ISSUE_TEMPLATE/1-bug-report.yml new file mode 100644 index 0000000..dd57932 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/1-bug-report.yml @@ -0,0 +1,105 @@ +--- + +name: ๐Ÿž Bug Report +description: Report an issue to help the project improve. +title: '[Bug]: ' +labels: ['type: bug'] + +assignees: + - lotyp + +body: + - type: markdown + attributes: + value: ๐Ÿž **Bug Report** + + - type: textarea + id: bug-description + attributes: + label: Describe the bug + description: Please provide a clear and detailed description of what the bug is. This helps us understand the issue quickly and look for potential fixes. + placeholder: Explain the bug in as much detail as possible... + validations: + required: true + + - type: textarea + id: regression + attributes: + label: Is this a regression? + description: | + Was this functionality working in a previous version? + If yes, please mention the last version in which it worked properly. + Understanding regressions helps prioritize fixes. + placeholder: Yes or No, and details about the last working version... + validations: + required: false + + - type: textarea + id: steps-to-reproduce + attributes: + label: To Reproduce + description: | + 'Please provide step-by-step instructions that reproduce the issue: + 1. Use x argument / navigate to... + 2. Fill this information... + 3. Go to... + 4. See error + placeholder: Detailed steps to reproduce the bug... + validations: + required: true + + - type: textarea + id: expected-behaviour + attributes: + label: Expected behaviour + description: | + Describe what you expected to happen. + Clear expectations help understand the gap between current and desired states. + placeholder: What did you expect to happen instead of the bug? + validations: + required: true + + - type: textarea + id: media + attributes: + label: Media prove + description: If applicable, add screenshots or videos to better illustrate the issue. Visual aids can significantly aid in diagnosing problems quicker. + placeholder: Upload files or paste links here... + validations: + required: false + + - type: textarea + id: environment + attributes: + label: Your environment + description: | + Provide detailed information about your environment to help us replicate the issue: + * OS: [e.g. Ubuntu] + * PHP version: [e.g. 8.2.2] + * Package version: [e.g. 1.0.0] + * Any relevant environment details + placeholder: List your environment details here... + validations: + required: false + + - type: textarea + id: additional-context + attributes: + label: Additional context + description: Include any other context about the problem here, such as unusual system configurations, previous issues, or possible causes. + placeholder: Any additional information that could help us resolve the issue... + validations: + required: false + + - type: markdown + attributes: + value: | + ๐Ÿ“› To ensure a smooth issue processing, please check if a similar bug report has already been submitted before creating a new one. + We highly value your contributions, so please make sure to familiarize yourself with our repository's guidelines: + - [Code of Conduct](https://github.com/wayofdev/docker-nginx/blob/master/.github/CODE_OF_CONDUCT.md) + - [Contribution Guidelines](https://github.com/wayofdev/docker-nginx/blob/master/.github/CONTRIBUTING.md) + + Additionally, consider joining our discussions on: + - [WayOfDev Discord Community](https://discord.gg/CE3TcCC5vr) + +... diff --git a/.github/ISSUE_TEMPLATE/2-feature-request.yml b/.github/ISSUE_TEMPLATE/2-feature-request.yml new file mode 100644 index 0000000..01187dd --- /dev/null +++ b/.github/ISSUE_TEMPLATE/2-feature-request.yml @@ -0,0 +1,75 @@ +--- + +name: ๐Ÿš€ Feature Request +description: Suggest an idea or possible new feature for this project. +title: '[Feature]: ' +labels: ['type: enhancement'] + +assignees: + - lotyp + +body: + - type: markdown + attributes: + value: ๐Ÿš€ **Feature Request** + + - type: textarea + id: problem-related + attributes: + label: Is your feature request related to a problem? Please describe. + description: | + Please provide a clear and detailed description of what the problem is. + For example, 'I'm always frustrated when...'. + This will help us understand the context and the impact of the problem. + placeholder: Describe the problem... + validations: + required: true + + - type: textarea + id: desired-solution + attributes: + label: "Describe the solution you'd like" + description: | + What would you like to see happen? Please provide a detailed explanation of the desired feature. + You may include bullet points to outline objectives, key activities, and expected outcomes. + placeholder: | + 1. Objective: [What you hope to achieve with this feature] + 2. Key Activities: [Steps to implement the feature] + 3. Expected Outcome: [Benefits and results of the feature] + validations: + required: true + + - type: textarea + id: alternative-solutions + attributes: + label: "Describe alternatives you've considered" + description: | + Are there alternative solutions or features you've considered? Please describe them. + Understanding different possible solutions can help in finding the best path forward. + placeholder: Describe any alternative solutions or workarounds you have considered... + validations: + required: false + + - type: textarea + id: additional-context + attributes: + label: Additional context + description: | + Add any other context or screenshots about the feature request here. + Links to similar features, or visual aids that support your proposal, if applicable. + placeholder: Insert any additional context or links to similar features here... + validations: + required: false + + - type: markdown + attributes: + value: | + ๐Ÿ“› To ensure a smooth issue processing, please check if a similar feature request has already been submitted before creating a new one. + We highly value your contributions, so please make sure to familiarize yourself with our repository's guidelines: + - [Code of Conduct](https://github.com/wayofdev/docker-nginx/blob/master/.github/CODE_OF_CONDUCT.md) + - [Contribution Guidelines](https://github.com/wayofdev/docker-nginx/blob/master/.github/CONTRIBUTING.md) + + Additionally, consider joining our discussions on: + - [WayOfDev Discord Community](https://discord.gg/CE3TcCC5vr) + +... diff --git a/.github/ISSUE_TEMPLATE/3-failing-test.yml b/.github/ISSUE_TEMPLATE/3-failing-test.yml new file mode 100644 index 0000000..10b005d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/3-failing-test.yml @@ -0,0 +1,63 @@ +--- + +name: ๐Ÿงช Failing Test +description: Report failing tests or CI jobs. +title: '[Test]: ' +labels: ['type: test'] + +assignees: + - lotyp + +body: + - type: markdown + attributes: + value: ๐Ÿงช **Failing Test** + + - type: textarea + id: failing-tests + attributes: + label: Which jobs/test(s) are failing + description: Please specify which CI jobs or tests are failing. Include test names or job identifiers. + placeholder: List the failing jobs or tests here... + validations: + required: true + + - type: textarea + id: reason-for-failure + attributes: + label: Reason for failure/description + description: Explain why the test is failing or what might be missing to make it pass. If available, include error messages or output logs. + placeholder: Provide details on why the test is failing, including error logs or output messages... + validations: + required: true + + - type: textarea + id: media-prove + attributes: + label: Media prove + description: If applicable, add screenshots, videos, or links to logs that help explain the issue. Visual aids can be very helpful in diagnosing problems. + placeholder: Upload files or paste links here... + validations: + required: false + + - type: textarea + id: additional-context + attributes: + label: Additional context + description: Add any other context about the problem, such as related issues, recent changes, or environmental specifics that might influence the test outcome. + placeholder: Include any other relevant information that might help understand the issue... + validations: + required: false + + - type: markdown + attributes: + value: | + ๐Ÿ“› To ensure a smooth issue processing, please check if a similar bug report has already been submitted before creating a new one. + We highly value your contributions, so please make sure to familiarize yourself with our repository's guidelines: + - [Code of Conduct](https://github.com/wayofdev/docker-nginx/blob/master/.github/CODE_OF_CONDUCT.md) + - [Contribution Guidelines](https://github.com/wayofdev/docker-nginx/blob/master/.github/CONTRIBUTING.md) + + Additionally, consider joining our discussions on: + - [WayOfDev Discord Community](https://discord.gg/CE3TcCC5vr) + +... diff --git a/.github/ISSUE_TEMPLATE/4-docs-bug-report.yml b/.github/ISSUE_TEMPLATE/4-docs-bug-report.yml new file mode 100644 index 0000000..9733a7a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/4-docs-bug-report.yml @@ -0,0 +1,79 @@ +--- + +name: ๐Ÿ“š Documentation or README.md issue report +description: Report an issue in the project's documentation or README.md file. +title: '[Docs]: ' +labels: ['type: documentation', 'type: maintenance'] + +assignees: + - lotyp + +body: + - type: markdown + attributes: + value: ๐Ÿ“š **Documentation Issue Report** + + - type: textarea + id: documentation-bug-description + attributes: + label: Describe the bug + description: Provide a clear and concise description of what the error or issue is in the documentation. + placeholder: Explain the issue with the documentation... + validations: + required: true + + - type: textarea + id: steps-to-reproduce + attributes: + label: To Reproduce + description: | + Please provide steps to reproduce the error in the documentation: + 1. Navigate to the section or URL where the error occurs... + 2. Specify the misleading or incorrect information... + 3. Suggest what is expected if applicable... + placeholder: | + 1. URL or Section... + 2. Misleading information... + 3. Expected correction... + validations: + required: true + + - type: textarea + id: media-prove + attributes: + label: Media prove + description: If applicable, add screenshots or videos to better illustrate the issue with the documentation. + placeholder: Upload files or paste links here... + validations: + required: false + + - type: textarea + id: desired-solution + attributes: + label: Describe the solution you would like + description: Describe what changes or improvements you would like to see in the documentation. + placeholder: Describe the desired changes or improvements... + validations: + required: true + + - type: textarea + id: additional-context + attributes: + label: Additional context + description: Add any other context or additional information that could help clarify the documentation issue. + placeholder: Provide any additional context here... + validations: + required: false + + - type: markdown + attributes: + value: | + ๐Ÿ“› To ensure a smooth issue processing, please check if a similar bug report has already been submitted before creating a new one. + We highly value your contributions, so please make sure to familiarize yourself with our repository's guidelines: + - [Code of Conduct](https://github.com/wayofdev/docker-nginx/blob/master/.github/CODE_OF_CONDUCT.md) + - [Contribution Guidelines](https://github.com/wayofdev/docker-nginx/blob/master/.github/CONTRIBUTING.md) + + Additionally, consider joining our discussions on: + - [WayOfDev Discord Community](https://discord.gg/CE3TcCC5vr) + +... diff --git a/.github/ISSUE_TEMPLATE/5-security-report.yml b/.github/ISSUE_TEMPLATE/5-security-report.yml new file mode 100644 index 0000000..15ec676 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/5-security-report.yml @@ -0,0 +1,35 @@ +--- + +name: โš ๏ธ Security Report +description: Please report security issues directly through GitHub Security Advisories to ensure privacy. +title: '[Security]: ' +labels: ['type: bug', 'priority: high', 'type: security'] + +assignees: + - lotyp + +body: + - type: markdown + attributes: + value: > + โš ๏ธ **Please DO NOT report security vulnerabilities here.** Instead, use the GitHub Security Advisories feature to report them privately and securely. This helps us address issues responsibly without exposing them publicly. + + - type: markdown + attributes: + value: > + GitHub Advisories do not automatically notify maintainers, so by using the advisories, you help maintain confidentiality while ensuring the issue is documented and tracked properly. + + - type: markdown + attributes: + value: 'To create a new advisory, go to: [Create Security Advisory](https://github.com/wayofdev/docker-nginx/security/advisories/new)' + + - type: textarea + id: github-advisory-url + attributes: + label: Your GitHub Advisory URL + description: Optionally, you can paste the URL of the GitHub Security Advisory you have created here for reference. + placeholder: Paste the GitHub Security Advisory URL here... + validations: + required: false + +... diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..a183414 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,14 @@ +--- + +blank_issues_enabled: true + +contact_links: + - name: Start a discussion or ask a question. + url: https://github.com/wayofdev/.github/discussions + about: Please ask and answer questions here. + + - name: Join our Discord Community + url: https://discord.gg/CE3TcCC5vr + about: Join our Discord community to get help, share your ideas, and chat with other developers. + +... diff --git a/.github/SECURITY.md b/.github/SECURITY.md new file mode 100644 index 0000000..84c1189 --- /dev/null +++ b/.github/SECURITY.md @@ -0,0 +1,25 @@ +# Security Policy + +Thank you for helping keep `wayofdev/docker-nginx` and its users safe. We greatly appreciate your efforts to disclose security vulnerabilities responsibly. + +
+ +## ๐Ÿšจ Reporting a Vulnerability + +We take all security bugs in `wayofdev/docker-nginx` seriously. Please follow the instructions below to report security vulnerabilities. + +### โ†’ How to Report a Vulnerability + +1. **GitHub Security Advisories**: Please report security issues directly through our GitHub Security Advisories page: [https://github.com/wayofdev/docker-nginx/security/advisories/new](https://github.com/wayofdev/docker-nginx/security/advisories/new). This ensures that sensitive information is handled confidentially. + +2. **Empty Security Issue**: After submitting through GitHub Security Advisories, please also create an empty security issue to alert us, as GitHub Advisories do not send automatic notifications. This can be done [here](https://github.com/wayofdev/docker-nginx/issues/new?assignees=&labels=type%3A+bug%2Cpriority%3A+high%2Ctype%3A+security&projects=&template=5-security-report.yml&title=%5BSecurity%5D%3A+). + +3. **Direct Contact**: For highly sensitive information, in addition to the GitHub Security Advisories, please email us directly at `the@wayof.dev` with the subject line "SECURITY - Vulnerability Report". This will be treated with the highest priority. + +Please do not discuss potential security issues in public forums or through our public GitHub issues tracker. + +## โŒ Third-Party Bug Bounty Platforms + +At this moment, we DO NOT accept reports from third-party bug bounty platforms to minimize risk. All vulnerability reports should come through the specified channels above. + +
diff --git a/.github/assets/screenshot.png b/.github/assets/screenshot.png new file mode 100644 index 0000000..433421f Binary files /dev/null and b/.github/assets/screenshot.png differ diff --git a/.github/labeler.yml b/.github/labeler.yml index af814de..658176f 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -3,12 +3,18 @@ # this file is for the labeler workflow job # Documentation https://github.com/marketplace/actions/labeler +"type: bug": + - head-branch: ['^bug', '^fix', 'bug', 'fix'] + +"type: enhancement": + - head-branch: ['^feature', '^feat', 'feature'] + "type: documentation": - - assets/**/* - - .github/* - - ./*.md + - changed-files: + - any-glob-to-any-file: ['assets/**/*', '.github/*.yml', './*.md'] "type: maintenance": - - .github/workflows/* + - changed-files: + - any-glob-to-any-file: ['.github/workflows/*'] ... diff --git a/.github/renovate.json b/.github/renovate.json new file mode 100644 index 0000000..0e44fa8 --- /dev/null +++ b/.github/renovate.json @@ -0,0 +1,16 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "config:base", + ":semanticCommitTypeAll(deps)" + ], + "prHourlyLimit": 0, + "automerge": true, + "platformAutomerge": true, + "lockFileMaintenance": { + "enabled": true, + "automerge": true, + "automergeType": "pr", + "platformAutomerge": true + } +} diff --git a/.github/workflows/apply-labels.yml b/.github/workflows/apply-labels.yml index c9b1196..06bc8ed 100644 --- a/.github/workflows/apply-labels.yml +++ b/.github/workflows/apply-labels.yml @@ -8,13 +8,15 @@ # https://github.com/actions/labeler/blob/master/README.md on: # yamllint disable-line rule:truthy - pull_request: + pull_request_target: + types: + - opened name: ๐Ÿท๏ธ Add labels jobs: label: - uses: wayofdev/gh-actions/.github/workflows/apply-labels.yml@master + uses: wayofdev/gh-actions/.github/workflows/apply-labels.yml@v3.2.0 with: os: ubuntu-latest secrets: diff --git a/.github/workflows/auto-merge-release.yaml b/.github/workflows/auto-merge-release.yaml index 084a3e1..932e82e 100644 --- a/.github/workflows/auto-merge-release.yaml +++ b/.github/workflows/auto-merge-release.yaml @@ -4,6 +4,8 @@ on: # yamllint disable-line rule:truthy pull_request: + branches: + - master permissions: pull-requests: write @@ -13,7 +15,7 @@ name: ๐Ÿคž Auto merge release jobs: auto-merge: - uses: wayofdev/gh-actions/.github/workflows/auto-merge-release.yml@master + uses: wayofdev/gh-actions/.github/workflows/auto-merge-release.yml@v3.2.0 with: os: ubuntu-latest pull-request-number: ${{ github.event.pull_request.number }} diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml new file mode 100644 index 0000000..a8bcf09 --- /dev/null +++ b/.github/workflows/coding-standards.yml @@ -0,0 +1,85 @@ +--- + +on: # yamllint disable-line rule:truthy + pull_request: + branches: + - master + +name: ๐Ÿงน Fix coding standards + +jobs: + commit-linting: + timeout-minutes: 4 + runs-on: ubuntu-latest + concurrency: + cancel-in-progress: true + group: commit-linting-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + permissions: + contents: read + pull-requests: read + steps: + - name: ๐Ÿ“ฆ Check out the codebase + uses: actions/checkout@v4.1.7 + + - name: ๐Ÿง Lint commits using "commitlint" + uses: wagoid/commitlint-github-action@v6.1.2 + with: + configFile: ${{ github.workspace }}/.github/.commitlint.config.mjs + failOnWarnings: false + failOnErrors: true + helpURL: 'https://github.com/conventional-changelog/commitlint/#what-is-commitlint' + + yaml-linting: + timeout-minutes: 4 + runs-on: ubuntu-latest + concurrency: + cancel-in-progress: true + group: yaml-linting-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + permissions: + contents: read + pull-requests: read + steps: + - name: ๐Ÿ“ฆ Check out the codebase + uses: actions/checkout@v4.1.7 + + - name: ๐Ÿง Lint YAML files + uses: ibiqlik/action-yamllint@v3.1.1 + with: + config_file: .github/.yamllint.yaml + file_or_dir: '.' + strict: true + + markdown-linting: + timeout-minutes: 4 + runs-on: ubuntu-latest + concurrency: + cancel-in-progress: true + group: markdown-linting-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + steps: + - name: ๐Ÿ“ฆ Check out the codebase + uses: actions/checkout@v4.1.7 + + - name: ๐Ÿง Lint Markdown files + uses: DavidAnson/markdownlint-cli2-action@v17.0.0 + with: + config: '.github/.markdownlint.json' + globs: | + **/*.md + !CHANGELOG.md + + ansible-linting: + timeout-minutes: 4 + runs-on: ubuntu-latest + concurrency: + cancel-in-progress: true + group: ansible-linting-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + env: + YAMLLINT_CONFIG_FILE: '${{ github.workspace }}/.github/.yamllint.yaml' + steps: + - name: ๐Ÿ“ฆ Check out the codebase + uses: actions/checkout@v4.1.7 + + - name: ๐Ÿง Lint Ansible files + uses: ansible/ansible-lint@v24.9.0 + with: + args: '-c ${{ github.workspace }}/.github/.ansible-lint.yml' diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 8bf60bf..964751b 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -2,6 +2,7 @@ # https://github.com/wayofdev/gh-actions/blob/master/.github/workflows/create-release.yml # https://github.com/google-github-actions/release-please-action#release-types-supported +# https://github.com/googleapis/release-please/blob/main/docs/customizing.md on: # yamllint disable-line rule:truthy push: @@ -12,12 +13,15 @@ name: ๐Ÿ“ฆ Create release jobs: release: - uses: wayofdev/gh-actions/.github/workflows/create-release.yml@master - with: - os: ubuntu-latest - branch: master - package-name: docker-nginx - secrets: - token: ${{ secrets.PERSONAL_GITHUB_TOKEN }} + runs-on: ubuntu-latest + steps: + - name: ๐ŸŽ‰ Create release + uses: googleapis/release-please-action@v4.1.3 + id: release + with: + token: ${{ secrets.PERSONAL_GITHUB_TOKEN }} + config-file: .github/.release-please-config.json + manifest-file: .github/.release-please-manifest.json + target-branch: master ... diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml new file mode 100644 index 0000000..e561bd8 --- /dev/null +++ b/.github/workflows/merge.yml @@ -0,0 +1,43 @@ +--- + +on: # yamllint disable-line rule:truthy + workflow_run: + types: + - completed + workflows: + - '๐Ÿงช Test Docker images' + +name: ๐Ÿ“ฅ Merge pull requests + +jobs: + merge: + runs-on: ubuntu-latest + timeout-minutes: 5 + if: > + github.event.workflow_run.event == 'pull_request' && + github.event.workflow_run.conclusion == 'success' && + ( + (github.actor == 'renovate[bot]' && + startsWith(github.event.workflow_run.head_commit.message, 'deps(deps)') + ) || + (github.actor == 'lotyp' && + startsWith(github.event.workflow_run.head_commit.message, 'chore(master)') + ) + ) + steps: + - name: ๐Ÿ™‹โ€โ™‚๏ธ Request reviewer from @way-finder-bot + uses: wayofdev/gh-actions/actions/github/pull-request/request-review@v3.2.0 + with: + reviewer: 'way-finder-bot' + github-token: "${{ secrets.WAY_FINDER_BOT_TOKEN }}" + + - name: ๐Ÿ™‹โ€โ™‚๏ธ Assign @way-finder-bot + uses: wayofdev/gh-actions/actions/github/pull-request/add-assignee@v3.2.0 + with: + assignee: 'way-finder-bot' + github-token: "${{ secrets.WAY_FINDER_BOT_TOKEN }}" + + - name: โœ… Approve pull request + uses: wayofdev/gh-actions/actions/github/pull-request/approve@v3.2.0 + with: + github-token: "${{ secrets.WAY_FINDER_BOT_TOKEN }}" diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml index d23d164..026faad 100644 --- a/.github/workflows/shellcheck.yml +++ b/.github/workflows/shellcheck.yml @@ -2,15 +2,21 @@ on: # yamllint disable-line rule:truthy pull_request: + branches: + - master name: ๐Ÿž Differential shell-check permissions: contents: read +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true + jobs: shellcheck: - uses: wayofdev/gh-actions/.github/workflows/shellcheck.yml@master + uses: wayofdev/gh-actions/.github/workflows/shellcheck.yml@v3.2.0 with: os: ubuntu-latest severity: warning diff --git a/.github/workflows/upload-assets.yml b/.github/workflows/upload-assets.yml index 8817670..dbcac01 100644 --- a/.github/workflows/upload-assets.yml +++ b/.github/workflows/upload-assets.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest steps: - name: ๐Ÿ“ฆ Check out the codebase - uses: actions/checkout@v4 + uses: actions/checkout@v4.1.7 - name: ๐Ÿš€ Generate dist files run: make generate @@ -23,7 +23,7 @@ jobs: run: tar -czvf dist.tar.gz dist - name: ๐Ÿ“ค Upload release assets - uses: alexellis/upload-assets@0.4.0 + uses: alexellis/upload-assets@0.4.1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6f591b5..9e212b4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,39 +2,48 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.6.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer - id: fix-encoding-pragma + - id: check-added-large-files + args: ['--maxkb=600'] - repo: https://github.com/adrienverge/yamllint - rev: v1.32.0 + rev: v1.35.1 hooks: - id: yamllint files: \.(yaml|yml)$ types: [file, yaml] - entry: yamllint --strict + entry: yamllint -c .github/.yamllint.yaml --strict - repo: https://github.com/commitizen-tools/commitizen - rev: 3.5.2 + rev: v3.29.0 hooks: - id: commitizen stages: - commit-msg + - repo: https://github.com/mpalmer/action-validator + rev: v0.6.0 + hooks: + - id: action-validator + stages: + - commit-msg + - repo: https://github.com/ansible/ansible-lint - rev: v6.17.2 + rev: v24.7.0 hooks: - id: ansible-lint - entry: ansible-lint . --force-color + entry: bash -c 'YAMLLINT_CONFIG_FILE=".github/.yamllint.yaml" ansible-lint . --force-color -c .github/.ansible-lint.yml' pass_filenames: false always_run: true additional_dependencies: - .[community] - repo: https://github.com/robertdebock/pre-commit - rev: v1.5.2 + rev: v1.5.3 hooks: - id: ansible_role_find_unused_variable - id: ansible_role_find_empty_files diff --git a/.yamllint b/.yamllint deleted file mode 100644 index b7bca9b..0000000 --- a/.yamllint +++ /dev/null @@ -1,58 +0,0 @@ ---- - -extends: "default" - -# Overwrite above default rules -rules: - braces: - # Defaults - # min-spaces-inside: 0 - # max-spaces-inside: 0 - - # Keep 0 min-spaces to not error on empty {} collection definitions - min-spaces-inside: 0 - - # Allow one space inside braces to improve code readability - max-spaces-inside: 1 - - brackets: - # Defaults - # min-spaces-inside: 0 - # max-spaces-inside: 0 - - # Keep 0 min-spaces to not error on empty [] collection definitions - min-spaces-inside: 0 - - # Allow one space inside braces to improve code readability - max-spaces-inside: 1 - - colons: - # Defaults - # min-spaces-before: 0 - # max-spaces-after: 1 - - # Allow multiple spaces after a colon to allow indentation of YAML - # dictionary values - max-spaces-after: -1 - - commas: - # Defaults - # max-spaces-after: 1 - - # Allow multiple spaces after a comma to allow indentation of YAML - # dictionary values - max-spaces-after: -1 - - comments: - require-starting-space: true - min-spaces-from-content: 1 - - line-length: - max: 180 - level: warning - -yaml-files: - - "*.yaml" - - "*.yml" - -... diff --git a/Makefile b/Makefile index 7e83dd3..4e01e12 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,9 @@ export DOCKER_BUILDKIT ?= 1 export COMPOSE_DOCKER_CLI_BUILD ?= 1 +# Docker binary to use, when executing docker tasks +DOCKER ?= docker + IMAGE_NAMESPACE ?= wayofdev/nginx IMAGE_TEMPLATE ?= k8s-alpine IMAGE_TAG ?= $(IMAGE_NAMESPACE):$(IMAGE_TEMPLATE)-latest @@ -13,6 +16,34 @@ CACHE_FROM ?= $(IMAGE_TAG) OS ?= $(shell uname) CURRENT_DIR ?= $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) +YAML_CONFIG_PATH ?= .github/.yamllint.yaml + +YAML_LINT_RUNNER ?= $(DOCKER) run --rm $$(tty -s && echo "-it" || echo) \ + -v $(PWD):/data \ + cytopia/yamllint:latest \ + -c $(YAML_CONFIG_PATH) \ + -f colored . + +ACTION_LINT_RUNNER ?= $(DOCKER) run --rm $$(tty -s && echo "-it" || echo) \ + -v $(shell pwd):/repo \ + --workdir /repo \ + rhysd/actionlint:latest \ + -color + +MARKDOWN_LINT_RUNNER ?= $(DOCKER) run --rm $$(tty -s && echo "-it" || echo) \ + -v $(shell pwd):/app \ + --workdir /app \ + davidanson/markdownlint-cli2-rules:latest \ + --config ".github/.markdownlint.json" + +ANSIBLE_LINT_RUNNER ?= $(DOCKER) run --rm $$(tty -s && echo "-it" || echo) \ + -v $(shell pwd):/code \ + -e YAMLLINT_CONFIG_FILE=$(YAML_CONFIG_PATH) \ + --workdir /code \ + pipelinecomponents/ansible-lint:latest \ + ansible-lint --show-relpath --config-file ".github/.ansible-lint.yml" + +# # Self documenting Makefile code # ------------------------------------------------------------------------------------ ifneq ($(TERM),) @@ -36,7 +67,7 @@ else WHITE := "" RST := "" endif -MAKE_LOGFILE = /tmp/docker-nginx.log +MAKE_LOGFILE = /tmp/wayofdev-docker-nginx.log MAKE_CMD_COLOR := $(BLUE) default: all @@ -45,29 +76,31 @@ help: ## Show this menu @echo 'Management commands for package:' @echo 'Usage:' @echo ' ${MAKE_CMD_COLOR}make${RST} Builds default image and then runs dgoss tests' - @grep -E '^[a-zA-Z_0-9%-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " ${MAKE_CMD_COLOR}make %-21s${RST} %s\n", $$1, $$2}' + @grep -E '^[a-zA-Z_0-9%-]+:.*?## .*$$' Makefile | awk 'BEGIN {FS = ":.*?## "}; {printf " ${MAKE_CMD_COLOR}make %-21s${RST} %s\n", $$1, $$2}' @echo @echo ' ๐Ÿ“‘ Logs are stored in $(MAKE_LOGFILE)' @echo @echo ' ๐Ÿ“ฆ Package docker-nginx (github.com/wayofdev/docker-nginx)' - @echo ' ๐Ÿค  Author Andrij Orlenko (github.com/lotyp)' + @echo ' ๐Ÿค  Author the dev (github.com/lotyp)' @echo ' ๐Ÿข ${YELLOW}Org wayofdev (github.com/wayofdev)${RST}' + @echo .PHONY: help .EXPORT_ALL_VARIABLES: +# # Default action # Defines default command when `make` is executed without additional parameters # ------------------------------------------------------------------------------------ -all: hooks generate build test +all: generate build test PHONY: all - +# # Docker Actions # ------------------------------------------------------------------------------------ build: ## Build default docker image cd $(CURRENT_DIR)$(DOCKERFILE_DIR); \ - docker build -t $(IMAGE_TAG) . + $(DOCKER) build -t $(IMAGE_TAG) . PHONY: build analyze: ## Analyze docker image @@ -80,11 +113,6 @@ build-from-cache: ## Build default docker image using cached layers docker build --cache-from $(CACHE_FROM) . -t $(IMAGE_TAG) PHONY: build-from-cache -test: ## Run dgoss tests over docker images - set -eux - GOSS_FILES_STRATEGY=cp GOSS_FILES_PATH=$(DOCKERFILE_DIR) dgoss run --add-host app:127.0.0.1 -t $(IMAGE_TAG) -.PHONY: test - pull: ## Pulls docker image from upstream docker pull $(IMAGE_TAG) .PHONY: pull @@ -97,7 +125,7 @@ ssh: ## Login into built image docker run --rm -it -v $(PWD)/:/opt/docker-nginx $(IMAGE_TAG) sh .PHONY: ssh - +# # Ansible Actions # ------------------------------------------------------------------------------------ generate: ## Generates dockerfiles from ansible templates @@ -108,23 +136,49 @@ clean: ## Cleans up generated files rm -rf ./dist/* PHONY: clean +# +# Testing +# ------------------------------------------------------------------------------------ +test: ## Run dgoss tests over docker images + set -eux + GOSS_SLEEP="0.4" GOSS_WAIT_OPTS="-r 40s -s 2s > /dev/stdout" GOSS_FILES_STRATEGY=cp GOSS_FILES_PATH=$(DOCKERFILE_DIR) dgoss run --add-host app:127.0.0.1 -t $(IMAGE_TAG) +.PHONY: test -# Code Quality, Git, Linting, Testing +# +# Code Quality, Git, Linting # ------------------------------------------------------------------------------------ hooks: ## Install git hooks from pre-commit-config pre-commit install + pre-commit install --hook-type commit-msg pre-commit autoupdate .PHONY: hooks +lint: lint-yaml lint-actions lint-md lint-ansible ## Runs all linting commands +.PHONY: lint + lint-yaml: ## Lints yaml files inside project - yamllint . + @$(YAML_LINT_RUNNER) | tee -a $(MAKE_LOGFILE) .PHONY: lint-yaml +lint-actions: ## Lint all github actions + @$(ACTION_LINT_RUNNER) | tee -a $(MAKE_LOGFILE) +.PHONY: lint-actions + +lint-md: ## Lint all markdown files using markdownlint-cli2 + @$(MARKDOWN_LINT_RUNNER) --fix "**/*.md" "!CHANGELOG.md" "!app/vendor" "!app/node_modules" | tee -a $(MAKE_LOGFILE) +.PHONY: lint-md + +lint-md-dry: ## Lint all markdown files using markdownlint-cli2 in dry-run mode + @$(MARKDOWN_LINT_RUNNER) "**/*.md" "!CHANGELOG.md" "!app/vendor" "!app/node_modules" | tee -a $(MAKE_LOGFILE) +.PHONY: lint-md-dry + lint-ansible: ## Lint ansible files inside project - ansible-lint . + @$(ANSIBLE_LINT_RUNNER) . | tee -a $(MAKE_LOGFILE) .PHONY: lint-ansible -lint-docker: ## Run hadolint linter over dist Dockerfiles - hadolint -V ./dist/dev-alpine/Dockerfile - hadolint -V ./dist/k8s-alpine/Dockerfile -.PHONY: lint-docker +# +# Release +# ------------------------------------------------------------------------------------ +commit: ## Run commitizen to create commit message + czg commit --config="./.github/.cz.config.js" +.PHONY: commit diff --git a/README.md b/README.md index 3a29cf3..ceb2be8 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ -
- -
-Logo -Logo -
- -
- -
+

+
+ + + + WayOfDev Logo + + +
+

Build Status @@ -23,7 +23,7 @@ This image is used together with [wayofdev/docker-php-dev](https://github.com/wayofdev/docker-php-dev) and other WOD images, to create local development environment for our projects. -![Screenshot](assets/screenshot.png) +![Screenshot](.github/assets/screenshot.png) ## โš™๏ธ Development @@ -40,7 +40,7 @@ For testing purposes we use **goss** and **dgoss**, follow installation instruct Generating distributable Dockerfiles from yaml source code: ```bash -$ make generate +make generate ```
@@ -48,22 +48,22 @@ $ make generate Building default image: ```bash -$ git clone git@github.com:wayofdev/docker-nginx.git -$ cd docker-nginx -$ make build +git clone git@github.com:wayofdev/docker-nginx.git +cd docker-nginx +make build ``` To **build** image, **test** it and then **clean** temporary files run: ```bash -$ make +make ``` Building all images: ```bash -$ make build IMAGE_TEMPLATE=dev-alpine -$ make build IMAGE_TEMPLATE=k8s-alpine +make build IMAGE_TEMPLATE=dev-alpine +make build IMAGE_TEMPLATE=k8s-alpine ```
@@ -73,14 +73,14 @@ $ make build IMAGE_TEMPLATE=k8s-alpine Testing default image: ```bash -$ make test +make test ``` To test all images: ```bash -$ make test IMAGE_TEMPLATE=dev-alpine -$ make test IMAGE_TEMPLATE=k8s-alpine +make test IMAGE_TEMPLATE=dev-alpine +make test IMAGE_TEMPLATE=k8s-alpine ```
@@ -90,41 +90,63 @@ $ make test IMAGE_TEMPLATE=k8s-alpine Run **yamllint** to validate all yaml files in project: ```bash -$ make lint-yaml +make lint-yaml ``` Run hadolint to validate created Dockerfiles: ```bash -$ make lint-docker +make lint-docker ``` Run ansible-lint to validate project files: ```bash -$ make lint-ansible +make lint-ansible ```
-## ๐Ÿค License +## ๐Ÿ”’ Security Policy -[![Licence](https://img.shields.io/github/license/wayofdev/docker-nginx?style=for-the-badge&color=blue)](./LICENSE) +This project has a [security policy](.github/SECURITY.md).
-## ๐Ÿ™†๐Ÿผโ€โ™‚๏ธ Author Information +## ๐Ÿ™Œ Want to Contribute? + +Thank you for considering contributing to the wayofdev community! We are open to all kinds of contributions. If you want to: + +- ๐Ÿค” [Suggest a feature](https://github.com/wayofdev/docker-nginx/issues/new?assignees=&labels=type%3A+enhancement&projects=&template=2-feature-request.yml&title=%5BFeature%5D%3A+) +- ๐Ÿ› [Report an issue](https://github.com/wayofdev/docker-nginx/issues/new?assignees=&labels=type%3A+documentation%2Ctype%3A+maintenance&projects=&template=1-bug-report.yml&title=%5BBug%5D%3A+) +- ๐Ÿ“– [Improve documentation](https://github.com/wayofdev/docker-nginx/issues/new?assignees=&labels=type%3A+documentation%2Ctype%3A+maintenance&projects=&template=4-docs-bug-report.yml&title=%5BDocs%5D%3A+) +- ๐Ÿ‘จโ€๐Ÿ’ป [Contribute to the code](./.github/CONTRIBUTING.md) -This repository was created in **2022** by [lotyp / wayofdev](https://github.com/wayofdev). +You are more than welcome. Before contributing, kindly check our [contribution guidelines](.github/CONTRIBUTING.md). + +[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg?style=for-the-badge)](https://conventionalcommits.org)
## ๐Ÿซก Contributors - - +

- Supporters +Contributors Badge +
+
+

+ +## ๐ŸŒ Social Links + +- **Twitter:** Follow our organization [@wayofdev](https://twitter.com/intent/follow?screen_name=wayofdev) and the author [@wlotyp](https://twitter.com/intent/follow?screen_name=wlotyp). +- **Discord:** Join our community on [Discord](https://discord.gg/CE3TcCC5vr). + +
+ +## โš–๏ธ License + +[![Licence](https://img.shields.io/github/license/wayofdev/docker-nginx?style=for-the-badge&color=blue)](./LICENSE.md)
diff --git a/assets/logo.gh-dark-mode-only.png b/assets/logo.gh-dark-mode-only.png deleted file mode 100644 index 9d695ea..0000000 Binary files a/assets/logo.gh-dark-mode-only.png and /dev/null differ diff --git a/assets/logo.gh-light-mode-only.png b/assets/logo.gh-light-mode-only.png deleted file mode 100644 index bb3bfde..0000000 Binary files a/assets/logo.gh-light-mode-only.png and /dev/null differ diff --git a/assets/screenshot.png b/assets/screenshot.png deleted file mode 100644 index dfe3f70..0000000 Binary files a/assets/screenshot.png and /dev/null differ diff --git a/package.json b/package.json deleted file mode 100644 index 19582b1..0000000 --- a/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "version": "1.4.1", - "repository": { - "url": "https://github.com/wayofdev/docker-nginx.git" - } -} diff --git a/renovate.json b/renovate.json deleted file mode 100644 index a393664..0000000 --- a/renovate.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "extends": [ - "config:base" - ], - "automerge": true, - "platformAutomerge": true -} diff --git a/src/playbook.yml b/src/playbook.yml index a371037..8276099 100644 --- a/src/playbook.yml +++ b/src/playbook.yml @@ -1,10 +1,12 @@ --- -- hosts: all +- name: Generate nginx Dockerfiles + hosts: all gather_facts: false tags: - template tasks: - - import_tasks: roles/all/main.yml + - name: Create dist for all supported nginx versions + ansible.builtin.import_tasks: roles/all/main.yml ... diff --git a/src/roles/all/main.yml b/src/roles/all/main.yml index 3db34ef..b6000c1 100644 --- a/src/roles/all/main.yml +++ b/src/roles/all/main.yml @@ -1,59 +1,59 @@ --- - name: Load k8s variables - include_vars: + ansible.builtin.include_vars: file: group_vars/k8s.yml name: type when: level == "k8s" - name: Load dev variables - include_vars: + ansible.builtin.include_vars: file: group_vars/dev.yml name: type when: level == "dev" - name: Create dist directories - file: + ansible.builtin.file: path: "{{ item.path }}" state: directory - mode: 0775 + mode: "0775" recurse: true with_items: - "{{ tpl_directories }}" - name: Generate Dockerfiles - template: + ansible.builtin.template: src: "{{ item.src }}" dest: "{{ item.dst }}" force: true - mode: 0644 + mode: "0644" with_items: - "{{ tpl_dockerfiles }}" - name: Generate nginx configuration files - template: + ansible.builtin.template: src: "{{ item.src }}" dest: "{{ item.dst }}" force: true - mode: 0644 + mode: "0644" with_items: - "{{ tpl_configs }}" - name: Generate Dockerfile dgoss tests - template: + ansible.builtin.template: src: "{{ item.src }}" dest: "{{ item.dst }}" force: true - mode: 0644 + mode: " 0644" with_items: - "{{ tpl_docker_tests }}" - name: Copy SSL certs - template: + ansible.builtin.template: src: "{{ item.src }}" dest: "{{ item.dst }}" force: true - mode: 0644 + mode: "0644" with_items: - "{{ tpl_certs }}"