Skip to content

Commit

Permalink
Build stage for s6-overlay
Browse files Browse the repository at this point in the history
  • Loading branch information
shinsenter committed Mar 13, 2022
1 parent 7d5d54f commit 6b6f7b9
Show file tree
Hide file tree
Showing 30 changed files with 246 additions and 97 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- uses: stefanzweifel/git-auto-commit-action@v4
with:
branch: ${{ github.event.release.target_commitish }}
commit_message: Update CHANGELOG.md
commit_message: 'Update CHANGELOG.md for ${{ github.event.release.tag_name }}'
file_pattern: CHANGELOG.md

################################################################################
Expand Down
71 changes: 67 additions & 4 deletions .github/workflows/publish-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,72 @@ on:
################################################################################

jobs:
##############################################################################
# S6 Overlay build stage
##############################################################################

s6-overlay:
runs-on: ubuntu-latest
strategy:
max-parallel: 10
matrix:
image:
- shinsenter/s6-overlay
env:
DOCKER_BUILDKIT: "1"
steps:
- uses: actions/checkout@v3
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1
-
id: config
run: |
echo -e "\n\n$(cat ./SPONSOR.md)" >>./src/base-s6/README.md
echo "::set-output name=date::$(date +'%Y%m%d')"
echo "::set-output name=description::$(sed '3q;d' ./src/base-s6/README.md)"
echo "::set-output name=s6_version::$(cat ./S6_VERSION.txt)"
-
uses: actions/cache@v2
with:
path: /tmp/buildx
key: ${{ runner.os }}-buildx-${{ steps.config.outputs.s6_version }}
restore-keys: "${{ runner.os }}-buildx-"
-
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
-
name: Building ${{ matrix.image }}:${{ steps.config.outputs.s6_version }}
uses: docker/build-push-action@v2
with:
push: true
cache-from: type=local,src=/tmp/buildx
cache-to: type=local,dest=/tmp/buildx,mode=max
context: ./src/base-s6/
platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/riscv64,linux/s390x
build-args: |
BUILD_NUMBER=${{ steps.config.outputs.date }}-${{ steps.config.outputs.s6_version }}
S6_VERSION=${{ steps.config.outputs.s6_version }}
tags: |
${{ matrix.image }}:${{ steps.config.outputs.s6_version }}
${{ matrix.image }}:latest
-
name: Updating ${{ matrix.image }}/README.md
uses: peter-evans/dockerhub-description@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
repository: ${{ matrix.image }}
short-description: '${{ steps.config.outputs.description }}'
readme-filepath: ./src/base-s6/README.md

##############################################################################
# Base Ubuntu with S6 Overlay
##############################################################################

base:
needs: s6-overlay
runs-on: ubuntu-latest
strategy:
max-parallel: 2
Expand All @@ -55,9 +116,9 @@ jobs:
./.git-config/hooks/pre-commit
mkdir -p /tmp/buildx
cat versions/base.txt
echo -e "\n\n$(cat ./SPONSOR.md)" >>./src/base/README.md
echo -e "\n\n$(cat ./SPONSOR.md)" >>./src/base-ubuntu/README.md
echo "::set-output name=date::$(date +'%Y%m%d')"
echo "::set-output name=description::$(sed '3q;d' ./src/base/README.md)"
echo "::set-output name=description::$(sed '3q;d' ./src/base-ubuntu/README.md)"
echo "::set-output name=s6_version::$(cat ./S6_VERSION.txt)"
-
uses: actions/cache@v2
Expand All @@ -78,14 +139,16 @@ jobs:
push: true
cache-from: type=local,src=/tmp/buildx
cache-to: type=local,dest=/tmp/buildx-new,mode=max
context: ./src/base/
context: ./src/base-ubuntu/
platforms: linux/amd64,linux/arm64,linux/arm/v7
build-args: |
BUILD_NUMBER=${{ steps.config.outputs.date }}-${{ hashFiles('versions/base.txt') }}
BASE_IMAGE=${{ matrix.base }}:${{ matrix.version }}
S6_VERSION=${{ steps.config.outputs.s6_version }}
tags: |
${{ matrix.image }}:${{ matrix.version }}-s6-${{ steps.config.outputs.s6_version }}
${{ matrix.image }}:${{ matrix.version }}
${{ matrix.image }}:s6-${{ steps.config.outputs.s6_version }}
${{ matrix.image }}:latest
-
name: Updating ${{ matrix.image }}/README.md
Expand All @@ -95,7 +158,7 @@ jobs:
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
repository: ${{ matrix.image }}
short-description: '${{ steps.config.outputs.description }}'
readme-filepath: ./src/base/README.md
readme-filepath: ./src/base-ubuntu/README.md
-
run: |
rm -rf /tmp/buildx
Expand Down
58 changes: 30 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

