{"id":21664384,"url":"https://github.com/wayofdev/docker-nginx","last_synced_at":"2025-07-25T02:39:23.427Z","repository":{"id":40476244,"uuid":"441509825","full_name":"wayofdev/docker-nginx","owner":"wayofdev","description":"Optimized Nginx Docker image for PHP development. SSL-ready, lightweight Alpine-based, multi-arch support. Ideal for Laravel, Symfony, and PHP web services.","archived":false,"fork":false,"pushed_at":"2025-04-03T13:54:31.000Z","size":1384,"stargazers_count":5,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-12T00:16:02.516Z","etag":null,"topics":["alpine","ansible","devops","docker","docker-compose","docker-image","docker-php","fpm","laravel","multi-arch","nginx","php","php-docker","ssl"],"latest_commit_sha":null,"homepage":"https://wayof.dev","language":"Jinja","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wayofdev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"wayofdev"}},"created_at":"2021-12-24T16:23:51.000Z","updated_at":"2025-02-27T19:35:36.000Z","dependencies_parsed_at":"2024-10-23T18:06:15.087Z","dependency_job_id":"1b128016-4ac3-467a-8e11-83ac49d27159","html_url":"https://github.com/wayofdev/docker-nginx","commit_stats":null,"previous_names":[],"tags_count":35,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wayofdev%2Fdocker-nginx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wayofdev%2Fdocker-nginx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wayofdev%2Fdocker-nginx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wayofdev%2Fdocker-nginx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wayofdev","download_url":"https://codeload.github.com/wayofdev/docker-nginx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248497818,"owners_count":21113984,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alpine","ansible","devops","docker","docker-compose","docker-image","docker-php","fpm","laravel","multi-arch","nginx","php","php-docker","ssl"],"created_at":"2024-11-25T10:37:21.382Z","updated_at":"2025-04-12T00:16:13.881Z","avatar_url":"https://github.com/wayofdev.png","language":"Jinja","readme":"\u003cp align=\"center\"\u003e\n    \u003cbr\u003e\n    \u003ca href=\"https://wayof.dev\" target=\"_blank\"\u003e\n        \u003cpicture\u003e\n            \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://raw.githubusercontent.com/wayofdev/.github/master/assets/logo.gh-dark-mode-only.png\"\u003e\n            \u003cimg width=\"400\" src=\"https://raw.githubusercontent.com/wayofdev/.github/master/assets/logo.gh-light-mode-only.png\" alt=\"WayOfDev Logo\"\u003e\n        \u003c/picture\u003e\n    \u003c/a\u003e\n    \u003cbr\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://actions-badge.atrox.dev/wayofdev/docker-nginx/goto\"\u003e\u003cimg alt=\"Build Status\" src=\"https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fwayofdev%2Fdocker-nginx%2Fbadge\u0026style=flat-square\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/wayofdev/docker-nginx/tags\"\u003e\u003cimg src=\"https://img.shields.io/github/v/tag/wayofdev/docker-nginx?sort=semver\u0026style=flat-square\" alt=\"Latest Version\"\u003e\u003c/a\u003e\n\u003ca href=\"https://hub.docker.com/repository/docker/wayofdev/nginx\"\u003e\u003cimg alt=\"Docker Pulls\" src=\"https://img.shields.io/docker/pulls/wayofdev/nginx?style=flat-square\"\u003e\u003c/a\u003e\n\u003ca href=\"LICENSE.md\"\u003e\u003cimg src=\"https://img.shields.io/github/license/wayofdev/docker-nginx.svg?style=flat-square\u0026color=blue\" alt=\"Software License\"/\u003e\u003c/a\u003e\n\u003ca href=\"#\"\u003e\u003cimg alt=\"Commits since latest release\" src=\"https://img.shields.io/github/commits-since/wayofdev/docker-nginx/latest?style=flat-square\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cbr\u003e\n\n# Docker Image: Nginx\n\nThis **Docker image** provides a streamlined **Nginx** setup optimized for **local PHP development environments**.\n\nIt's designed to seamlessly integrate with [wayofdev/docker-php-dev](https://github.com/wayofdev/docker-php-dev) and other (WOD) images, creating an efficient local development ecosystem for web projects.\n\n\u003cbr\u003e\n\n## 🌟 Why Choose This Image for Local Development?\n\n- **Ansible-based Configuration:** Easily customizable through Ansible templates\n- **PHP-FPM Optimized:** Pre-configured to work with PHP-FPM for fast local testing and development\n- **SSL Ready:** Includes built-in support for HTTPS using self-signed certificates, mimicking production environments locally\n- **Developer Friendly:** Packed with tools and configurations to enhance local development workflows\n- **Flexible Deployment:** Includes a `k8s-alpine` variant for testing Kubernetes setups locally\n- **Lightweight:** Based on **Alpine Linux** for minimal footprint and faster local builds\n- **Multi-arch Support:** Works on both **x86 (AMD64)** and **ARM64** architectures, supporting various development machines\n- **Regular Updates:** Maintained and updated frequently to align with the latest development practices\n\nPerfect for developing **Laravel** applications, **Symfony** projects, or any **PHP-based web services** in a local environment that closely mirrors production setups.\n\nProvides foundation for creating, testing, and debugging your web applications locally.\n\n\u003cbr\u003e\n\nIf you **like/use** this package, please consider ⭐️ **starring** it. Thanks!\n\n\u003cbr\u003e\n\n## 📦 Image Variants\n\n| Variant    | Description                                                                   |\n|------------|-------------------------------------------------------------------------------|\n| dev-alpine | For local development environments, uses 80 and 443 ports.                    |\n| k8s-alpine | Optimized for k8s and local environments, uses 8880 and 8443 ports, rootless. |\n\n\u003cbr\u003e\n\n## 🚀 Usage\n\n### → Pulling the Image\n\n```bash\ndocker pull wayofdev/nginx:k8s-alpine-latest\n```\n\nReplace `k8s-alpine-latest` with your desired type, and tag.\n\n### → Available Image Variants\n\n- **Types:** k8s, dev\n- **Architectures:** amd64, arm64\n\n### → Using in Docker Compose\n\nHere's an example `docker-compose.yml` for a typical setup:\n\n```yaml\nservices:\n  app:\n    image: wayofdev/php-dev:8.3-fpm-alpine-latest\n    container_name: ${COMPOSE_PROJECT_NAME}-app\n    restart: on-failure\n    networks:\n      - default\n      - shared\n    depends_on:\n      - database\n    links:\n      - database\n    volumes:\n      - ./.github/assets:/assets:rw,cached\n      - ./app:/app:rw,cached\n      - ./.env:/app/.env\n      - ~/.composer:/.composer\n      - ~/.ssh:/home/www-data/.ssh\n    environment:\n      FAKETIME: '+2h'\n      XDEBUG_MODE: '${XDEBUG_MODE:-off}'\n      PHIVE_HOME: /app/.phive\n    dns:\n      - 8.8.8.8\n    extra_hosts:\n      - 'host.docker.internal:host-gateway'\n\n  web:\n    image: wayofdev/nginx:k8s-alpine-latest\n    container_name: ${COMPOSE_PROJECT_NAME}-web\n    restart: on-failure\n    networks:\n      - default\n      - shared\n    depends_on:\n      - app\n    links:\n      - app\n    volumes:\n      - ./app:/app:rw,cached\n      - ./.env:/app/.env\n    labels:\n      - traefik.enable=true\n      - traefik.http.routers.api-${COMPOSE_PROJECT_NAME}-secure.rule=Host(`api.${COMPOSE_PROJECT_NAME}.docker`)\n      - traefik.http.routers.api-${COMPOSE_PROJECT_NAME}-secure.entrypoints=websecure\n      - traefik.http.routers.api-${COMPOSE_PROJECT_NAME}-secure.tls=true\n      - traefik.http.services.api-${COMPOSE_PROJECT_NAME}-secure.loadbalancer.server.port=8880\n      - traefik.docker.network=network.${SHARED_SERVICES_NAMESPACE}\n```\n\n#### This configuration includes\n\n- An `app` service using the `wayofdev/php-dev` image for PHP processing.\n- A `web` service using a [custom Nginx image](https://github.com/wayofdev/docker-nginx) for serving the application.\n- Network configuration for both default and shared networks.\n- Volume mounts for application code, assets, and configuration files.\n- Environment variables for PHP and Xdebug configuration.\n- Traefik labels for reverse proxy and SSL termination.\n\n#### Real-world Example\n\nFor a comprehensive, real-world example of how to use this image in a Docker Compose setup, please refer to the [wayofdev/laravel-starter-tpl](https://github.com/wayofdev/laravel-starter-tpl) repository. This template provides a fully configured development environment for Laravel projects using the `wayofdev/php-dev` image.\n\n\u003cbr\u003e\n\n## ⚙️ Configuration\n\nThe Nginx image is pre-configured for optimal performance with PHP applications, but you can customize it further to suit your specific needs.\n\n### → Default Configuration\n\nThe default configuration is generated using Ansible templates and includes:\n\n- Optimized settings for PHP-FPM\n- SSL/TLS support with self-signed certificates\n- Gzip compression enabled\n- Basic security headers\n\n### → Custom Configuration\n\nWhile the configuration is primarily managed through Ansible templates, you can override specific settings:\n\n1. **Environment Variables:** The image uses the following environment variables:\n\n   | Variable               | Default Value | Description                           |\n      |------------------------|---------------|---------------------------------------|\n   | PHP_UPSTREAM_CONTAINER | app           | The name of the PHP-FPM container     |\n   | PHP_UPSTREAM_PORT      | 9000          | The port of the PHP-FPM container     |\n\n   Set these in your `docker-compose.yml` file:\n\n   ```yaml\n   services:\n     web:\n       image: wayofdev/nginx:k8s-alpine-latest\n       environment:\n         - PHP_UPSTREAM_CONTAINER=my-php-app\n         - PHP_UPSTREAM_PORT=9001\n   ```\n\n2. **Volume Mounts:** For more extensive customizations, you can mount your own config files:\n\n   ```yaml\n   services:\n     web:\n       image: wayofdev/nginx:k8s-alpine-latest\n       volumes:\n         - ./custom-nginx.conf:/etc/nginx/nginx.conf\n         - ./custom-default.conf:/etc/nginx/conf.d/default.conf\n   ```\n\n### → SSL Configuration\n\nThe image includes self-signed SSL certificates. To use your own:\n\n```yaml\nservices:\n  web:\n    image: wayofdev/nginx:k8s-alpine-latest\n    volumes:\n      - ./certs/cert.pem:/etc/nginx/ssl/cert.pem\n      - ./certs/key.pem:/etc/nginx/ssl/key.pem\n```\n\n### → Advanced Configuration\n\nFor more advanced configurations:\n\n1. Fork this repository\n2. Modify the Ansible templates in the `src` directory\n3. Regenerate the Dockerfiles using `make generate`\n4. Build your custom image\n\n\u003cbr\u003e\n\n## 🔨 Development\n\nThis project uses a set of tools for development and testing. The `Makefile` provides various commands to streamline the development process.\n\n### → Requirements\n\n- Docker\n- Make\n- Ansible\n- goss and dgoss for testing\n\n### → Setting Up the Development Environment\n\nClone the repository:\n\n```bash\ngit clone git@github.com:wayofdev/docker-nginx.git \u0026\u0026 \\\ncd docker-nginx\n```\n\n### → Generating Dockerfiles\n\nAnsible is used to generate Dockerfiles and configurations. To generate distributable Dockerfiles from Jinja template source code:\n\n```bash\nmake generate\n```\n\n### → Building Images\n\n- Build the default image:\n\n  ```bash\n  make build\n  ```\n\n  This command builds the image specified by the `IMAGE_TEMPLATE` variable in the Makefile. By default, it's set to `k8s-alpine`.\n\n- Build a specific image:\n\n  ```bash\n  make build IMAGE_TEMPLATE=\"k8s-alpine\"\n  ```\n\n  Replace `8.3-fpm-alpine` with your desired PHP version, type, and OS.\n\n- Build all images:\n\n  ```bash\n  make build IMAGE_TEMPLATE=\"k8s-alpine\"\n  make build IMAGE_TEMPLATE=\"dev-alpine\"\n  ```\n\n  These commands will build all supported image variants.\n\n\u003cbr\u003e\n\n## 🧪 Testing\n\nThis project uses a testing approach to ensure the quality and functionality of the Docker images. The primary testing tool is [dgoss](https://github.com/aelsabbahy/goss/tree/master/extras/dgoss), which allows for testing Docker containers.\n\n### → Running Tests\n\nYou can run tests using the following commands:\n\n- Test the default image:\n\n  ```bash\n  make test\n  ```\n\n  This command tests the image specified by the `IMAGE_TEMPLATE` variable in the Makefile (default is `k8s-alpine`).\n\n- Test a specific image:\n\n  ```bash\n  make test IMAGE_TEMPLATE=\"k8s-alpine\"\n  ```\n\n  Replace `k8s-alpine` with your desired image type, and OS.\n\n- Test all images:\n\n  ```bash\n  make test IMAGE_TEMPLATE=\"k8s-alpine\"\n  make test IMAGE_TEMPLATE=\"dev-alpine\"\n  ```\n\n### → Test Configuration\n\nThe test configurations are defined in `goss.yaml` files, which are generated for each image variant. These files specify the tests to be run, including:\n\n- File existence and permissions\n- Process checks\n- Port availability\n- Package installations\n- Command outputs\n\n### → Test Process\n\nWhen you run the `make test` command, the following steps occur:\n\n1. The specified Docker image is built (if not already present).\n2. dgoss runs the tests defined in the `goss.yaml` file against the Docker container.\n3. The test results are displayed in the console.\n\n\u003cbr\u003e\n\n## 🔒 Security Policy\n\nThis project has a [security policy](.github/SECURITY.md).\n\n\u003cbr\u003e\n\n## 🙌 Want to Contribute?\n\nThank you for considering contributing to the wayofdev community! We are open to all kinds of contributions. If you want to:\n\n- 🤔 [Suggest a feature](https://github.com/wayofdev/docker-nginx/issues/new?assignees=\u0026labels=type%3A+enhancement\u0026projects=\u0026template=2-feature-request.yml\u0026title=%5BFeature%5D%3A+)\n- 🐛 [Report an issue](https://github.com/wayofdev/docker-nginx/issues/new?assignees=\u0026labels=type%3A+documentation%2Ctype%3A+maintenance\u0026projects=\u0026template=1-bug-report.yml\u0026title=%5BBug%5D%3A+)\n- 📖 [Improve documentation](https://github.com/wayofdev/docker-nginx/issues/new?assignees=\u0026labels=type%3A+documentation%2Ctype%3A+maintenance\u0026projects=\u0026template=4-docs-bug-report.yml\u0026title=%5BDocs%5D%3A+)\n- 👨‍💻 [Contribute to the code](./.github/CONTRIBUTING.md)\n\nYou are more than welcome. Before contributing, kindly check our [contribution guidelines](.github/CONTRIBUTING.md).\n\n[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg?style=for-the-badge)](https://conventionalcommits.org)\n\n\u003cbr\u003e\n\n## 🫡 Contributors\n\n\u003cp align=\"left\"\u003e\n\u003ca href=\"https://github.com/wayofdev/docker-nginx/graphs/contributors\"\u003e\n\u003cimg align=\"left\" src=\"https://img.shields.io/github/contributors-anon/wayofdev/docker-nginx?style=for-the-badge\" alt=\"Contributors Badge\"/\u003e\n\u003c/a\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003c/p\u003e\n\n## 🌐 Social Links\n\n- **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).\n- **Discord:** Join our community on [Discord](https://discord.gg/CE3TcCC5vr).\n\n\u003cbr\u003e\n\n## ⚖️ License\n\n[![Licence](https://img.shields.io/github/license/wayofdev/docker-nginx?style=for-the-badge\u0026color=blue)](./LICENSE.md)\n\n\u003cbr\u003e\n","funding_links":["https://github.com/sponsors/wayofdev"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwayofdev%2Fdocker-nginx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwayofdev%2Fdocker-nginx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwayofdev%2Fdocker-nginx/lists"}