Skip to content

Commit

Permalink
Merge pull request #19 from sdr-enthusiasts/s6
Browse files Browse the repository at this point in the history
S6
  • Loading branch information
fredclausen authored Sep 26, 2023
2 parents 9ac4335 + b709bd6 commit 003e92f
Show file tree
Hide file tree
Showing 72 changed files with 186 additions and 70 deletions.
22 changes: 22 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---

version: 2

updates:
# Maintain dependencies for Docker
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: daily
time: "00:00"
timezone: "Etc/UTC"
assignees:
- "mikenye"

# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
assignees:
- "mikenye"
83 changes: 83 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
name: Deploy

on:
workflow_dispatch:
inputs:
reason:
required: true
description: "Reason for running this workflow"
use_test_image:
required: false
type: boolean
description: "Use base image testpr"
default: false
push:
branches:
- main
# Don't trigger if it's just a documentation update
paths-ignore:
- "**.md"
- "**.MD"
- "**.yml"
- "LICENSE"
- ".gitattributes"
- ".gitignore"
- ".dockerignore"

# Set workflow-wide environment variables
# - REPO: repo name on dockerhub
# - IMAGE: image name on dockerhub
env:
GHCR_IMAGE: ${{ github.repository }}
GHCR_REGISTRY: ghcr.io

jobs:
workflow-dispatch:
name: Triggered via Workflow Dispatch?
# only run this step if workflow dispatch triggered
# log the reason the workflow dispatch was triggered
if: |
github.event_name == 'workflow_dispatch' &&
github.event.inputs.reason != ''
runs-on: ubuntu-latest
steps:
- name: Log dispatch reason
env:
INPUTS_REASON: ${{ github.event.inputs.reason }}
INPUTS_USE_TEST_IMAGE: ${{ github.event.inputs.use_test_image }}
run: |
echo "Workflow dispatch reason: $INPUTS_REASON"
echo "Use test image: $INPUTS_USE_TEST_IMAGE"
hadolint:
name: Run hadolint against docker files
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Pull hadolint/hadolint:latest Image
run: docker pull hadolint/hadolint:latest
- name: Run hadolint against Dockerfiles
run: docker run --rm -i -v "$PWD":/workdir --workdir /workdir --entrypoint hadolint hadolint/hadolint --ignore DL3003 --ignore DL3006 --ignore DL3010 --ignore DL4001 --ignore DL3007 --ignore DL3008 --ignore SC2068 --ignore DL3007 --ignore SC1091 --ignore DL3013 --ignore DL3010 $(find . -type f -iname "Dockerfile*")

build_and_push:
name: Image Build & Push
uses: sdr-enthusiasts/common-github-workflows/.github/workflows/build_and_push_image.yml@main
needs: [hadolint]
with:
push_enabled: true
push_destinations: ghcr.io
ghcr_repo_owner: ${{ github.repository_owner }}
ghcr_repo: ${{ github.repository }}
platform_linux_arm32v6_enabled: false
platform_linux_i386_enabled: false
# set build_latest to true if github.event.inputs.use_test_image is false
build_latest: ${{ github.event.inputs.use_test_image == 'false' || github.event.inputs.use_test_image == '' }}
build_baseimage_test: ${{ github.event.inputs.use_test_image == 'true' }}
# only build the entire stack if we are not using the test image
build_version_specific: false
build_platform_specific: false
build_nohealthcheck: false
build_baseimage_url: :base/:base-test-pr
secrets:
ghcr_token: ${{ secrets.GITHUB_TOKEN }}
17 changes: 0 additions & 17 deletions .github/workflows/docker.yml

This file was deleted.

74 changes: 36 additions & 38 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM debian:stable-slim
FROM ghcr.io/sdr-enthusiasts/docker-baseimage:base