https://hub.docker.com/r/shinsenter/php

[![Docker Pulls](https://img.shields.io/docker/pulls/shinsenter/php)](https://hub.docker.com/r/shinsenter/php) [![Docker Image Size](https://img.shields.io/docker/image-size/shinsenter/php?label=shinsenter%2Fphp)](https://hub.docker.com/r/shinsenter/php/tags) [![Publish Images (shinsenter/php)](https://github.com/shinsenter/php/actions/workflows/publish-images.yml/badge.svg?branch=main)](https://github.com/shinsenter/php/actions/workflows/publish-images.yml)
[![Docker Pulls](https://img.shields.io/docker/pulls/shinsenter/php)](https://hub.docker.com/r/shinsenter/php) [![Docker Image Size](https://img.shields.io/docker/image-size/shinsenter/php/latest?label=shinsenter%2Fphp)](https://hub.docker.com/r/shinsenter/php/tags) [![Publish Images (shinsenter/php)](https://github.com/shinsenter/php/actions/workflows/publish-images.yml/badge.svg?branch=main)](https://github.com/shinsenter/php/actions/workflows/publish-images.yml)

* * *

Expand All @@ -24,7 +24,26 @@ Let's check it out!!

This project is built on top of my Docker base image, which is Ubuntu 20.04 (Focal) with s6-overlay v3 and OpenSSL included. Learn more at: [shinsenter/s6-ubuntu](https://hub.docker.com/r/shinsenter/s6-ubuntu).

## Available PHP modules
## Usage

### Docker Pull command

```bash
docker pull shinsenter/php:${PHP_VERSION}-${PHP_VARIATION}
```

### Docker Compose example

```yml
version: '3'
services:
my-container:
image: shinsenter/php:${PHP_VERSION}-${PHP_VARIATION}
```
View more image tags at [shinsenter/php/tags](https://hub.docker.com/r/shinsenter/php/tags).
### Available PHP modules
```
apcu
Expand Down Expand Up @@ -84,25 +103,6 @@ Then type these command:
apt-update && apt-install <package_name>
```

## Usage

### Docker Pull command

```bash
docker pull shinsenter/php:${PHP_VERSION}-${PHP_VARIATION}
```

### Docker Compose example

```yml
version: '3'
services:
my-container:
image: shinsenter/php:${PHP_VERSION}-${PHP_VARIATION}
```
View more image tags at [shinsenter/php/tags](https://hub.docker.com/r/shinsenter/php/tags).
## Available images

### PHP version
Expand All @@ -115,16 +115,18 @@ View more image tags at [shinsenter/php/tags](https://hub.docker.com/r/shinsente

- [`shinsenter/php:${PHP_VERSION}-cli`](https://hub.docker.com/r/shinsenter/php/tags?page=1&name=cli) <br/> [![Docker Image Size (tag)](https://img.shields.io/docker/image-size/shinsenter/php/cli?label=shinsenter%2Fphp%3Acli)](https://hub.docker.com/r/shinsenter/php/tags?page=1&name=cli)
- [`shinsenter/php:${PHP_VERSION}-fpm`](https://hub.docker.com/r/shinsenter/php/tags?page=1&name=fpm) <br/> [![Docker Image Size (tag)](https://img.shields.io/docker/image-size/shinsenter/php/fpm?label=shinsenter%2Fphp%3Afpm)](https://hub.docker.com/r/shinsenter/php/tags?page=1&name=fpm)
- [`shinsenter/php:${PHP_VERSION}-fpm-apache`](https://hub.docker.com/r/shinsenter/php/tags?page=1&name=fpm-apache) <br/> [![Docker Image Size (tag)](https://img.shields.io/docker/image-size/shinsenter/php/fpm-apache?label=shinsenter%2Fphp%3Afpm-apache)](https://hub.docker.com/r/shinsenter/php/tags?page=1&name=fpm-apache)
- [`shinsenter/php:${PHP_VERSION}-fpm-nginx`](https://hub.docker.com/r/shinsenter/php/tags?page=1&name=fpm-nginx) <br/> [![Docker Image Size (tag)](https://img.shields.io/docker/image-size/shinsenter/php/fpm-nginx?label=shinsenter%2Fphp%3Afpm-nginx)](https://hub.docker.com/r/shinsenter/php/tags?page=1&name=fpm-nginx)

### Images for Web applications
- [`shinsenter/phpfpm-apache`](https://hub.docker.com/r/shinsenter/phpfpm-apache/tags)<br/> [![Docker Image Size (tag)](https://img.shields.io/docker/image-size/shinsenter/phpfpm-apache/latest?label=shinsenter%2Fphpfpm-apache)](https://hub.docker.com/r/shinsenter/phpfpm-apache/tags)
- [`shinsenter/phpfpm-nginx`](https://hub.docker.com/r/shinsenter/phpfpm-nginx/tags)<br/> [![Docker Image Size (tag)](https://img.shields.io/docker/image-size/shinsenter/phpfpm-nginx/latest?label=shinsenter%2Fphpfpm-nginx)](https://hub.docker.com/r/shinsenter/phpfpm-nginx/tags)

### Images for popular PHP projects

- [`shinsenter/wordpress`](https://hub.docker.com/r/shinsenter/wordpress/tags)<br/> [![Docker Image Size (tag)](https://img.shields.io/docker/image-size/shinsenter/wordpress?label=shinsenter%2Fwordpress)](https://hub.docker.com/r/shinsenter/wordpress/tags)
- [`shinsenter/phpmyadmin`](https://hub.docker.com/r/shinsenter/phpmyadmin/tags)<br/> [![Docker Image Size (tag)](https://img.shields.io/docker/image-size/shinsenter/phpmyadmin?label=shinsenter%2Fphpmyadmin)](https://hub.docker.com/r/shinsenter/phpmyadmin/tags)
- [`shinsenter/laravel`](https://hub.docker.com/r/shinsenter/laravel/tags)<br/> [![Docker Image Size (tag)](https://img.shields.io/docker/image-size/shinsenter/laravel?label=shinsenter%2Flaravel)](https://hub.docker.com/r/shinsenter/laravel/tags)
- [`shinsenter/codeigniter4`](https://hub.docker.com/r/shinsenter/codeigniter4/tags)<br/> [![Docker Image Size (tag)](https://img.shields.io/docker/image-size/shinsenter/codeigniter4?label=shinsenter%2Fcodeigniter4)](https://hub.docker.com/r/shinsenter/codeigniter4/tags)
- [`shinsenter/symfony`](https://hub.docker.com/r/shinsenter/symfony/tags)<br/> [![Docker Image Size (tag)](https://img.shields.io/docker/image-size/shinsenter/symfony?label=shinsenter%2Fsymfony)](https://hub.docker.com/r/shinsenter/symfony/tags)
- [`shinsenter/wordpress`](https://hub.docker.com/r/shinsenter/wordpress/tags)<br/> [![Docker Image Size (tag)](https://img.shields.io/docker/image-size/shinsenter/wordpress/latest?label=shinsenter%2Fwordpress)](https://hub.docker.com/r/shinsenter/wordpress/tags)
- [`shinsenter/phpmyadmin`](https://hub.docker.com/r/shinsenter/phpmyadmin/tags)<br/> [![Docker Image Size (tag)](https://img.shields.io/docker/image-size/shinsenter/phpmyadmin/latest?label=shinsenter%2Fphpmyadmin)](https://hub.docker.com/r/shinsenter/phpmyadmin/tags)
- [`shinsenter/laravel`](https://hub.docker.com/r/shinsenter/laravel/tags)<br/> [![Docker Image Size (tag)](https://img.shields.io/docker/image-size/shinsenter/laravel/latest?label=shinsenter%2Flaravel)](https://hub.docker.com/r/shinsenter/laravel/tags)
- [`shinsenter/codeigniter4`](https://hub.docker.com/r/shinsenter/codeigniter4/tags)<br/> [![Docker Image Size (tag)](https://img.shields.io/docker/image-size/shinsenter/codeigniter4/latest?label=shinsenter%2Fcodeigniter4)](https://hub.docker.com/r/shinsenter/codeigniter4/tags)
- [`shinsenter/symfony`](https://hub.docker.com/r/shinsenter/symfony/tags)<br/> [![Docker Image Size (tag)](https://img.shields.io/docker/image-size/shinsenter/symfony/latest?label=shinsenter%2Fsymfony)](https://hub.docker.com/r/shinsenter/symfony/tags)

## Customize your own image

Expand Down
2 changes: 1 addition & 1 deletion checksum.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ curlhash .dep-ondrej-php.txt 'http://ppa.launchpad.net/ondrej/php/ubuntu/dist
curlhash .dep-ondrej-apache.txt 'http://ppa.launchpadcontent.net/ondrej/apache2/ubuntu/dists/?C=M;O=D'
curlhash .dep-ondrej-nginx.txt 'http://ppa.launchpadcontent.net/ondrej/nginx-mainline/ubuntu/dists/?C=M;O=D'

treehash base.txt S6_VERSION.txt src/base/
treehash base.txt S6_VERSION.txt src/base-ubuntu/
treehash cli.txt base.txt .dep-ondrej-php.txt src/php/cli/
treehash fpm.txt cli.txt src/php/fpm/
treehash servers.txt fpm.txt .dep-ondrej-apache.txt .dep-ondrej-nginx.txt src/servers/
Expand Down
68 changes: 68 additions & 0 deletions src/base-s6/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# This file is the work of https://github.com/shinsenter/php
################################################################################

ARG BASE_IMAGE=ubuntu:latest

################################################################################

# prepares base image
FROM ${BASE_IMAGE} as build

# sets version for s6 overlay
ARG S6_DIR=/usr/src/s6/
ARG S6_SRC_DEP="xz-utils wget"
ARG S6_SRC_URL="https://github.com/just-containers/s6-overlay/releases/download"
ARG S6_VERSION

# disable frontend
ENV DEBIAN_FRONTEND=noninteractive
ENV TERM=xterm

# checks build argument
RUN if [ -z "$S6_VERSION" ]; then \
echo "Please set S6_VERSION build argument."; exit 1; \
fi

# adds build dependencies
RUN apt-get update -y
RUN apt-get install -y $S6_SRC_DEP --no-install-recommends --no-install-suggests

# detect system arch then select the right version of s6
RUN export SYS_ARCH=$(uname -m); \
case "$SYS_ARCH" in \
aarch64 ) export S6_ARCH='aarch64' ;; \
arm ) export S6_ARCH='arm' ;; \
arm* ) export S6_ARCH='armhf' ;; \
i4+ ) export S6_ARCH='i486' ;; \
i6+ ) export S6_ARCH='i686' ;; \
riscv64 ) export S6_ARCH='riscv64' ;; \
s390* ) export S6_ARCH='s390x' ;; \
* ) export S6_ARCH='x86_64' ;; \
esac; \
\
# adds s6 overlay
echo "⬇️ Downloading s6 overlay:${S6_ARCH}-${S6_VERSION} for ${SYS_ARCH}..." \
&& mkdir -p $S6_DIR \
&& untar (){ \
echo " ⏬ Downloading $1"; \
wget --no-check-certificate -O- $1 | tar Jxp -C ${2:-"$S6_DIR"}; \
} \
&& untar ${S6_SRC_URL}/${S6_VERSION}/s6-overlay-noarch.tar.xz \
&& untar ${S6_SRC_URL}/${S6_VERSION}/s6-overlay-${S6_ARCH}.tar.xz \
&& du -sh $S6_DIR

################################################################################

# the main image
FROM scratch

# copies from from build stage
COPY --from=build /usr/src/s6/ /
ENTRYPOINT ["/init"]

################################################################################

ARG BUILD_NUMBER
LABEL build_number="$BUILD_NUMBER"
LABEL maintainer="[email protected]"
LABEL publisher="https://hub.docker.com/u/shinsenter"
41 changes: 41 additions & 0 deletions src/base-s6/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# shinsenter/s6-overlay

The images in this repository contain only the unpacked s6-overlay as a multi-platform build stage.

https://hub.docker.com/r/shinsenter/s6-overlay

[![Docker Pulls](https://img.shields.io/docker/pulls/shinsenter/s6-overlay)](https://hub.docker.com/r/shinsenter/s6-overlay) [![Docker Image Size](https://img.shields.io/docker/image-size/shinsenter/s6-overlay/latest?label=shinsenter%2Fs6-overlay)](https://hub.docker.com/r/shinsenter/s6-overlay/tags)

* * *

## About this project

The images in this repository contain only the unpacked [s6-overlay](https://github.com/just-containers/s6-overlay) as a multi-platform and reusable build stage.

The s6-overlay was built specifically for the lifecycle of containers, giving you a more accurate way of bringing containers down and monitoring their health.

## Usage

This repository is not intended to be used directly, but rather consumed in other Dockerfiles as a multi-platform and reusable build stage.

```Dockerfile
FROM ubuntu

# adds file from the shinsenter/s6-overlay image
COPY --from=shinsenter/s6-overlay / /
ENTRYPOINT ["/init"]

# runs other commands
RUN ...
```

## Supported platforms

This repository uses multi-platform images via Docker manifests. You do not need to use a platform-specific tag (although you can); Docker will automatically choose the appropriate architecture. Currently, the supported architectures are:

- linux/amd64
- linux/arm/v7
- linux/arm64
- linux/ppc64le
- linux/riscv64
- linux/s390x
Loading

0 comments on commit 6b6f7b9

Please sign in to comment.