Skip to content

Commit

Permalink
Merge branch 'release-1.1.0' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
BertrandGouny committed Jul 19, 2017
2 parents c293aec + 28b10f0 commit ac22107
Show file tree
Hide file tree
Showing 21 changed files with 153 additions and 147 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

# 1.1.0
- Use debian stretch-slim as baseimage

## 1.0.0
- run tool now use 2 environmen variable KILL_PROCESS_TIMEOUT and KILL_ALL_PROCESSES_TIMEOUT
- change default local to en_US.UTF-8
Expand Down
23 changes: 14 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
NAME = osixia/light-baseimage
VERSION = 1.0.0
VERSION = 1.1.0

.PHONY: all build build-nocache test tag_latest release

all: build
.PHONY: build build-nocache test tag-latest push push-latest release git-tag-version

build:
docker build -t $(NAME):$(VERSION) --rm image
Expand All @@ -14,10 +12,17 @@ build-nocache:
test:
env NAME=$(NAME) VERSION=$(VERSION) bats test/test.bats

tag_latest:
tag-latest:
docker tag $(NAME):$(VERSION) $(NAME):latest

release: build test tag_latest
@if ! docker images $(NAME) | awk '{ print $$2 }' | grep -q -F $(VERSION); then echo "$(NAME) version $(VERSION) is not yet built. Please run 'make build'"; false; fi
docker push $(NAME)
@echo "*** Don't forget to run 'twgit release/hotfix finish' :)"
push:
docker push $(NAME):$(VERSION)

push-latest:
docker push $(NAME):latest

release: build test tag_latest push push_latest

git-tag-version: release
git tag -a v$(VERSION) -m "v$(VERSION)"
git push origin v$(VERSION)
166 changes: 85 additions & 81 deletions README.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions example/multiple-process-image/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Use osixia/light-baseimage
# https://github.com/osixia/docker-light-baseimage
FROM osixia/light-baseimage:1.0.0
FROM osixia/light-baseimage:1.1.0
MAINTAINER Your Name <[email protected]>

# Install multiple process stack, nginx and php5-fpm and clean apt-get files
# Install multiple process stack, nginx and php7.0-fpm and clean apt-get files
# https://github.com/osixia/docker-light-baseimage/blob/stable/image/tool/add-multiple-process-stack
RUN apt-get -y update \
&& /container/tool/add-multiple-process-stack \
&& LC_ALL=C DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
nginx \
php5-fpm \
php7.0-fpm \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

Expand Down
4 changes: 1 addition & 3 deletions example/multiple-process-image/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
NAME = example/multiple-process

.PHONY: all build build-nocache

all: build
.PHONY: build build-nocache

