INT 21h

Hi, I am Vladimir Smagin, SysAdmin, DevOps and barely good guy. Telegram Email / GIT / Микроблог / Thingiverse / GPG

External sourced PHP application inside docker container with nginx unit

№ 9702 В разделе "Администрирование" от January 30th, 2019,

If you want to run application inside container, but do not want to copy source files inside you can use this universal image. Build image, mount your sources directory and run it. Do not forget to add all required external network services to same network with your container.

Project pages:

Dockerfile

FROM nginx/unit:1.7.1-php7.0

LABEL maintainer="21h@blindage.org"
LABEL description="Nginx unitd universal image. More information here https://blindage.org/?s=unitd"

# install base dependencies

RUN    apt-get ${APT_FLAGS_COMMON} update && \
    apt-get ${APT_FLAGS_PERSISTENT} -y install apt-utils

RUN apt-get ${APT_FLAGS_PERSISTENT} -y install php7.0-gd php7.0-mysql php7.0-curl php7.0-mcrypt php7.0-xml php7.0-json php7.0-mbstring curl

RUN    apt-get ${APT_FLAGS_COMMON} purge -y apt-utils && \
    apt-get ${APT_FLAGS_COMMON} autoremove -y && \
    apt-get ${APT_FLAGS_COMMON} clean && \
    rm -rf /var/lib/apt/lists/*

COPY config.json /state/new_config.json

WORKDIR /www

RUN chown -R www-data:www-data /www

# upload config to unitd

RUN unitd --state /state --pid /tmp/unitd.pid && \
    curl -s -X PUT -d @/state/new_config.json \
         --unix-socket /run/control.unit.sock \
         http://localhost/config/ && \
    kill -9 $(cat /tmp/unitd.pid)

EXPOSE 80

CMD ["unitd", "--no-daemon", "--state", "/state"]

config.json

{
    "listeners": {
        "*:80": {
            "application": "node"
        }
    },
    "applications": {
        "node": {
            "type": "php",
            "user": "www-data",
            "group": "www-data",
            "root": "/www",
            "index": "index.php"
        }
    }
}

Build: docker build -t unitd .

How to run:

docker run  -d --name site_blindage_unitd \
   -v /var/www/blindage.org:/www \
   -p 5004:80 \
   unitd

See also “Standalone PHP application inside docker container with nginx unit

Нет комментариев »

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Яндекс.Метрика

Fortune cookie: Today's spam: Boost your P'E_N^IS_ LEN.GTH