Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Latest commit

 

History

History
81 lines (68 loc) · 2.3 KB

File metadata and controls

81 lines (68 loc) · 2.3 KB

StackHead Nginx images

This image allows configuring the public path, which is served by Nginx, and the name of the service and port that receives the traffic.

Configuration

Customization can be done by setting environment variables. The default values for those vary by image (see below).

Environment variable Description
DOCKER_PROXY_SERVICE_NAME Name of Docker service
DOCKER_PROXY_SERVICE_PORT Port to receive the HTTP request
NGINX_PUBLIC_DIRECTORY Folder containing files to be served

Available tags

The tags describe which files Nginx can process and forward to the respective service.

  • standalone (Dockerfile)
    • NGINX_PUBLIC_DIRECTORY=html
    • NGINX_LISTEN_PORT=8080
  • php (Dockerfile)
    • DOCKER_PROXY_SERVICE_NAME=php
    • DOCKER_PROXY_SERVICE_PORT=9000
    • NGINX_PUBLIC_DIRECTORY=html
    • NGINX_LISTEN_PORT=8080

Example usage

Dockerfile

# from Docker registry
FROM getstackhead/nginx:php

# from GitHub registry
FROM docker.pkg.github.com/getstackhead/dockerimages/nginx:php

Docker Compose

services:
  nginx:
    image: getstackhead/nginx:php
    environment:
      DOCKER_PROXY_SERVICE_NAME: phpfpm # name of PHP service (default: php)
      NGINX_PUBLIC_DIRECTORY: htdocs # folder containing files to be served (default: www)
    volumes:
      - .:/var/www # Nginx serves /var/www/$NGINX_PUBLIC_DIRECTORY
    links:
      - phpfpm
  phpfpm:
    image: php:7.4-fpm
    # ...

StackHead project definition

deployment:
  type: docker
  settings:
    services:
      - name: data
        image: mydatacontainer
      - name: nginx
        image: getstackhead/nginx:php
        environment:
          DOCKER_PROXY_SERVICE_NAME: phpfpm # name of my php service below is phpfpm
          NGINX_PUBLIC_DIRECTORY: htdocs # files are in /var/www/htdocs (mounted from mydatacontainer)
        volumes_from:
          - data
        links:
          - phpfpm
      - name: phpfpm
        image: php:7.4-fpm
        # ... more configuration here...