Giter Club home page Giter Club logo

unit-php's Introduction

unit-php

Alpine based Docker image for nginx-unit with PHP module

Ready-to-use images:

ghcr.io/n0rthernl1ghts/unit-php

Supported PHP versions:

  • PHP7.4
  • PHP8.1
  • PHP8.2

Check the package for available tags.

Currently under active maintenance, so to be considered as unstable.

How to use

On container startup, unit is launched and then config.json is sent to the service.


Bundled config is suitable for running simple Laravel application in /app. Keep in mind persistent directories, if any.

docker run -it \
  -v "/path/to/your/laravel_app:/app" \
  ghcr.io/n0rthernl1ghts/unit-php

And here's how to run with your own config:

docker run -it \
  -v "/path/to/your/unit_config.json:/etc/unit/config.json" \
  -v "/path/to/your/web_app:/app" \
  ghcr.io/n0rthernl1ghts/unit-php

You can also override path to unit configuration file with UNIT_CONFIGURATION_FILE environment variable:

docker run -it \
  -e "UNIT_CONFIGURATION_FILE=/app/config/unit.json" \
  -v "/path/to/your/web_app:/app" \
  ghcr.io/n0rthernl1ghts/unit-php
Extending the image

Example multistage Dockerfile:

# First stage: Build root filesystem (copy files)
FROM scratch AS rootfs

COPY ["./app", "/app"]
COPY ["./unit.json", "/etc/unit/config.json"]



# Main stage
FROM ghcr.io/n0rthernl1ghts/unit-php

# Copy prepared root filesystem (single layer)
COPY --from=rootfs ["/", "/"]

# Install PHP extensions with pecl: apcu and redis
# Install PHP extension: opcache, pdo and pdo_mysql
RUN set -eux \
    && apk add --update --no-cache alpine-sdk \
    && pear channel-update pear.php.net \
    && pecl channel-update pecl.php.net \
    && pecl install apcu redis \
    && docker-php-ext-enable apcu redis \
    && docker-php-ext-install -j "$(nproc)" opcache pdo pdo_mysql \
    && apk del alpine-sdk \
    && rm /tmp/* -rf

Supervisor

This image comes bundled with just-containers/s6-overlay from build ghcr.io/n0rthernl1ghts/s6-rootfs. To control supervisor behavior, you can use it's environment variables.

Do NOT attempt starting with docker built-in supervisor (Tini [--init]). S6 must run as PID 1.

Caveats

  • Comes with PHP ZTS (Zend Thread Safety) enabled. The reason behind is that official PHP image, doesn't support PHP embed on Alpine based images. See: docker-library/php#1355. It does, however on ZTS Alpine images.

unit-php's People

Contributors

dependabot[bot] avatar xzero707 avatar

Watchers

 avatar  avatar

unit-php's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.