INT 21h

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

Standalone PHP application inside docker container with nginx unit

№ 9575 В разделе "Администрирование" от November 25th, 2018,

Yes, I know, complete documentation about containerization unitd with predefined config is absent, found examples just uploads config after container start, but not during build. Here’s my own Dockerfile with unitd, php, php-mysql module and uploading project’s configuration during image building.

Dockerfile

FROM nginx/unit:1.7.1-php7.0

LABEL maintainer="21h@blindage.org"
LABEL description="More information here https://blindage.org/?p=9575"

# 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/*

# do not autostart
RUN rm -f /etc/init.d/unit

COPY config.json /state/new_config.json

WORKDIR /www

COPY index.php .

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

# upload config to unitd and die
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

# now container ready to start with predefined config
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"
        }
    }
}

See also “External sourced PHP application inside docker container with nginx unit

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

Leave a Reply

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

*

Микроблог перейти

# 2019-03-18 13:39:04

Yes, Solus is beautiful, but what you can't do:
1) set your password to 123, OS thinks you are stupid
2) set any other keyboard layout switch hotkey instead of fucking macos style, no choice

# 2019-02-14 13:07:54

есть у нас один деплойный плейбук сразу кучи проектов на кучу наших серверов и клиентов. хз что за демоны в голове сношались у человека, который его придумал.

# 2019-02-14 08:46:15

logstash не получится балансировать в кубере, filebeat держит соединение с логсташем постоянно, не разрывая соединение из-за чего будет работать только 1 под из всех поднятых.


© Vladimir Smagin, 2005-2019. Копирование материалов без разрешения запрещено. GPG DA4CD0F5E222EA727D6A40C413BCE12E5618F071
Яндекс.Метрика

Fortune cookie: I haven't been married in over six years, but we had sexual counseling every day from Oral Roberts!!