diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..5e3d9ca --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,3 @@ +--- +github: [cytopia] +patreon: devilbox diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000..180ae53 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,106 @@ +--- +name: "\U0001F41B Bug report" +description: File a bug report +title: "[Bug]: " +labels: ["bug", "status:triage"] +assignees: + - cytopia + +body: + + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this bug report! + + - type: input + attributes: + label: (Optional) Error message + description: If you encountered any error message, copy and paste it here. This will be used for googling the issue. + validations: + required: false + + - type: textarea + id: what-happened + attributes: + label: What went wrong? + description: What exactly went wrong and what bug did you encounter? + validations: + required: true + + - type: textarea + id: expected-behaviour + attributes: + label: Expected behaviour + description: What did you expect to happen instead? + validations: + required: true + + - type: textarea + id: steps-to-reproduce + attributes: + label: How can we reproduce the bug? + description: How do you trigger this bug? Please walk us through it step by step in detail. This is crucial in order to triage the bug and support you in resolving it. + validations: + required: true + + - type: dropdown + id: host-os + attributes: + label: Host Operating System + description: What operating system are you using? + multiple: false + options: + - Linux + - macOS + - Windows + validations: + required: true + + - type: dropdown + id: host-platform + attributes: + label: Host Platform (amd64, arm64, other) + description: What host platform are you running on? + options: + - amd64 + - arm64 + - other + validations: + required: true + + - type: dropdown + attributes: + label: (Linux only) Is SELinux enabled? + description: When using Linux as your host operating system, check if SELinux is enabled or not. + options: + - Yes, SELinux is enabled + - No, SELinux is disabled + - I don't know + - I am not on Linux + validations: + required: true + + - type: input + id: docker-version + attributes: + label: Docker version + description: "What Docker version are you using? Please copy and paste the output of `docker --version` into this text area." + validations: + required: true + + - type: textarea + id: log-docker + attributes: + label: "Log: docker logs" + description: "Please copy and paste the output of `docker logs` into this text area" + render: shell + validations: + required: true + + - type: textarea + attributes: + label: (Optional) Additional information + description: Add any additional information that might help with this bug report. + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..9f2ad11 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,12 @@ +--- +blank_issues_enabled: false +contact_links: + - name: Devilbox Discord Chat + url: https://discord.gg/2wP3V6kBj4 + about: Please notify or discuss about any other requests here. + - name: Devilbox Discourse Forum + url: https://devilbox.discourse.group/ + about: Please ask and answer general questions here. + - name: Devilbox documentation + url: https://devilbox.readthedocs.io/ + about: Find the Devilbox documentation here. diff --git a/.github/ISSUE_TEMPLATE/documentation.yml b/.github/ISSUE_TEMPLATE/documentation.yml new file mode 100644 index 0000000..b0e2a11 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/documentation.yml @@ -0,0 +1,37 @@ +--- +name: "\U0001F4DD Documentation" +description: Something is missing, unclear or wrong in the documentation. +title: "[Docs]: " +labels: ["documentation", "status:triage"] +assignees: + - cytopia + +body: + + - type: textarea + attributes: + label: What is wrong in the documentation? + description: Tell us, what is wrong in the documentation? + validations: + required: false + + - type: textarea + attributes: + label: What is unclear in the documentation? + description: Tell us, what is unclear in the documentation? + validations: + required: false + + - type: textarea + attributes: + label: What is missing in the documentation? + description: Tell us, what is missing in the documentation? + validations: + required: false + + - type: dropdown + attributes: + label: Are you willing to provide a PR to address this? + options: + - "Yes" + - "No" diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 0000000..a4706bf --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,36 @@ +--- +name: "โœจ Feature request" +description: Suggest an idea or feature for this project +title: "[Feature]: " +labels: ["feature", "status:triage"] +assignees: [cytopia] + +body: + + - type: textarea + attributes: + label: What is your idea or feature suggestion? + description: Tell us, what idea or feature you suggest to be added. + validations: + required: true + + - type: textarea + attributes: + label: Benefits + description: Tell us, how this will be beneficial. + validations: + required: false + + - type: textarea + attributes: + label: Where can we find information about this? + description: If you are proposing a software or tool, please add relevant links and documentation. + validations: + required: false + + - type: dropdown + attributes: + label: Are you willing to provide a PR to address this? + options: + - "Yes" + - "No" diff --git a/.github/ISSUE_TEMPLATE/howto.yml b/.github/ISSUE_TEMPLATE/howto.yml new file mode 100644 index 0000000..823af05 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/howto.yml @@ -0,0 +1,45 @@ +--- +name: "โ” Question" +description: How do I do X or Y? +title: "[Question]: " +labels: ["question", "status:triage"] +assignees: [cytopia] + +body: + + - type: markdown + attributes: + value: | + If this is a generic question, please consider using the [Discord Chat](https://discord.gg/2wP3V6kBj4) or the [Devilbox forum](https://devilbox.discourse.group/) instead. + + - type: checkboxes + attributes: + label: Have you already checked elsewhere? + description: You may select more than one. + options: + - label: I have checked existing issues + - label: I have googled already with no luck + - label: I have not done any of the above + validations: + required: true + + - type: textarea + attributes: + label: What is your question? + description: Tell the community, what your question is. Be as specific as possible to make it easier for other people to answer your question. + validations: + required: true + + - type: textarea + attributes: + label: What have you tried already? + description: Add some details on what you have tried already, so this can be ruled out. + validations: + required: true + + - type: textarea + attributes: + label: What is your goal? + description: Tell the community, what you want to accomplish? This might be helpful to know in order to prevent [XY problems](https://en.wikipedia.org/wiki/XY_problem). + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/report.yml b/.github/ISSUE_TEMPLATE/report.yml new file mode 100644 index 0000000..36381de --- /dev/null +++ b/.github/ISSUE_TEMPLATE/report.yml @@ -0,0 +1,21 @@ +--- +name: "๐Ÿ•ฌ Report" +description: Report something to the maintainer +title: "[Report]: " +labels: ["report", "status:triage"] +assignees: + - cytopia + +body: + + - type: markdown + attributes: + value: | + Report something to the maintainer such as versions are outdated or pipelines are not running, etc. For anything else please use other issue types. Thanks for taking the time! + + - type: textarea + attributes: + label: Report + description: What do you want to report? + validations: + required: true diff --git a/.github/labels.yml b/.github/labels.yml index 9a507e8..f92e955 100644 --- a/.github/labels.yml +++ b/.github/labels.yml @@ -1,6 +1,10 @@ # The labels in this file are automatically synced with the repository # using the micnncim/action-label-syncer action. --- + +### +### Pull Requests +### - name: C-dependency color: 1abc9c description: "Category: Dependency" @@ -10,3 +14,92 @@ - name: PR-merge color: 3498db description: "Pull Request: Merge when ready" + +### +### General Issues +### +- name: bug + description: "Bug Report" + color: ee0701 +- name: report + description: "General Report" + color: ef561f +- name: feature + description: "Feature Request" + color: dc8b10 +- name: question + description: "General question" + color: cc317c +- name: documentation + description: "Documentation related" + color: 45b046 + +### +### Status: Issue progress +### +- name: "status:triage" + description: "Issue needs Triaging" + color: f2a7cf +- name: "status:confirmed" + description: "Issue is confirmed" + color: f2a7cf +- name: "status:needs-more-info" + description: "Issue needs more info" + color: f2a7cf + +### +### Close +### +- name: "issue:invalid" + description: "" + color: f5c7fc +- name: "issue:invalid-type" + description: "" + color: f5c7fc +- name: "issue:duplicate" + description: "" + color: f5c7fc +- name: "issue:wontfix" + description: "" + color: f5c7fc +- name: "issue:stale" + description: "" + color: f5c7fc + +### +### Issue types +### +- name: "type:extension" + description: "" + color: 0c9cf2 +- name: "type:tool" + description: "" + color: 0c9cf2 +- name: "type:env-var" + description: "" + color: 0c9cf2 +- name: "type:config" + description: "" + color: 0c9cf2 + +### +### Issue Host specific +### +- name: "host:linux" + description: "" + color: fbca04 +- name: "host:macos" + description: "" + color: fbca04 +- name: "host:windows" + description: "" + color: fbca04 +- name: "arch:amd64" + description: "" + color: fbca04 +- name: "arch:arm64" + description: "" + color: fbca04 +- name: "arch:other" + description: "" + color: fbca04 diff --git a/.github/workflows/action_branch.yml b/.github/workflows/action_branch.yml index 3197415..8abf667 100644 --- a/.github/workflows/action_branch.yml +++ b/.github/workflows/action_branch.yml @@ -11,6 +11,13 @@ name: build # ------------------------------------------------------------------------------------------------- on: push: + paths: + - '.github/workflows/action_branch.yml' + - '.github/workflows/params.yml' + - 'Dockerfiles/**' + - 'tests/**' + - 'Makefile' + - '!**.md' jobs: diff --git a/.github/workflows/action_pull_request.yml b/.github/workflows/action_pull_request.yml index 21b075b..7ed7b6d 100644 --- a/.github/workflows/action_pull_request.yml +++ b/.github/workflows/action_pull_request.yml @@ -11,6 +11,13 @@ name: build # ------------------------------------------------------------------------------------------------- on: pull_request: + paths: + - '.github/workflows/action_pull_request.yml' + - '.github/workflows/params.yml' + - 'Dockerfiles/**' + - 'tests/**' + - 'Makefile' + - '!**.md' jobs: diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index 1a63d7e..78f68c1 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -14,6 +14,6 @@ jobs: # Drafts your next Release notes as Pull Requests are merged into "master" - uses: release-drafter/release-drafter@v5 with: - publish: true + publish: false env: GITHUB_TOKEN: ${{ secrets.RELEASE_DRAFTER_TOKEN }} diff --git a/Makefile b/Makefile index 8e386e3..2ee815a 100644 --- a/Makefile +++ b/Makefile @@ -91,6 +91,3 @@ manifest-push: docker-manifest-push .PHONY: test test: ./tests/start-ci.sh $(IMAGE) $(NAME) $(VERSION) $(DOCKER_TAG) $(ARCH) - -.PHONY: update-readme - ./build/gen-readme.sh $(IMAGE) $(NAME) $(VERSION) $(DOCKER_TAG) $(ARCH) diff --git a/README.md b/README.md index efa4732..07d05f0 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,19 @@ -# Nginx stable Docker image +# Nginx stable +[![release](https://img.shields.io/github/release/devilbox/docker-nginx-stable.svg)](https://github.com/devilbox/docker-nginx-stable/releases) +[![Github](https://img.shields.io/badge/github-docker--nginx--stable-red.svg)](https://github.com/devilbox/docker-nginx-stable) [![lint](https://github.com/devilbox/docker-nginx-stable/workflows/lint/badge.svg)](https://github.com/devilbox/docker-nginx-stable/actions?query=workflow%3Alint) [![build](https://github.com/devilbox/docker-nginx-stable/workflows/build/badge.svg)](https://github.com/devilbox/docker-nginx-stable/actions?query=workflow%3Abuild) [![nightly](https://github.com/devilbox/docker-nginx-stable/workflows/nightly/badge.svg)](https://github.com/devilbox/docker-nginx-stable/actions?query=workflow%3Anightly) +[![License](https://img.shields.io/badge/license-MIT-%233DA639.svg)](https://opensource.org/licenses/MIT) + +[![Discord](https://img.shields.io/discord/1051541389256704091?color=8c9eff&label=Discord&logo=discord)](https://discord.gg/2wP3V6kBj4) +[![Discourse](https://img.shields.io/discourse/https/devilbox.discourse.group/status.svg?colorB=%234CB697&label=Discourse&logo=discourse)](https://devilbox.discourse.group) -[![release](https://img.shields.io/github/release/devilbox/docker-nginx-stable.svg)](https://github.com/devilbox/docker-nginx-stable/releases) -[![Join the chat at https://gitter.im/devilbox/Lobby](https://badges.gitter.im/devilbox/Lobby.svg)](https://gitter.im/devilbox/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -[![Github](https://img.shields.io/badge/github-docker--nginx--stable-red.svg)](https://github.com/devilbox/docker-nginx-stable) -[![](https://images.microbadger.com/badges/license/devilbox/nginx-stable.svg)](https://microbadger.com/images/devilbox/nginx-stable "nginx-stable") -**[devilbox/docker-nginx-stable](https://github.com/devilbox/docker-nginx-stable)** +**Available Architectures:** `amd64`, `arm64`, `386`, `arm/v7`, `arm/v6` -* **Available Architectures:** `amd64`, `arm64`, `386`, `arm/v7`, `arm/v6` -* **Available Docker tags:** `latest`, `alpine`, `debian` +[![](https://img.shields.io/docker/pulls/devilbox/nginx-stable.svg)](https://hub.docker.com/r/devilbox/nginx-stable) This image is based on the official **[Nginx](https://hub.docker.com/_/nginx)** Docker image and extends it with the ability to have **virtual hosts created automatically**, as well as **adding SSL certificates** when creating new directories. For that to work, it integrates two tools that will take care about the whole process: **[watcherd](https://github.com/devilbox/watcherd)** and **[vhost-gen](https://github.com/devilbox/vhost-gen)**. @@ -20,167 +21,190 @@ From a users perspective, you mount your local project directory into the contai **HTTP/2 is enabled by default for all SSL connections.** -| Docker Hub | Upstream Project | -|------------|------------------| -| | | - -**[Apache 2.2](https://github.com/devilbox/docker-apache-2.2) | [Apache 2.4](https://github.com/devilbox/docker-apache-2.4) | Nginx stable | [Nginx mainline](https://github.com/devilbox/docker-nginx-mainline)** - ----- - - -## Usage -#### Automated virtual hosts +> ##### ๐Ÿฑ GitHub: [devilbox/docker-nginx-stable](https://github.com/devilbox/docker-nginx-stable) -1. Automated virtual hosts can be enabled by providing `-e MASS_VHOST_ENABLE=1`. -2. You should mount a local project directory into the Docker under `/shared/httpd` (`-v /local/path:/shared/httpd`). -3. You can optionally specify a global server name suffix via e.g.: `-e MASS_VHOST_TLD=.loc` -4. You can optionally specify a global subdirectory from which the virtual host will servve the documents via e.g.: `-e MASS_VHOST_DOCROOT=www` -5. Allow the Docker to expose its port via `-p 80:80`. -6. Have DNS names point to the IP address the container runs on (e.g. via `/etc/hosts`) +| Web Server Project | Reference Implementation | +|:-------------------:|:------------------------:| +| | | +| Streamlined Webserver images | The [Devilbox](https://github.com/cytopia/devilbox) | -With the above described settings, whenever you create a local directory under your projects dir -such as `/local/path/mydir`, there will be a new virtual host created by the same name -`http://mydir`. You can also specify a global suffix for the vhost names via -`-e MASS_VHOST_TLD=.loc`, afterwards your above created vhost would be reachable via -`http://mydir.loc`. - -Just to give you a few examples: - -**Assumption:** `/local/path` is mounted to `/shared/httpd` +**[Apache 2.2](https://github.com/devilbox/docker-apache-2.2) | [Apache 2.4](https://github.com/devilbox/docker-apache-2.4) | Nginx stable | [Nginx mainline](https://github.com/devilbox/docker-nginx-mainline)** -| Directory | `MASS_VHOST_DOCROOT` | `MASS_VHOST_TLD` | Serving from (*) | Via | -|-----------|----------------------|------------------|--------------------------|----------------------| -| work1/ | htdocs/ | | /local/path/work1/htdocs | http://work1 | -| work1/ | www/ | | /local/path/work1/www | http://work1 | -| work1/ | htdocs/ | .loc | /local/path/work1/htdocs | http://work1.loc | -| work1/ | www/ | .loc | /local/path/work1/www | http://work1.loc | +---- -(*) This refers to the directory on your host computer -**Assumption:** `/tmp` is mounted to `/shared/httpd` +## ๐Ÿ‹ Available Docker tags -| Directory | `MASS_VHOST_DOCROOT` | `MASS_VHOST_TLD` | Serving from (*) | Via | -|-----------|----------------------|------------------|--------------------------|----------------------| -| api/ | htdocs/ | | /tmp/api/htdocs | http://api | -| api/ | www/ | | /tmp/api/www | http://api | -| api/ | htdocs/ | .test.com | /tmp/api/htdocs | http://api.test.com | -| api/ | www/ | .test.com | /tmp/api/www | http://api.test.com | +[![](https://img.shields.io/docker/pulls/devilbox/nginx-stable.svg)](https://hub.docker.com/r/devilbox/nginx-stable) -(*) This refers to the directory on your host computer +[`latest`][tag_latest] [`debian`][tag_debian] [`alpine`][tag_alpine] +```bash +docker pull devilbox/nginx-stable +``` -You would start it as follows: +[tag_latest]: https://github.com/devilbox/docker-nginx-stable/blob/master/Dockerfiles/Dockerfile.latest +[tag_debian]: https://github.com/devilbox/docker-nginx-stable/blob/master/Dockerfiles/Dockerfile.debian +[tag_alpine]: https://github.com/devilbox/docker-nginx-stable/blob/master/Dockerfiles/Dockerfile.alpine -```shell -docker run -it \ - -p 80:80 \ - -e MASS_VHOST_ENABLE=1 \ - -e MASS_VHOST_DOCROOT=www \ - -e MASS_VHOST_TLD=.loc \ - -v /local/path:/shared/httpd \ - devilbox/nginx-stable -``` -#### Customization per virtual host +#### Rolling releases -Each virtual host is generated from templates by **[vhost-gen](https://github.com/devilbox/vhost-gen/tree/master/etc/templates)**. As `vhost-gen` is really flexible and allows combining multiple templates, you can copy and alter an existing template and then place it in a subdirectory of your project folder. The subdirectory is specified by `MASS_VHOST_TPL`. +The following Docker image tags are rolling releases and are built and updated every night. -**Assumption:** `/local/path` is mounted to `/shared/httpd` +[![nightly](https://github.com/devilbox/docker-nginx-stable/workflows/nightly/badge.svg)](https://github.com/devilbox/docker-nginx-stable/actions?query=workflow%3Anightly) -| Directory | `MASS_VHOST_TPL` | Templates are then read from (*) | -|-----------|------------------|------------------------------| -| work1/ | cfg/ | /local/path/work1/cfg/ | -| api/ | cfg/ | /local/path/api/cfg/ | -| work1/ | conf/ | /local/path/work1/conf/ | -| api/ | conf/ | /local/path/api/conf/ | +| Docker Tag | Git Ref | Available Architectures | +|----------------------------------|--------------|-----------------------------------------------| +| **[`latest`][tag_latest]** | master | `amd64`, `i386`, `arm64`, `arm/v7`, `arm/v6` | +| [`debian`][tag_debian] | master | `amd64`, `i386`, `arm64`, `arm/v7`, `arm/v6` | +| [`alpine`][tag_alpine] | master | `amd64`, `i386`, `arm64`, `arm/v7`, `arm/v6` | -(*) This refers to the directory on your host computer -#### Customizing the default virtual host +#### Point in time releases -The default virtual host can also be overwritten with a custom template. Use `MAIN_VHOST_TPL` variable in order to set the subdirectory to look for template files. +The following Docker image tags are built once and can be used for reproducible builds. Its version never changes so you will have to update tags in your pipelines from time to time in order to stay up-to-date. -#### Enabling PHP-FPM +[![build](https://github.com/devilbox/docker-nginx-stable/workflows/build/badge.svg)](https://github.com/devilbox/docker-nginx-stable/actions?query=workflow%3Abuild) -PHP-FPM is not included inside this Docker container, but can be enabled to contact a remote PHP-FPM server. To do so, you must enable it and at least specify the remote PHP-FPM server address (hostname or IP address). Additionally you must mount the data dir under the same path into the PHP-FPM docker container as it is mounted into the web server. +| Docker Tag | Git Ref | Available Architectures | +|----------------------------------|--------------|-----------------------------------------------| +| **[``][tag_latest]** | git: `` | `amd64`, `i386`, `arm64`, `arm/v7`, `arm/v6` | +| [`-debian`][tag_debian] | git: `` | `amd64`, `i386`, `arm64`, `arm/v7`, `arm/v6` | +| [`-alpine`][tag_alpine] | git: `` | `amd64`, `i386`, `arm64`, `arm/v7`, `arm/v6` | -**Note:** When PHP-FPM is enabled, it is enabled for the default virtual host as well as for all other automatically created mass virtual hosts. +> ๐Ÿ›ˆ Where `` refers to the chosen git tag from this repository.
+> โš  **Warning:** The latest available git tag is also build every night and considered a rolling tag. -#### Disabling the default virtual host -If you only want to server you custom projects and don't need the default virtual host, you can disable it by `-e MAIN_VHOST_ENABLE=0`. +## โœฐ Features +> ๐Ÿ›ˆ For details see **[Documentation: Features](doc/features.md)** -## Options +### Automated virtual hosts -#### Environmental variables +Virtual hosts are created automatically, simply by creating a new project directory (inside or outside of the container). This allows you to quickly create new projects and work on them in your IDE without the hassle of configuring the web server. -This Docker container adds a lot of injectables in order to customize it to your needs. See the table below for a detailed description. +### Automated PHP-FPM setup -##### Required environmental variables +PHP is not included in the provided images, but you can link the Docker container to a PHP-FPM image with any PHP version. This allows you to easily switch PHP versions and choose one which is currently required. -`PHP_FPM_SERVER_ADDR` is required when enabling PHP FPM. +### Automated SSL certificate generation -##### Optional environmental variables (nginx) +SSL certificates are generated automatically for each virtual host to allow you to develop over HTTP and HTTPS. -| Variable | Type | Default | Description | -|----------|------|---------|-------------| -| WORKER_CONNECTIONS | int | `1024` | [worker_connections](https://nginx.org/en/docs/ngx_core_module.html#worker_connections) | -| WORKER_PROCESSES | int or `auto` | `auto` | [worker_processes](https://nginx.org/en/docs/ngx_core_module.html#worker_processes) | +### Automatically trusted HTTPS + +SSL certificates are signed by a certificate authority (which is also being generated). The CA file can be mounted locally and imported into your browser, which allows you to automatically treat all generated virtual host certificates as trusted. + +### Customization per virtual host + +Each virtual host can individually be fully customized via `vhost-gen` templates. + +### Customization for the default virtual host + +The default virtual host is also treated differently from the auto-generated mass virtual hosts. You can choose to disable it or use it for a generic overview page for all of your created projects. -##### Optional environmental variables (general) +### Reverse Proxy integration -| Variable | Type | Default | Description | -|----------|------|---------|-------------| -| DEBUG_ENTRYPOINT | int | `0` | Show settings and shell commands executed during startup.
Values:
`0`: Off
`1`: Show settings
`2`: Show settings and commands | -| DEBUG_RUNTIME | bool | `0` | Be verbose during runtime.
Value: `0` or `1` | -| DOCKER_LOGS | bool | `0` | When set to `1` will redirect error and access logs to Docker logs (`stderr` and `stdout`) instead of file inside container.
Value: `0` or `1` | -| TIMEZONE | string | `UTC` | Set docker OS timezone.
(Example: `Europe/Berlin`) | -| NEW_UID | int | `101` | Assign the default Nginx user a new UID. This is useful if you you mount your document root and want to match the file permissions to the one of your local user. Set it to your host users uid (see `id` for your uid). | -| NEW_GID | int | `101` | This is useful if you you mount your document root and want to match the file permissions to the one of your local user group. Set it to your host user groups gid (see `id` for your gid). | -| PHP_FPM_ENABLE | bool | `0` | Enable PHP-FPM for the default vhost and the mass virtual hosts. | -| PHP_FPM_SERVER_ADDR | string | `` | IP address or hostname of remote PHP-FPM server.
Required when enabling PHP. | -| PHP_FPM_SERVER_PORT | int | `9000` | Port of remote PHP-FPM server | -| PHP_FPM_TIMEOUT | int | `180` | Timeout in seconds to upstream PHP-FPM server | -| HTTP2_ENABLE | int | `1` | Enabled or disabled HTTP2 support.
Values:
`0`: Disabled
`1`: Enabled
Defaults to Enabled | +Through virtual host customization, any project can also be served with a reverse proxy. This is useful if you want to run NodeJS or Python projects which require a reverse proxy and still want to benefit with a custom domain and auto-generated SSL certificates. -##### Optional environmental variables (default vhost) +### Local file system permission sync -| Variable | Type | Default | Description | -|----------|------|---------|-------------| -| MAIN_VHOST_ENABLE | bool | `1` | By default there is a standard (catch-all) vhost configured to accept requests served from `/var/www/default/htdocs`. If you want to disable it, set the value to `0`.
Note:The `htdocs` dir name can be changed with `MAIN_VHOST_DOCROOT`. See below. | -| MAIN_VHOST_SSL_TYPE | string | `plain` |
  • plain - only serve via http
  • ssl - only serve via https
  • both - serve via http and https
  • redir - serve via https and redirect http to https
| -| MAIN_VHOST_SSL_GEN | bool | `0` | `0`: Do not generate an ssl certificate
`1`: Generate self-signed certificate automatically | -| MAIN_VHOST_SSL_CN | string | `localhost` | Comma separated list of CN names for SSL certificate generation (The domain names by which you want to reach the default server) | -| MAIN_VHOST_DOCROOT | string | `htdocs`| This is the directory name appended to `/var/www/default/` from which the default virtual host will serve its files.
Default:
`/var/www/default/htdocs`
Example:
`MAIN_VHOST_DOCROOT=www`
Doc root: `/var/www/default/www` | -| MAIN_VHOST_TPL | string | `cfg` | Directory within th default vhost base path (`/var/www/default`) to look for templates to overwrite virtual host settings. See [vhost-gen](https://github.com/devilbox/vhost-gen/tree/master/etc/templates) for available template files.
Resulting default path:
`/var/www/default/cfg` | -| MAIN_VHOST_STATUS_ENABLE | bool | `0` | Enable httpd status page. | -| MAIN_VHOST_STATUS_ALIAS | string | `/httpd-status` | Set the alias under which the httpd server should serve its status page. | +File system permissions of files/dirs inside the running Docker container are synced with the permission on your host system. This is accomplished by specifying a user- and group-id to the `docker run` command. -##### Optional environmental variables (mass vhosts) -| Variable | Type | Default | Description | -|----------|------|---------|-------------| -| MASS_VHOST_ENABLE | bool | `0` | You can enable mass virtual hosts by setting this value to `1`. Mass virtual hosts will be created for each directory present in `/shared/httpd` by the same name including a top-level domain suffix (which could also be a domain+tld). See `MASS_VHOST_TLD` for how to set it. | -| MASS_VHOST_SSL_TYPE | string | `plain` |
  • plain - only serve via http
  • ssl - only serve via https
  • both - serve via http and https
  • redir - serve via https and redirect http to https
| -| MASS_VHOST_SSL_GEN | bool | `0` | `0`: Do not generate an ssl certificate
`1`: Generate self-signed certificate automatically | -| MASS_VHOST_TLD | string | `.loc`| This string will be appended to the server name (which is built by its directory name) for mass virtual hosts and together build the final domain.
Default:`.loc`
Example:
Path: `/shared/httpd/temp`
`MASS_VHOST_TLD=.lan`
Server name: `temp.lan`
Example:
Path:`/shared/httpd/api`
`MASS_VHOST_TLD=.example.com`
Server name: `api.example.com` | -| MASS_VHOST_DOCROOT | string | `htdocs`| This is a subdirectory within your project dir under each project from which the web server will serve its files.
`/shared/httpd//$MASS_VHOST_DOCROOT/`
Default:
`/shared/httpd//htdocs/` | -| MASS_VHOST_TPL | string | `cfg` | Directory within your new virtual host to look for templates to overwrite virtual host settings. See [vhost-gen](https://github.com/devilbox/vhost-gen/tree/master/etc/templates) for available template files.
`/shared/httpd//$MASS_VHOST_TPL/`
Resulting default path:
`/shared/httpd//cfg/` | +## โˆ‘ Environment Variables +The provided Docker images add a lot of injectables in order to customize it to your needs. See the table below for a brief overview. -#### Available mount points +> ๐Ÿ›ˆ For details see **[Documentation: Environment variables](doc/environment-variables.md)** -| Docker | Description | -|---------------------|-------------| -| /etc/httpd-custom.d | Mount this directory to add outside configuration files (`*.conf`) to Nginx | -| /var/www/default | Nginx default virtual host base path (contains by default `htdocs/` and `cfg/` | -| /shared/httpd | Nginx mass virtual host root directory | -| /etc/vhost-gen.d | [vhost-gen](https://github.com/devilbox/vhost-gen) directory for custom templates. Copy and customize [nginx.yml](https://github.com/devilbox/vhost-gen/blob/master/etc/templates/nginx.yml) into this mounted directory for global vhost customizations | + + + + + + + + + + + + + + + + + + + + + +
NginxLoggingFeatures
+ WORKER_CONNECTIONS
+ WORKER_PROCESSES
+ HTTP2_ENABLE
+
+ DEBUG_ENTRYPOINT
+ DEBUG_RUNTIME
+ DOCKER_LOGS
+
+ TIMEZONE
+ NEW_UID
+ NEW_GID
+
Main vHostMass vHostPHP
+ MAIN_VHOST_ENABLE
+ MAIN_VHOST_SSL_TYPE
+ MAIN_VHOST_SSL_GEN
+ MAIN_VHOST_SSL_CN
+ MAIN_VHOST_DOCROOT
+ MAIN_VHOST_TPL
+ MAIN_VHOST_STATUS_ENABLE
+ MAIN_VHOST_STATUS_ALIAS
+
+ MASS_VHOST_ENABLE
+ MASS_VHOST_SSL_TYPE
+ MASS_VHOST_SSL_GEN
+ MASS_VHOST_TLD
+ MASS_VHOST_DOCROOT
+ MASS_VHOST_TPL
+
+ PHP_FPM_ENABLE
+ PHP_FPM_SERVER_ADDR
+ PHP_FPM_SERVER_PORT
+ PHP_FPM_TIMEOUT
+
-#### Default ports +## ๐Ÿ“‚ Volumes + +The provided Docker images offer the following internal paths to be mounted to your local file system. + +> ๐Ÿ›ˆ For details see **[Documentation: Volumes](doc/volumes.md)** + + + + + + + + + + + +
Data dirConfig dir
+ /var/www/default/
+ /shared/httpd/
+
+ /etc/httpd-custom.d/
+ /etc/vhost-gen.d/
+
+ + +## ๐Ÿ–ง Exposed Ports + +When you plan on using `443` you should enable automated SSL certificate generation. | Docker | Description | |--------|-------------| @@ -188,65 +212,73 @@ This Docker container adds a lot of injectables in order to customize it to your | 443 | HTTPS listening Port | -## Examples +## ๐Ÿ’ก Examples -#### 1. Serve static files +### Serve static files -Mount your local directort `~/my-host-www` into the docker and server those files. +Mount your local directort `~/my-host-www` into the container and server those files. **Note:** Files will be server from `~/my-host-www/htdocs`. ```bash -$ docker run -d -p 80:80 -v ~/my-host-www:/var/www/default -t devilbox/nginx-stable +docker run -d -it \ + -p 80:80 \ + -v ~/my-host-www:/var/www/default \ + devilbox/nginx-stable ``` -#### 2. Serve PHP files with PHP-FPM - -Note, for this to work, the `~/my-host-www` dir must be mounted into the Nginx Docker as well as into the php-fpm docker. +### Serve PHP files with PHP-FPM -You can also attach other PHP-FPM version: [PHP-FPM 5.4](https://github.com/cytopia/docker-php-fpm-5.4), [PHP-FPM 5.5](https://github.com/cytopia/docker-php-fpm-5.5), [PHP-FPM 5.6](https://github.com/cytopia/docker-php-fpm-5.6), [PHP-FPM 7.0](https://github.com/cytopia/docker-php-fpm-7.0), [PHP-FPM 7.1](https://github.com/cytopia/docker-php-fpm-7.1), [PHP-FPM 7.2](https://github.com/cytopia/docker-php-fpm-7.2) or [HHVM](https://github.com/cytopia/docker-hhvm-latest). +| PHP-FPM Reference Images | +|--------------------------| +| | -Each PHP-FPM docker also has the option to enable Xdebug and more, see their respective Readme files for futher settings. +Note, for this to work, the `~/my-host-www` dir must be mounted into the Nginx container as well as into the php-fpm container. +Each PHP-FPM container also has the option to enable Xdebug and more, see their respective Readme files for futher settings. ```bash -# Start the PHP-FPM docker, mounting the same diectory -$ docker run -d -p 9000 -v ~/my-host-www:/var/www/default --name php cytopia/php-fpm-5.6 +# Start the PHP-FPM container, mounting the same diectory +docker run -d -it \ + --name php \ + -p 9000 \ + -v ~/my-host-www:/var/www/default \ + devilbox/php-fpm:5.6-prod -# Start the Nginx Docker, linking it to the PHP-FPM docker -$ docker run -d \ +# Start the Nginx Docker, linking it to the PHP-FPM container +docker run -d -it \ -p 80:80 \ -v ~/my-host-www:/var/www/default \ -e PHP_FPM_ENABLE=1 \ -e PHP_FPM_SERVER_ADDR=php \ -e PHP_FPM_SERVER_PORT=9000 \ --link php \ - -t devilbox/nginx-stable + devilbox/nginx-stable ``` -#### 3. Fully functional LEMP stack +### Fully functional LEMP stack -Same as above, but also add a MySQL docker and link it into Nginx. +Same as above, but also add a MySQL container and link it into Nginx. ```bash -# Start the MySQL docker -$ docker run -d \ +# Start the MySQL container +docker run -d -it \ + --name mysql \ -p 3306:3306 \ -e MYSQL_ROOT_PASSWORD=my-secret-pw \ - --name mysql \ - -t cytopia/mysql-5.5 + devilbox/mysql:mysql-5.5 -# Start the PHP-FPM docker, mounting the same diectory. +# Start the PHP-FPM container, mounting the same diectory. # Also make sure to # forward the remote MySQL port 3306 to 127.0.0.1:3306 within the -# PHP-FPM docker in order to be able to use `127.0.0.1` for mysql -# connections from within the php docker. -$ docker run -d \ +# PHP-FPM container in order to be able to use `127.0.0.1` for mysql +# connections from within the php container. +docker run -d -it \ + --name php \ -p 9000:9000 \ -v ~/my-host-www:/var/www/default \ -e FORWARD_PORTS_TO_LOCALHOST=3306:mysql:3306 \ - --name php \ - cytopia/php-fpm-5.6 + devilbox/php-fpm:5.6-prod -# Start the Nginx Docker, linking it to the PHP-FPM docker -$ docker run -d \ +# Start the Nginx Docker, linking it to the PHP-FPM container +docker run -d -it \ -p 80:80 \ -v ~/my-host-www:/var/www/default \ -e PHP_FPM_ENABLE=1 \ @@ -254,25 +286,121 @@ $ docker run -d \ -e PHP_FPM_SERVER_PORT=9000 \ --link php \ --link mysql \ - -t devilbox/nginx-stable + devilbox/nginx-stable ``` -#### 4. Ultimate pre-configured docker-compose setup - -Have a look at the **[Devilbox](https://github.com/cytopia/devilbox)** for a fully-customizable docker-compose variant. - -It offers pre-configured mass virtual hosts and an intranet. - -It allows any of the following combinations: -* PHP 5.2, PHP 5.3, PHP 5.4, PHP 5.5, PHP 5.6, PHP 7.0, PHP 7.1, PHP 7.2, PHP 7.3, PHP 7.4 and PHP 8.0 -* MySQL 5.5, MySQL 5.6, MySQL 5.7, MariaDB 5 and MariaDB 10 -* Apache 2.2, Apache 2.4, Nginx stable and Nginx mainline -* And more to come... - - -## Version - -``` -nginx version: nginx/1.20.2 -``` +## ๐Ÿ–ค Sister Projects + +Show some love for the following sister projects. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
๐Ÿ–ค Project๐Ÿฑ GitHub๐Ÿ‹ DockerHub
Devilbox
docker-php-fpmdevilbox/php-fpm
docker-php-fpm-communitydevilbox/php-fpm-community
docker-mysqldevilbox/mysql
+ docker-apache-2.2
+ docker-apache-2.4
+ docker-nginx-stable
+ docker-nginx-mainline +
+ devilbox/apache-2.2
+ devilbox/apache-2.4
+ devilbox/nginx-stable
+ devilbox/nginx-mainline +
+ + +## ๐Ÿ‘ซ Community + +In case you seek help, go and visit the community pages. + + + + + + + + + + + + + + + + + + + + + +

๐Ÿ“˜ Documentation

๐ŸŽฎ Discord

๐Ÿ—ช Forum

+ + + + + + + + + + + +
devilbox.readthedocs.iodiscord/devilboxdevilbox.discourse.group
+ + +## ๐Ÿง˜ Maintainer + +**[@cytopia](https://github.com/cytopia)** + +I try to keep up with literally **over 100 projects** besides a full-time job. +If my work is making your life easier, consider contributing. ๐Ÿ–ค + +* [GitHub Sponsorship](https://github.com/sponsors/cytopia) +* [Patreon](https://www.patreon.com/devilbox) +* [Open Collective](https://opencollective.com/devilbox) + +**Findme:** +**๐Ÿฑ** [cytopia](https://github.com/cytopia) / [devilbox](https://github.com/devilbox) | +**๐Ÿ‹** [cytopia](https://hub.docker.com/r/cytopia/) / [devilbox](https://hub.docker.com/r/devilbox/) | +**๐Ÿฆ** [everythingcli](https://twitter.com/everythingcli) / [devilbox](https://twitter.com/devilbox) | +**๐Ÿ“–** [everythingcli.org](http://www.everythingcli.org/) + +**Contrib:** PyPI: [cytopia](https://pypi.org/user/cytopia/) **ยท** +Terraform: [cytopia](https://registry.terraform.io/namespaces/cytopia) **ยท** +Ansible: [cytopia](https://galaxy.ansible.com/cytopia) + + +## ๐Ÿ—Ž License + +**[MIT License](LICENSE)** + +Copyright (c) 2016 [cytopia](https://github.com/cytopia) diff --git a/build/gen-readme.sh b/build/gen-readme.sh deleted file mode 100755 index 16f1073..0000000 --- a/build/gen-readme.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh -eu - - -### -### Globals -### -CWD="$(cd -P -- "$(dirname -- "$0")" && pwd -P)/.." -IMAGE="${1}" -ARCH="${2}" - -### -### Retrieve information afterwards and Update README.md -### -INFO="$( docker run --rm --platform "${ARCH}" --entrypoint=nginx "${IMAGE}" -v 2>&1 | tr -d '\r' )" - -echo "${INFO}" -sed -i'' '/##[[:space:]]Version/q' "${CWD}/README.md" -{ - echo ""; - echo '```'; - echo "${INFO}"; - echo '```'; -} >> "${CWD}/README.md" diff --git a/doc/environment-variables.md b/doc/environment-variables.md new file mode 100644 index 0000000..f94d3ec --- /dev/null +++ b/doc/environment-variables.md @@ -0,0 +1,65 @@ +[Features](features.md) | +**Environment variables** | +[Volumes](volumes.md) + +--- + +# Documentation: Environment Variables + + +This Docker container adds a lot of injectables in order to customize it to your needs. See the table below for a detailed description. + +## Required environmental variables + +`PHP_FPM_SERVER_ADDR` is required when enabling PHP FPM. + + +## Optional environmental variables (nginx) + +| Variable | Type | Default | Description | +|----------|------|---------|-------------| +| `WORKER_CONNECTIONS` | int | `1024` | [worker_connections](https://nginx.org/en/docs/ngx_core_module.html#worker_connections) | +| `WORKER_PROCESSES` | int or `auto` | `auto` | [worker_processes](https://nginx.org/en/docs/ngx_core_module.html#worker_processes) | + + +## Optional environmental variables (general) + +| Variable | Type | Default | Description | +|----------|------|---------|-------------| +| `DEBUG_ENTRYPOINT` | int | `0` | Show settings and shell commands executed during startup.
Values:
`0`: Off
`1`: Show settings
`2`: Show settings and commands | +| `DEBUG_RUNTIME` | bool | `0` | Be verbose during runtime.
Value: `0` or `1` | +| `DOCKER_LOGS` | bool | `0` | When set to `1` will redirect error and access logs to Docker logs (`stderr` and `stdout`) instead of file inside container.
Value: `0` or `1` | +| `TIMEZONE` | string | `UTC` | Set docker OS timezone.
(Example: `Europe/Berlin`) | +| `NEW_UID` | int | `101` | Assign the default Nginx user a new UID. This is useful if you you mount your document root and want to match the file permissions to the one of your local user. Set it to your host users uid (see `id` for your uid). | +| `NEW_GID` | int | `101` | This is useful if you you mount your document root and want to match the file permissions to the one of your local user group. Set it to your host user groups gid (see `id` for your gid). | +| `PHP_FPM_ENABLE` | bool | `0` | Enable PHP-FPM for the default vhost and the mass virtual hosts. | +| `PHP_FPM_SERVER_ADDR` | string | `` | IP address or hostname of remote PHP-FPM server.
Required when enabling PHP. | +| `PHP_FPM_SERVER_PORT` | int | `9000` | Port of remote PHP-FPM server | +| `PHP_FPM_TIMEOUT` | int | `180` | Timeout in seconds to upstream PHP-FPM server | +| `HTTP2_ENABLE` | int | `1` | Enabled or disabled HTTP2 support.
Values:
`0`: Disabled
`1`: Enabled
Defaults to Enabled | + + +## Optional environmental variables (default vhost) + +| Variable | Type | Default | Description | +|----------|------|---------|-------------| +| `MAIN_VHOST_ENABLE` | bool | `1` | By default there is a standard (catch-all) vhost configured to accept requests served from `/var/www/default/htdocs`. If you want to disable it, set the value to `0`.
Note:The `htdocs` dir name can be changed with `MAIN_VHOST_DOCROOT`. See below. | +| `MAIN_VHOST_SSL_TYPE` | string | `plain` |
  • plain - only serve via http
  • ssl - only serve via https
  • both - serve via http and https
  • redir - serve via https and redirect http to https
| +| `MAIN_VHOST_SSL_GEN` | bool | `0` | `0`: Do not generate an ssl certificate
`1`: Generate self-signed certificate automatically | +| `MAIN_VHOST_SSL_CN` | string | `localhost` | Comma separated list of CN names for SSL certificate generation (The domain names by which you want to reach the default server) | +| `MAIN_VHOST_DOCROOT` | string | `htdocs`| This is the directory name appended to `/var/www/default/` from which the default virtual host will serve its files.
Default:
`/var/www/default/htdocs`
Example:
`MAIN_VHOST_DOCROOT=www`
Doc root: `/var/www/default/www` | +| `MAIN_VHOST_TPL` | string | `cfg` | Directory within th default vhost base path (`/var/www/default`) to look for templates to overwrite virtual host settings. See [vhost-gen](https://github.com/devilbox/vhost-gen/tree/master/etc/templates) for available template files.
Resulting default path:
`/var/www/default/cfg` | +| `MAIN_VHOST_STATUS_ENABLE` | bool | `0` | Enable httpd status page. | +| `MAIN_VHOST_STATUS_ALIAS` | string | `/httpd-status` | Set the alias under which the httpd server should serve its status page. | + + +## Optional environmental variables (mass vhosts) + +| Variable | Type | Default | Description | +|----------|------|---------|-------------| +| `MASS_VHOST_ENABLE` | bool | `0` | You can enable mass virtual hosts by setting this value to `1`. Mass virtual hosts will be created for each directory present in `/shared/httpd` by the same name including a top-level domain suffix (which could also be a domain+tld). See `MASS_VHOST_TLD` for how to set it. | +| `MASS_VHOST_SSL_TYPE` | string | `plain` |
  • plain - only serve via http
  • ssl - only serve via https
  • both - serve via http and https
  • redir - serve via https and redirect http to https
| +| `MASS_VHOST_SSL_GEN` | bool | `0` | `0`: Do not generate an ssl certificate
`1`: Generate self-signed certificate automatically | +| `MASS_VHOST_TLD` | string | `.loc`| This string will be appended to the server name (which is built by its directory name) for mass virtual hosts and together build the final domain.
Default:`.loc`
Example:
Path: `/shared/httpd/temp`
`MASS_VHOST_TLD=.lan`
Server name: `temp.lan`
Example:
Path:`/shared/httpd/api`
`MASS_VHOST_TLD=.example.com`
Server name: `api.example.com` | +| `MASS_VHOST_DOCROOT` | string | `htdocs`| This is a subdirectory within your project dir under each project from which the web server will serve its files.
`/shared/httpd//$MASS_VHOST_DOCROOT/`
Default:
`/shared/httpd//htdocs/` | +| `MASS_VHOST_TPL` | string | `cfg` | Directory within your new virtual host to look for templates to overwrite virtual host settings. See [vhost-gen](https://github.com/devilbox/vhost-gen/tree/master/etc/templates) for available template files.
`/shared/httpd//$MASS_VHOST_TPL/`
Resulting default path:
`/shared/httpd//cfg/` | diff --git a/doc/features.md b/doc/features.md new file mode 100644 index 0000000..0c7844a --- /dev/null +++ b/doc/features.md @@ -0,0 +1,92 @@ +**Features** | +[Environment variables](environment-variables.md) | +[Volumes](volumes.md) + +--- + +# Documentation: Features + + +## Automated virtual hosts + +1. Automated virtual hosts can be enabled by providing `-e MASS_VHOST_ENABLE=1`. +2. You should mount a local project directory into the Docker under `/shared/httpd` (`-v /local/path:/shared/httpd`). +3. You can optionally specify a global server name suffix via e.g.: `-e MASS_VHOST_TLD=.loc` +4. You can optionally specify a global subdirectory from which the virtual host will servve the documents via e.g.: `-e MASS_VHOST_DOCROOT=www` +5. Allow the Docker to expose its port via `-p 80:80`. +6. Have DNS names point to the IP address the container runs on (e.g. via `/etc/hosts`) + +With the above described settings, whenever you create a local directory under your projects dir +such as `/local/path/mydir`, there will be a new virtual host created by the same name +`http://mydir`. You can also specify a global suffix for the vhost names via +`-e MASS_VHOST_TLD=.loc`, afterwards your above created vhost would be reachable via +`http://mydir.loc`. + +Just to give you a few examples: + +**Assumption:** `/local/path` is mounted to `/shared/httpd` + +| Directory | `MASS_VHOST_DOCROOT` | `MASS_VHOST_TLD` | Serving from (*) | Via | +|-----------|----------------------|------------------|--------------------------|----------------------| +| work1/ | htdocs/ | | /local/path/work1/htdocs | http://work1 | +| work1/ | www/ | | /local/path/work1/www | http://work1 | +| work1/ | htdocs/ | .loc | /local/path/work1/htdocs | http://work1.loc | +| work1/ | www/ | .loc | /local/path/work1/www | http://work1.loc | + +(*) This refers to the directory on your host computer + +**Assumption:** `/tmp` is mounted to `/shared/httpd` + +| Directory | `MASS_VHOST_DOCROOT` | `MASS_VHOST_TLD` | Serving from (*) | Via | +|-----------|----------------------|------------------|--------------------------|----------------------| +| api/ | htdocs/ | | /tmp/api/htdocs | http://api | +| api/ | www/ | | /tmp/api/www | http://api | +| api/ | htdocs/ | .test.com | /tmp/api/htdocs | http://api.test.com | +| api/ | www/ | .test.com | /tmp/api/www | http://api.test.com | + +(*) This refers to the directory on your host computer + +You would start it as follows: + +```shell +docker run -it \ + -p 80:80 \ + -e MASS_VHOST_ENABLE=1 \ + -e MASS_VHOST_DOCROOT=www \ + -e MASS_VHOST_TLD=.loc \ + -v /local/path:/shared/httpd \ + devilbox/nginx-stable +``` + + +## Automated PHP-FPM setup + +PHP-FPM is not included inside this Docker container, but can be enabled to contact a remote PHP-FPM server. To do so, you must enable it and at least specify the remote PHP-FPM server address (hostname or IP address). Additionally you must mount the data dir under the same path into the PHP-FPM docker container as it is mounted into the web server. + +**Note:** When PHP-FPM is enabled, it is enabled for the default virtual host as well as for all other automatically created mass virtual hosts. + + +## Customization per virtual host + +Each virtual host is generated from templates by **[vhost-gen](https://github.com/devilbox/vhost-gen/tree/master/etc/templates)**. As `vhost-gen` is really flexible and allows combining multiple templates, you can copy and alter an existing template and then place it in a subdirectory of your project folder. The subdirectory is specified by `MASS_VHOST_TPL`. + +**Assumption:** `/local/path` is mounted to `/shared/httpd` + +| Directory | `MASS_VHOST_TPL` | Templates are then read from (*) | +|-----------|------------------|------------------------------| +| work1/ | cfg/ | /local/path/work1/cfg/ | +| api/ | cfg/ | /local/path/api/cfg/ | +| work1/ | conf/ | /local/path/work1/conf/ | +| api/ | conf/ | /local/path/api/conf/ | + +(*) This refers to the directory on your host computer + + +## Customization for the default virtual host + +The default virtual host can also be overwritten with a custom template. Use `MAIN_VHOST_TPL` variable in order to set the subdirectory to look for template files. + + +## Disabling the default virtual host + +If you only want to server you custom projects and don't need the default virtual host, you can disable it by `-e MAIN_VHOST_ENABLE=0`. diff --git a/doc/volumes.md b/doc/volumes.md new file mode 100644 index 0000000..9328d63 --- /dev/null +++ b/doc/volumes.md @@ -0,0 +1,61 @@ +[Features](features.md) | +[Environment variables](environment-variables.md) | +**Volumes** + +--- + +# Documentation: Volumes + + +## `/var/www/default/` + +* **type:** data directory +* **purpose:** website files for the default virtual host + +Files in this directory are used to serve the default virtual host. + +Mount this directory to your local file system in order to add html, js, php, etc files and edit them with your local IDE/editor. + +**Note:** You can disable the default virtual host and then don't need to mount this directory. + +```bash +docker run -d -it \ + -v $(pwd)/default:/var/www/default \ + -e MAIN_VHOST_ENABLE=1 \ + devilbox/nginx-stable +``` + + +## `/shared/httpd/` + +* **type:** data directory +* **purpose:** website files for the mass virtual hosts (your projects) + +This directory contains all your projects. When a new directory is created inside this directory, a new virtual host is automatically created by the web server. + +Mount this directory to your local file system in order to add html, js, php, etc files and edit them with your local IDE/editor. + +**Note:** You can disable mass virtual hosts and then don't need to mount this directory. + +```bash +docker run -d -it \ + -v $(pwd)/projects:/shared/httpd \ + -e MASS_VHOST_ENABLE=1 \ + devilbox/nginx-stable +``` + + +## `/etc/httpd-custom.d/` + +* **type:** config directory +* **purpose:** Add `*.conf` files to alter the webserver behaviour + +Mount this directory to your local file system and add any valid `*.conf` files to alter the web server behaviour. + + +## `/etc/vhost-gen.d/` + +* **type:** config directory +* **purpose:** Add [vhost-gen](https://github.com/devilbox/vhost-gen) templates to alter the webserver behaviour + +Copy and customize [nginx.yml](https://github.com/devilbox/vhost-gen/blob/master/etc/templates/nginx.yml) into this mounted directory for global vhost customizations.