ENV BASESTATIONPORT="30003" \
FAM_BINGKEY="" \
Expand Down Expand Up @@ -47,49 +47,53 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN set -x && \
apt-get update -y && \
apt-get install -y --no-install-recommends \
ca-certificates \
curl \
file \
git \
html2text \
jq \
locales \
procps \
socat \
wget \
pwgen \
&& \
ca-certificates \
curl \
file \
git \
html2text \
jq \
locales \
procps \
socat \
wget \
pwgen \
&& \
useradd -d "/home/${WEBUSER}" -m -r -U "${WEBUSER}" && \
echo "========== Setup locales ==========" && \
echo "en_US ISO-8859-1" >> /etc/locale.gen && \
echo "de_DE ISO-8859-1" >> /etc/locale.gen && \
echo "es_ES ISO-8859-1" >> /etc/locale.gen && \
echo "fr_FR ISO-8859-1" >> /etc/locale.gen && \
locale-gen && \
echo "========== Deploy php7 ==========" && \
echo "========== Deploy php ==========" && \
apt-get install software-properties-common ca-certificates lsb-release apt-transport-https -y --no-install-recommends && \
sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list' && \
wget -qO - https://packages.sury.org/php/apt.gpg | apt-key add - && \
apt-get update -y && \
apt-get install -y --no-install-recommends \
php \
php-curl \
php-fpm \
php-gd \
php-gettext \
php-json \
php-mysql \
php-xml \
php-zip \
&& \
sed -i '/;error_log/c\error_log = /proc/self/fd/2' /etc/php/7.3/fpm/php-fpm.conf && \
php7.4 \
php7.4-curl \
php7.4-fpm \
php7.4-gd \
php7.4-gettext \
php7.4-json \
php7.4-mysql \
php7.4-xml \
php7.4-zip \
&& \
sed -i '/;error_log/c\error_log = /proc/self/fd/2' /etc/php/7.4/fpm/php-fpm.conf && \
mkdir -p /run/php && \
rm -vrf /etc/php/7.3/fpm/pool.d/* && \
#rm -vrf /etc/php/8.2/fpm/pool.d/* && \
echo "========== Deploy nginx ==========" && \
apt-get install -y --no-install-recommends \
nginx-light && \
nginx-light && \
rm -vf /etc/nginx/conf.d/default.conf && \
rm -vrf /var/www/* && \
usermod -aG www-data "${WEBUSER}" && \
echo "========== Deploy MariaDB ==========" && \
apt-get install -y --no-install-recommends \
mariadb-server && \
mariadb-server && \
mkdir -p /run/mysqld && \
chown -vR mysql:mysql /run/mysqld && \
echo "========== Deploy FlightAirMap ==========" && \
Expand All @@ -99,21 +103,15 @@ RUN set -x && \
chown -vR "${WEBUSER}":"${WEBUSER}" /var/www/flightairmap && \
git log | head -1 | tr -s " " "_" | tee /VERSION || true && \
rm -rf /var/www/flightairmap/htdocs/.git && \
echo "========== Deploy s6-overlay ==========" && \
apt-get install --no-install-recommends -y gnupg && \
wget -q -O - https://raw.githubusercontent.com/mikenye/deploy-s6-overlay/master/deploy-s6-overlay.sh | sh && \
apt-get remove -y gnupg && \
echo "========== Clean up ==========" && \
apt-get remove -y \
file \
git \
&& \
file \
git \
&& \
apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/* /tmp/* /src

# Copy config files
COPY etc/ /etc/

ENTRYPOINT [ "/init" ]
COPY rootfs/ /

EXPOSE 80
5 changes: 0 additions & 5 deletions etc/services.d/php-fpm/run

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/01-sanitycheck/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
oneshot
2 changes: 2 additions & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/01-sanitycheck/up
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec /etc/s6-overlay/scripts/01-sanitycheck
Empty file.
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/02-firstrun/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
oneshot
2 changes: 2 additions & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/02-firstrun/up
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec /etc/s6-overlay/scripts/02-firstrun
Empty file.
Empty file.
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/03-settings/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
oneshot
2 changes: 2 additions & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/03-settings/up
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec /etc/s6-overlay/scripts/03-settings
Empty file.
Empty file.
Empty file.
2 changes: 2 additions & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/daemon-acars/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec /etc/s6-overlay/scripts/daemon-acars
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/daemon-acars/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
Empty file.
Empty file.
Empty file.
2 changes: 2 additions & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/daemon-spotter/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec /etc/s6-overlay/scripts/daemon-spotter
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/daemon-spotter/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
Empty file.
Empty file.
Empty file.
2 changes: 2 additions & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/mysql/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec /etc/s6-overlay/scripts/mysql
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/mysql/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
Empty file.
Empty file.
Empty file.
2 changes: 2 additions & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/nginx/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec /etc/s6-overlay/scripts/nginx
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/nginx/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
Empty file.
Empty file.
Empty file.
2 changes: 2 additions & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/php-fpm/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec /etc/s6-overlay/scripts/php-fpm
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/php-fpm/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
Empty file.
Empty file.
Empty file.
2 changes: 2 additions & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/socat/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec /etc/s6-overlay/scripts/socat
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/socat/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
Empty file.
Empty file.
Empty file.
2 changes: 2 additions & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/update_db/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec /etc/s6-overlay/scripts/update_db
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/update_db/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
2 changes: 1 addition & 1 deletion etc/cont-init.d/01-sanitycheck → rootfs/etc/s6-overlay/scripts/01-sanitycheck
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/with-contenv /bin/bash
#!/command/with-contenv /bin/bash
#shellcheck shell=bash

