|
1 | 1 | # docker-nginx
|
2 |
| -Provides base OS, patches and stable nginx for quick and easy spinup |
| 2 | +Provides base OS, patches and stable nginx for quick and easy spinup. |
| 3 | +Integrates S6 process supervisor for zombie reaping (as PID 1) and boot coordination. |
| 4 | +@see https://github.com/just-containers/s6-overlay |
3 | 5 |
|
| 6 | +### Expectations |
| 7 | + |
| 8 | +Applications using this as a container parent must copy their html/app into the `/var/www/html` folder |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | +### Environment Variables |
4 | 13 |
|
5 | 14 | Variable | Example | Description
|
6 | 15 | --- | --- | ---
|
7 | 16 | `SERVER_MAX_BODY_SIZE` | `SERVER_MAX_BODY_SIZE=4M` | Allows the downstream application to specify a non-default `client_max_body_size` configuration for the `server`-level directive in `/etc/nginx/sites-available/default`
|
8 | 17 | `SERVER_INDEX` | `SERVER_INDEX index.html index.html index.php` | Changes the default pages to hit for folder and web roots
|
9 |
| -`SERVER_APP_NAME` | `SERVER_APP_NAME='view'` | Sets a kv pair to be consumed by logging service for easy parsing and searching |
| 18 | +`SERVER_APP_NAME` | `SERVER_APP_NAME='view'` | Gets appended to the default logging format |
10 | 19 | `SERVER_GZIP_OPTIONS` | `SERVER_GZIP_OPTIONS=1` | Allows default set of static content to be served gzipped
|
11 | 20 | `SERVER_SENDFILE` | `SERVER_SENDFILE=off` | Allows runtime to specify value of nginx's `sendfile` (default, on)
|
12 | 21 | `SERVER_KEEPALIVE` | `SERVER_KEEPALIVE=30` | Define HTTP 1.1's keepalive timeout
|
13 | 22 | `SERVER_WORKER_CONNECTIONS` | `SERVER_WORKER_CONNECTIONS=2048` | Sets up the number of connections for worker processes
|
14 | 23 | `SERVER_LOG_MINIMAL` | `SERVER_LOG_MINIMAL=1` | Minimize the logging format, appropriate for development environments
|
| 24 | +`S6_KILL_FINISH_MAXTIME` | `S6_KILL_FINISH_MAXTIME=1000` | Wait time (in ms) for zombie reaping before sending a kill signal |
| 25 | +`S6_KILL_GRACETIME` | `S6_KILL_GRACETIME=500` | Wait time (in ms) for S6 finish scripts before sending kill signal |
| 26 | + |
| 27 | + |
| 28 | +### Startup/Runtime Modification |
15 | 29 |
|
| 30 | +To inject changes just before runtime, shell scripts (ending in .sh) may be placed into the |
| 31 | +`/etc/cont-init.d` folder. For example, the above environment variables are used to drive nginx configuration at runtime. |
| 32 | +As part of the process manager, these scripts are run in advance of the supervised processes. @see https://github.com/just-containers/s6-overlay#executing-initialization-andor-finalization-tasks |
16 | 33 |
|
17 |
| -### Runtime Commands |
18 | 34 |
|
19 |
| -To inject things into the runtime process, add shell scripts (ending in .sh) into the |
20 |
| -`/run.d` folder. These will be executed during container start. |
| 35 | +### Advanced Modification |
21 | 36 |
|
22 |
| -- If script terminates with a non-zero exit code, container will stop, terminating with the script's exit code, unless... |
23 |
| -- If script terminates with exit code of $SIGNAL_BUILD_STOP (99), this will signal the container to stop cleanly. This can be used for multi-stage builds that can be committed |
| 37 | +More advanced changes can take effect using the run.d system. Similar to the `/etc/cont-init.d/` script system, any scripts (ending in .sh) in the `/run.d/` folder will be executed ahead of the S6 initialization. |
24 | 38 |
|
| 39 | +- If run.d script terminates with a non-zero exit code, container will stop, terminating with the script's exit code, unless... |
| 40 | +- If script terminates with exit code of $SIGNAL_BUILD_STOP (99), this will signal the container to stop cleanly. This can be used for multi-stage builds |
25 | 41 |
|
26 |
| -### Long-running processes (workers) |
| 42 | + |
| 43 | +### Long-running processes (workers + crons) |
| 44 | + |
| 45 | +This container image can be shared between web and non-web processes. An example use case would be |
| 46 | +a web service and codebase that also has a few crons and background workers. To reuse this container for |
| 47 | +those types of workloads: |
27 | 48 |
|
28 | 49 | `docker run {image_id} /worker.sh 3 /bin/binary -parameters -that -binary -receives`
|
29 | 50 |
|
30 |
| -Runs 3 copies of `/bin/binary` that receives any arguments as parameters |
| 51 | +Runs `3` copies of `/bin/binary` that receives the parameters `-parameters -that -binary -receives` |
| 52 | + |
| 53 | + |
| 54 | +### Container Organization |
| 55 | + |
| 56 | +Besides the instructions contained in the Dockerfile, the majority of this |
| 57 | +container's use is in configuration and process. The `./container/root` repo directory is overlayed into a container during build. Adding additional files |
| 58 | +to the folders in there will be present in the final image. |
| 59 | + |
| 60 | +Nginx is currently set up as an S6 service in `/etc/services-available/nginx`, during default environment conditions, it will symlink itself to be supervised under `/etc/services.d/nginx`. When running under worker entrypoint (`worker.sh`), it will not be S6's `service.d` folder to be supervised. |
0 commit comments