build:
docker build -t $(NAME) --rm .
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ server {

location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
# With php fpm:
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
include fastcgi.conf;
Expand Down
17 changes: 17 additions & 0 deletions example/multiple-process-image/service/php/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash -e
# this script is run during the image build

# config
sed -i -e "s/expose_php = On/expose_php = Off/g" /etc/php/7.0/fpm/php.ini
sed -i -e "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g" /etc/php/7.0/fpm/php.ini
sed -i -e "s/;listen.owner = www-data/listen.owner = www-data/g" /etc/php/7.0/fpm/php.ini
sed -i -e "s/;listen.group = www-data/listen.group = www-data/g" /etc/php/7.0/fpm/php.ini

# create php socket directory
mkdir -p /run/php

# replace default website with php service default website
cp -f /container/service/php/config/default /etc/nginx/sites-available/default

# create phpinfo.php
echo "<?php phpinfo(); " > /var/www/html/phpinfo.php
2 changes: 2 additions & 0 deletions example/multiple-process-image/service/php/process.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash -e
exec /usr/sbin/php-fpm7.0 --nodaemonize
14 changes: 0 additions & 14 deletions example/multiple-process-image/service/php5-fpm/install.sh

This file was deleted.

2 changes: 0 additions & 2 deletions example/multiple-process-image/service/php5-fpm/process.sh

This file was deleted.

2 changes: 1 addition & 1 deletion example/single-process-image/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Use osixia/light-baseimage
# https://github.com/osixia/docker-light-baseimage
FROM osixia/light-baseimage:1.0.0
FROM osixia/light-baseimage:1.1.0
MAINTAINER Your Name <[email protected]>

# Download nginx from apt-get and clean apt-get files
Expand Down
4 changes: 1 addition & 3 deletions example/single-process-image/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
NAME = example/single-process

.PHONY: all build build-nocache

all: build
.PHONY: build build-nocache

build:
docker build -t $(NAME) --rm .
Expand Down
8 changes: 4 additions & 4 deletions image/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM debian:jessie
FROM debian:stretch-slim
MAINTAINER Bertrand Gouny <[email protected]>

COPY . /container
RUN /container/build.sh

ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
ENV LANG="en_US.UTF-8" \
LANGUAGE="en_US:en" \
LC_ALL="en_US.UTF-8"

ENTRYPOINT ["/container/tool/run"]
8 changes: 1 addition & 7 deletions image/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ dpkg-divert --local --rename --add /usr/bin/ischroot
ln -sf /bin/true /usr/bin/ischroot

## Install apt-utils.
$MINIMAL_APT_GET_INSTALL apt-utils python locales
$MINIMAL_APT_GET_INSTALL apt-utils apt-transport-https ca-certificates locales procps dirmngr gnupg iproute python-minimal python-yaml

## Upgrade all packages.
apt-get dist-upgrade -y --no-install-recommends -o Dpkg::Options::="--force-confold"
Expand All @@ -53,12 +53,6 @@ echo -n en_US.UTF-8 > /container/environment/LANG
echo -n en_US.UTF-8 > /container/environment/LANGUAGE
echo -n en_US.UTF-8 > /container/environment/LC_CTYPE

# install PyYAML
tar -C /container/file/ -xvf /container/file/PyYAML-3.11.tar.gz
cd /container/file/PyYAML-3.11/
python setup.py install
cd -

apt-get clean
rm -rf /tmp/* /var/tmp/*
rm -rf /var/lib/apt/lists/*
Expand Down
Binary file removed image/file/PyYAML-3.11.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion image/service-available/:ssl-tools/assets/tool/ssl-helper
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ if [ "${SSL_HELPER_AUTO_RENEW,,}" = "true" ]; then
fi

# add cron job
echo "$SSL_HELPER_AUTO_RENEW_CRON_EXP root /usr/sbin/ssl-auto-renew ${SSL_HELPER_TOOL,,} $PREFIX $CERT_FILE $KEY_FILE $CA_FILE \"$SSL_HELPER_AUTO_RENEW_SERVICES_IMPACTED\" \"$JSONSSL_FILE\" \"$SSL_HELPER_AUTO_RENEW_FROM_FILES\" \"$SSL_HELPER_AUTO_RENEW_CERT_FROM_FILE\" \"$SSL_HELPER_AUTO_RENEW_KEY_FROM_FILE\" \"$SSL_HELPER_AUTO_RENEW_CA_CERT_FROM_FILE\" 2>&1 | /usr/bin/logger -s -t ssl-auto-renew" > /etc/cron.d/$PREFIX
echo "$SSL_HELPER_AUTO_RENEW_CRON_EXP root /usr/sbin/ssl-auto-renew ${SSL_HELPER_TOOL,,} $PREFIX $CERT_FILE $KEY_FILE $CA_FILE \"$SSL_HELPER_AUTO_RENEW_SERVICES_IMPACTED\" \"$JSONSSL_FILE\" \"$SSL_HELPER_AUTO_RENEW_FROM_FILES\" \"$SSL_HELPER_AUTO_RENEW_CERT_FROM_FILE\" \"$SSL_HELPER_AUTO_RENEW_KEY_FROM_FILE\" \"$SSL_HELPER_AUTO_RENEW_CA_CERT_FROM_FILE\" > /proc/1/fd/1 2>/proc/1/fd/2" > /etc/cron.d/$PREFIX
chmod 600 /etc/cron.d/$PREFIX

# disable auto-renew if it was added
Expand Down
4 changes: 4 additions & 0 deletions image/service-available/:ssl-tools/download.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@ fi

LC_ALL=C DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends openssl jq

echo "Download cfssl ..."
curl -o /usr/sbin/cfssl -SL https://pkg.cfssl.org/R1.2/cfssl_linux-amd64
chmod 700 /usr/sbin/cfssl

echo "Download cfssljson ..."
curl -o /usr/sbin/cfssljson -SL https://pkg.cfssl.org/R1.2/cfssljson_linux-amd64
chmod 700 /usr/sbin/cfssljson

echo "Project sources: https://github.com/cloudflare/cfssl"

# remove tools installed to download cfssl
if [ -n "$to_install" ]; then
apt-get remove -y --purge --auto-remove $to_install
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@version: 3.5
@version: 3.8
@include "scl.conf"
@include "`scl-root`/system/tty10.conf"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh -e
log-helper level eq trace && set -x

exec tail -F -n 0 /var/log/syslog
exec tail -F -n 0 /var/log/syslog > /proc/1/fd/1
14 changes: 6 additions & 8 deletions image/tool/log-helper
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ function error() {
getEchoParams $@

if [ $log_level -ge 1 ]; then
[[ -z "$echo_msg" ]] && getMsgFromStdin
echo $echo_param "$echo_msg"
fi
}
Expand All @@ -42,7 +41,6 @@ function warning() {
getEchoParams $@

if [ $log_level -ge 2 ]; then
[[ -z "$echo_msg" ]] && getMsgFromStdin
echo $echo_param "$echo_msg"
fi
}
Expand All @@ -51,7 +49,6 @@ function info() {
getEchoParams $@

if [ $log_level -ge 3 ]; then
[[ -z "$echo_msg" ]] && getMsgFromStdin
echo $echo_param "$echo_msg"
fi
}
Expand All @@ -60,7 +57,6 @@ function debug() {
getEchoParams $@

if [ $log_level -ge 4 ]; then
[[ -z "$echo_msg" ]] && getMsgFromStdin
echo $echo_param "$echo_msg"
fi
}
Expand All @@ -69,14 +65,13 @@ function trace() {
getEchoParams $@

if [ $log_level -ge 5 ]; then
[[ -z "$echo_msg" ]] && getMsgFromStdin
echo $echo_param "$echo_msg"
fi
}

function getMsgFromStdin() {
if [ -z "$2" ]; then
read -r echo_msg || true
echo_msg=$(cat)
fi
}

Expand All @@ -88,6 +83,9 @@ function getEchoParams() {
echo_param=$1
echo_msg=${echo_msg#$1 }
fi

# read from pipe if echo_msg is empty
[[ -n "$echo_msg" ]] || getMsgFromStdin
}

function level() {
Expand All @@ -106,13 +104,13 @@ function level() {
if [ -z "$loglevel_str" ]; then
echo "Error: No log level provided"
echo "Allowed log level are: none, error, warning, info, debug, trace"
echo "usage example: log-helper level is eq info"
echo "usage example: log-helper level eq info"
exit 1
fi

local log_level_var=LOG_LEVEL_$loglevel_str

if [ ${!log_level_var} -$operator $log_level ]; then
if [ $log_level -$operator ${!log_level_var} ]; then
exit 0
else
exit 1
Expand Down
13 changes: 6 additions & 7 deletions image/tool/run
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,10 @@ def xstr(s):
def set_env_hostname_to_etc_hosts():
try:
if "HOSTNAME" in os.environ:
with open('/etc/hostname', 'r') as f:
etc_hostname = f.readline().rstrip()
socket_hostname = socket.gethostname()

if os.environ["HOSTNAME"] != etc_hostname:
ip_address = socket.gethostbyname(etc_hostname)
if os.environ["HOSTNAME"] != socket_hostname:
ip_address = socket.gethostbyname(socket_hostname)
with open("/etc/hosts", "a") as myfile:
myfile.write(ip_address+" "+os.environ["HOSTNAME"]+"\n")
except:
Expand Down Expand Up @@ -641,7 +640,7 @@ def run_process(args, background_process_name, background_process_command):
def run_background_process(name, command):
info("Running "+ name +"...")
pid = os.spawnvp(os.P_NOWAIT, command[0], command)
debug(name + " started as PID %d" % pid)
debug("%s started as PID %d" % (name, pid))
return pid

def wait_background_process(name, pid):
Expand All @@ -656,7 +655,7 @@ def wait_background_process(name, pid):
exit_status = 1
else:
exit_status = os.WEXITSTATUS(exit_code)
info(name + " exited with status %d" % exit_status)
info("%s exited with status %d" % (name, exit_status))
return (process_exited, exit_status)

def run_foreground_process(command):
Expand Down Expand Up @@ -685,7 +684,7 @@ def run_foreground_process(command):

def shutdown_runit_services():
debug("Begin shutting down runit services...")
os.system("/usr/bin/sv -w %d down "+RUN_PROCESS_DIR+"/* > /dev/null" % KILL_PROCESS_TIMEOUT)
os.system("/usr/bin/sv -w %d force-stop %s/* > /dev/null" % (KILL_PROCESS_TIMEOUT, RUN_PROCESS_DIR))

def wait_for_runit_services():
debug("Waiting for runit services to exit...")
Expand Down

0 comments on commit ac22107

Please sign in to comment.