Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move to the S6 init system #10

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 34 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,43 @@
FROM ubuntu:bionic
MAINTAINER LanCache.Net Team <[email protected]>
LABEL maintainer="LanCache.Net Team <[email protected]>"

ARG DEBIAN_FRONTEND=noninteractive

ADD ["https://github.com/just-containers/s6-overlay/releases/download/v1.17.2.0/s6-overlay-amd64.tar.gz", "/tmp"]

ENTRYPOINT ["/init"]

RUN \
apt-get -y update && apt-get -y upgrade && \
apt-get -y install python3-pip curl wget bzip2 locales tzdata && \
# Extract S6 overlay
tar xzf /tmp/s6-overlay-amd64.tar.gz -C / && \
# Update and get dependencies
apt-get update && \
apt-get install -y \
curl \
wget \
bzip2 \
locales \
tzdata \
&& \
# Add user
useradd -u 911 -U -d /data -s /bin/false abc && \
usermod -G users abc && \
# Timezone
locale-gen en_GB.utf8 && \
update-locale LANG=en_GB.utf8
RUN \
pip3 install supervisor && \
mkdir --mode 777 -p /var/log/supervisor
RUN \
update-locale LANG=en_GB.utf8 && \
# Create directories
mkdir /data && \
# Cleanup
apt-get -y autoremove && \
apt-get -y clean && \
rm -rf /var/lib/apt/lists/*
ENV \
SUPERVISORD_EXIT_ON_FATAL=1 \
rm -rf /var/lib/apt/lists/* && \
rm -rf /tmp/* && \
rm -rf var/tmp/*

ENV \
LC_ALL=en_GB.UTF-8 \
LANG=en_GB.UTF-8 \
LANGUAGE=en_GB.UTF-8 \
TZ=Europe/London \
SUPERVISORD_LOGLEVEL=WARN
TZ=Europe/London

COPY overlay/ /
RUN chmod -R 755 /init /hooks
ENTRYPOINT ["/bin/bash", "-e", "/init/entrypoint"]
CMD ["/init/supervisord"]
19 changes: 8 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,17 @@ It is currently based on 18.04 LTS (Bionic Beaver)

You can easily extend the behavour of this image in the following ways

* `/hooks/entrypoint-pre.d/`
Executables placed in this directory are executed very early on, before anything else is done.
* `/etc/fix-attrs.d`
Fix ownership and permissions before anything else is executes. These files require a specific format detailed [here](https://github.com/just-containers/s6-overlay#fixing-ownership--permissions).

* `/hooks/entrypoint-run`
If it exists, this is executed if the default command is not overridden. After it's execution completes the default command is executed.
* `/etc/cont-init.d`
Executables in this folder are run prior to any services being started.

* `/hooks/entrypoint-exec`
If it exists, this is executed if default command is overridden. After it's execution completes the default command is executed.
* `/etc/services.d`
Services are defined in this directory. A service is defined by creating a directory with the service name with a run file in it.

* `/hooks/supervisord-pre.d/`
Executables placed in this directory are executed just before supervisord is executed.

* `/hooks/supervisord-ready`
If it exists, this is executed once supervisord is read. This is triggered from supervisord itself, when it fires the SUPERVISOR_STATE_CHANGE_RUNNING event.
* `/etc/cont-finish.d`
Executables placed in this directory are executed after a service has died.

## Usage

Expand Down
4 changes: 1 addition & 3 deletions goss.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ package:
installed: true
curl:
installed: true
python3-pip:
installed: true
wget:
installed: true
process:
supervisord:
s6-svscan:
running: true
13 changes: 0 additions & 13 deletions overlay/etc/apt/apt.conf.d/docker-autoremove-suggests

This file was deleted.

16 changes: 0 additions & 16 deletions overlay/etc/apt/apt.conf.d/docker-clean

This file was deleted.

9 changes: 0 additions & 9 deletions overlay/etc/apt/apt.conf.d/docker-gzip-indexes

This file was deleted.

4 changes: 0 additions & 4 deletions overlay/etc/apt/apt.conf.d/docker-no-languages

This file was deleted.

4 changes: 0 additions & 4 deletions overlay/etc/apt/apt.conf.d/dpkg-options

This file was deleted.

16 changes: 16 additions & 0 deletions overlay/etc/cont-init.d/01_uidpatch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/with-contenv bash

PUID=${PUID:-911}
PGID=${PGID:-911}

groupmod -o -g "$PGID" abc > /dev/null 2>&1
usermod -o -u "$PUID" abc > /dev/null 2>&1

echo "-------------------------------------
GID/UID
-------------------------------------
User uid: $(id -u abc)
User gid: $(id -g abc)
-------------------------------------"

chown abc:abc /data
4 changes: 4 additions & 0 deletions overlay/etc/cont-init.d/02_timezonepatch
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/with-contenv bash

ln -snf /usr/share/zoneinfo/$TZ /etc/localtime
echo $TZ > /etc/timezone
File renamed without changes.
18 changes: 0 additions & 18 deletions overlay/etc/supervisor/supervisord.conf

This file was deleted.

Empty file.
5 changes: 0 additions & 5 deletions overlay/hooks/supervisord-ready

This file was deleted.

68 changes: 0 additions & 68 deletions overlay/init/entrypoint

This file was deleted.

29 changes: 0 additions & 29 deletions overlay/init/supervisord

This file was deleted.

8 changes: 1 addition & 7 deletions run-tests.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
#!/bin/bash

if [[ "$@" == *" -- "* ]]; then
SD_LOGLEVEL="-e SUPERVISORD_LOGLEVEL=INFO"
else
SD_LOGLEVEL="-- -e SUPERVISORD_LOGLEVEL=INFO"
fi

curl -fsSL https://raw.githubusercontent.com/lancachenet/test-suite/master/dgoss-tests.sh | bash -s -- --imagename="lancachenet/ubuntu:goss-test" $@ $SD_LOGLEVEL
curl -fsSL https://raw.githubusercontent.com/lancachenet/test-suite/master/dgoss-tests.sh | bash -s -- --imagename="lancachenet/ubuntu:goss-test" $@