NOCOLOR='\033[0m'
Expand Down
4 changes: 2 additions & 2 deletions etc/cont-init.d/02-firstrun → rootfs/etc/s6-overlay/scripts/02-firstrun
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/with-contenv /bin/bash
#!/command/with-contenv /bin/bash
#shellcheck shell=bash

if [ -n "${VERBOSE_LOGGING}" ]; then
Expand Down Expand Up @@ -104,7 +104,7 @@ sed -i 's/access_log\ \/dev\/stdout\;/#&/' /etc/nginx/nginx.conf
sed -i 's/error_log\ \/dev\/stdout/#&/' /etc/nginx/nginx.conf

# Start temporary services
/usr/sbin/php-fpm7.3 --daemonize
/usr/sbin/php-fpm7.4 --daemonize
/usr/sbin/nginx -g "daemon on; error_log /dev/null crit;"

# re-enable nginx access log
Expand Down
2 changes: 1 addition & 1 deletion etc/cont-init.d/03-settings → rootfs/etc/s6-overlay/scripts/03-settings
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/with-contenv /bin/bash
#!/command/with-contenv /bin/bash
#shellcheck shell=bash

NOCOLOR='\033[0m'
Expand Down
2 changes: 1 addition & 1 deletion etc/services.d/daemon-acars/run → rootfs/etc/s6-overlay/scripts/daemon-acars
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/with-contenv sh
#!/command/with-contenv sh
# shellcheck shell=sh

s6-setuidgid "$WEBUSER" php /var/www/flightairmap/htdocs/scripts/daemon-acars.php 2>&1 | awk '{print "[daemon-acars] " $0}'
Expand Down
2 changes: 1 addition & 1 deletion etc/services.d/daemon-spotter/run → rootfs/etc/s6-overlay/scripts/daemon-spotter
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/with-contenv sh
#!/command/with-contenv sh
# shellcheck shell=sh

s6-setuidgid "$WEBUSER" php /var/www/flightairmap/htdocs/scripts/daemon-spotter.php 2>&1 | awk '{print "[daemon-spotter] " $0}'
Expand Down
2 changes: 1 addition & 1 deletion etc/services.d/mysql/run → rootfs/etc/s6-overlay/scripts/mysql
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/with-contenv sh
#!/command/with-contenv sh
# shellcheck shell=sh

# if using local database
Expand Down
2 changes: 1 addition & 1 deletion etc/services.d/nginx/run → rootfs/etc/s6-overlay/scripts/nginx
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/with-contenv sh
#!/command/with-contenv sh
# shellcheck shell=sh

/usr/sbin/nginx 2>&1 | awk '{print "[nginx] " $0}'
Expand Down
5 changes: 5 additions & 0 deletions rootfs/etc/s6-overlay/scripts/php-fpm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/command/with-contenv sh
# shellcheck shell=sh

/usr/sbin/php-fpm7.4 --nodaemonize 2>&1 | awk '{print "[php-fpm] " $0}'

2 changes: 1 addition & 1 deletion etc/services.d/socat/run → rootfs/etc/s6-overlay/scripts/socat
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/with-contenv sh
#!/command/with-contenv sh
# shellcheck shell=sh

if [ -z "${BASESTATIONHOST}" ]; then
Expand Down
2 changes: 1 addition & 1 deletion etc/services.d/update_db/run → rootfs/etc/s6-overlay/scripts/update_db
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/with-contenv sh
#!/command/with-contenv sh
# shellcheck shell=sh

sleep 1h
Expand Down

0 comments on commit 003e92f

Please sign in to comment.