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

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

Zabbix: MySQL to Postgresql migration

№ 9662 В разделе "Администрирование" от December 28th, 2018,

All services containerized by Docker, MySQL and Zabbix containers connected to network “zabbix”.

Start Postgresql container and add it to zabbix network group in Docker, set parameters as you need

docker run --name postgres -d --restart=Always \
    -e POSTGRES_USER=postgres
    -e POSTGRES_PASSWORD=postgres
    postgres
docker network connect zabbix postgres

Now create database and user

docker exec -it postgres su -c "createuser -P zabbix" postgres
docker exec -it postgres su -c "createdb -E UTF-8 -O zabbix zabbix" postgres

Ok, database online and accessible for Zabbix services.

Now you can stop old containers with Zabbix services for MySQL and run migration

docker stop zabbix-server-mysql zabbix-panel-mysql
docker run --network zabbix --rm -v /tmp/zabbix:/zabbix dimitri/pgloader:latest \
    bash -c "pgloader --debug --verbose \
    mysql://root:pa55w0rd@mariadb/zabbix \
    postgresql://zabbix:zabbix@postgres/zabbix"

Lets create script to start new Zabbix containers for Postgres DB

!/bin/bash

alertscripts="/srv/docker/zabbix/alertscripts:/usr/lib/zabbix/alertscripts"
externalscripts="/srv/docker/zabbix/externalscripts:/usr/lib/zabbix/externalscripts"

docker run --name zabbix-server-pg -p 10051:10051 \
    -v $alertscripts \
    -v $externalscripts \
    -e DB_SERVER_HOST="postgres" \
    -e DB_SERVER_PORT=5432 \
    -e POSTGRES_USER="zabbix" \
    -e POSTGRES_PASSWORD="zabbix" \
    -e POSTGRES_DB="zabbix" \
    -d --restart=always \
    --network zabbix \
    zabbix/zabbix-server-pgsql:ubuntu-latest

docker run --name zabbix-panel-pg -p 5001:80 \
    -e DB_SERVER_HOST="postgres" \
    -e POSTGRES_USER="zabbix" \
    -e POSTGRES_PASSWORD="zabbix" \
    -e POSTGRES_DB="zabbix" \
    -e ZBX_SERVER_HOST="zabbix-server-pg" \
    -e ZBX_SERVER_PORT="10051" \
    -e PHP_TZ="Asia/Novosibirsk" \
    -d --restart=always \
    --network zabbix \
    zabbix/zabbix-web-nginx-pgsql:ubuntu-latest

You did it! Take a cookie from shelf.

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

gogocron – one second cron daemon

№ 9641 В разделе "Администрирование" от December 12th, 2018,

After unsuccessful searches of same featured cron daemon I wrote it myself.

Features

  • 1 second minimal interval
  • 10 ms precision
  • run command as other user
  • batch of commands
  • timeout for whole task
  • your own ENV variables
  • traditional crontab syntax

https://git.blindage.org/21h/gogocron

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

Tracking in kubedb for Kubernetes

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

Me and my colleague seriously rewriting kubedb to remove bash pornography and implement new functions required by our production and today I found code with… google tracking and it turned on by default! Whhyyy they did it and no said about it??! I think patch of this file will not be accepted to upstream.

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

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

# 2019-06-06 09:47:42

Подборка материалов по Go gist.github.com/egorsmkv/9df2a

# 2019-06-06 09:47:41

Modules для Terraform modules.tf

# 2019-06-06 09:47:38

Как прикрутить oauth2 авторизацию к сайтам, где авторизация не была предусмотрена совсем akomljen.com/protect-kubernete


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

Fortune cookie: FORTUNE'S RULES TO LIVE BY: #8 Don't wear your high heels while making love on the pool table.