Skip to content

Commit

Permalink
config alignement + fix alpine build
Browse files Browse the repository at this point in the history
- overall config alignment with bash-dev-env project
- fix alpine build
- refactored github workflow with 4 separated jobs
- use plain docker instructions in lint-test.yml
  instead of relying on bin/test script
- added bin/installRequirements
- docker images create a default www-data user
  • Loading branch information
fchastanet committed May 5, 2024
1 parent d3c9c3e commit 268dffb
Show file tree
Hide file tree
Showing 57 changed files with 2,360 additions and 464 deletions.
142 changes: 0 additions & 142 deletions .cspell.json

This file was deleted.

2 changes: 2 additions & 0 deletions .cspell/bash.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ loadprofile
LOCALAPPDATA
maxdepth
mdformat
megalinter
mindepth
mkdir
mktemp
Expand All @@ -79,6 +80,7 @@ NONINTERACTIVE
nonportable
nullglob
onbuild
oxsecurity
pathchk
PATHCONV
pgrep
Expand Down
41 changes: 41 additions & 0 deletions .cspell/lintersConfig.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Bazyli
bbwe
Brzóska
Chastanet
Checkstyle
codesniffer
containerd
DISTRO
distro
DOCKERHUB
fasd
fchastanet
GRYPE
hjson
inet
JSONLINT
kics
mbstring
megalinter
meslo
nameserver
nodoc
oxsecurity
Parens
pipefail
plantuml
powerlevel
precommit
RUBOCOP
shellcheck
shellcheckrc
shfmt
sudoer
tabwidth
tagname
TRIVY
TRUFFLEHOG
undelete
usermod
venv
wekyb
50 changes: 19 additions & 31 deletions .docker/Dockerfile.alpine
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,28 @@ FROM ${BASH_IMAGE}

SHELL ["/bin/sh", "-o", "pipefail", "-o", "errexit", "-o", "xtrace", "-c"]
RUN \
apk upgrade ;\
echo 'http://dl-cdn.alpinelinux.org/alpine/v3.17/main' >> /etc/apk/repositories ;\
apk update ;\
apk add --no-cache \
"bc=~1" \
"coreutils=~9" \
"curl=~8" \
"gawk" \
# needed for envsubst
"gettext=~0.21" \
"git=~2" \
"jq=~1.6" \
"parallel=20221022-r0" \
;\
# remove parallel nagware
mkdir -p ~/.parallel ;\
touch ~/.parallel/will-cite
apk upgrade ;\
echo 'http://dl-cdn.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories ;\
apk update ;\
apk add --no-cache \
"bc" \
"coreutils" \
"curl" \
"gawk" \
# needed for envsubst
"gettext" \
"git" \
"jq" \
"parallel"

# Create a default www-data user
COPY createUser.alpine.sh /usr/local/bin/createUser.sh
RUN USER_ID=1000 GROUP_ID=1000 SKIP_USER=0 createUser.sh

ENV IN_BASH_DOCKER="You're in docker"
WORKDIR /bash

ONBUILD ARG USER_ID=1000
ONBUILD ARG GROUP_ID=1000
ONBUILD ARG SKIP_USER=0
ONBUILD RUN \
if [ "${SKIP_USER:-0}" -eq "0" ] && [ "${USER_ID:-0}" -ne "0" ] && [ "${GROUP_ID:-0}" -ne "0" ]; then \
# del all users with group Id and the del group id
awk -F: "\$4 == ${GROUP_ID} {print \$1}" /etc/passwd | while read -r user; do deluser "${user}"; done ;\
delgroup "${GROUP_ID}" || true ;\
# create www-data user and group from scratch
delgroup www-data || true ;\
deluser www-data || true ;\
addgroup -g "${GROUP_ID}" -S www-data ;\
adduser -u "${USER_ID}" -D -S -h /app -s /sbin/nologin -G www-data www-data ;\
# remove parallel nagware
mkdir -p /app/.parallel ;\
touch /app/.parallel/will-cite; \
fi
ONBUILD RUN /usr/local/bin/createUser.sh
23 changes: 5 additions & 18 deletions .docker/Dockerfile.ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ RUN \
./configure ;\
make install ;\
) ;\
# remove parallel nagware
mkdir -p ~/.parallel ;\
touch ~/.parallel/will-cite ;\
\
# clean apt packages
apt-get remove -y ca-certificates bison build-essential ;\
Expand All @@ -54,25 +51,15 @@ RUN \
# remove apt cache and man/doc
/var/cache/apt/archives /usr/share/{doc,man,locale}/

# Create a default www-data user
COPY createUser.ubuntu.sh /usr/local/bin/createUser.sh
RUN USER_ID=1000 GROUP_ID=1000 SKIP_USER=0 /usr/local/bin/createUser.sh

ENV IN_BASH_DOCKER="You're in docker"
WORKDIR /bash

ONBUILD ARG USER_ID=1000
ONBUILD ARG GROUP_ID=1000
ONBUILD ARG SKIP_USER=0
ONBUILD SHELL ["/bin/bash", "-o", "pipefail", "-o", "errexit", "-o", "xtrace", "-c"]
ONBUILD RUN \
if [[ "${SKIP_USER:-0}" = "0" && "${USER_ID:-0}" != "0" && "${GROUP_ID:-0}" != "0" ]]; then \
# del all users with group Id and the del group id
awk -F: "\$4 == ${GROUP_ID} {print \$1}" /etc/passwd | while read -r user; do userdel "${user}"; done ;\
groupdel "${GROUP_ID}" || true ;\
# create www-data user and group from scratch
userdel -f www-data || true ;\
groupdel www-data || true ;\
groupadd -g "${GROUP_ID}" www-data ;\
useradd -l -u "${USER_ID}" -g www-data www-data ;\
install -d -m 0755 -o www-data -g www-data /home/www-data ;\
# remove parallel nagware
mkdir -p /home/www-data/.parallel ;\
touch /home/www-data/.parallel/will-cite ;\
fi
ONBUILD RUN /usr/local/bin/createUser.sh
22 changes: 22 additions & 0 deletions .docker/createUser.alpine.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

set -x
set -o errexit
set -o pipefail

if [[ "${SKIP_USER:-0}" = "0" && "${USER_ID:-0}" != "0" && "${GROUP_ID:-0}" != "0" ]]; then
# del all users with group Id and the del group id
awk -F: "\$4 == ${GROUP_ID} {print \$1}" /etc/passwd |
while read -r user; do
deluser "${user}"
done
delgroup "${GROUP_ID}" || true
# create www-data user and group from scratch
delgroup www-data || true
deluser www-data || true
addgroup -g "${GROUP_ID}" -S www-data
adduser -u "${USER_ID}" -D -S -h /app -s /sbin/nologin -G www-data www-data
# remove parallel nagware
mkdir -p /app/.parallel
touch /app/.parallel/will-cite
fi
23 changes: 23 additions & 0 deletions .docker/createUser.ubuntu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

set -x
set -o errexit
set -o pipefail

if [[ "${SKIP_USER:-0}" = "0" && "${USER_ID:-0}" != "0" && "${GROUP_ID:-0}" != "0" ]]; then
# del all users with group Id and the del group id
awk -F: "\$4 == ${GROUP_ID} {print \$1}" /etc/passwd |
while read -r user; do
userdel "${user}"
done
groupdel "${GROUP_ID}" || true
# create www-data user and group from scratch
userdel -f www-data || true
groupdel www-data || true
groupadd -g "${GROUP_ID}" www-data
useradd -l -u "${USER_ID}" -g www-data www-data
install -d -m 0755 -o www-data -g www-data /home/www-data
# remove parallel nagware
mkdir -p /home/www-data/.parallel
touch /home/www-data/.parallel/will-cite
fi
18 changes: 17 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,21 @@ module.exports = {
commonjs: true,
node: true,
},
extends: ['eslint:recommended', 'plugin:prettier/recommended'],
plugins: ['json'],
extends: [
'eslint:recommended',
'plugin:json/recommended',
'eslint-config-prettier',
],
rules: {
'json/*': ['error', {allowComments: false}],
},
overrides: [
{
files: ['**/.vscode/*.json'],
rules: {
'json/*': ['error', {allowComments: true}],
},
},
],
};
4 changes: 2 additions & 2 deletions .framework-config
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ fi
# describe the functions that will be skipped from being imported
FRAMEWORK_FUNCTIONS_IGNORE_REGEXP="${FRAMEWORK_FUNCTIONS_IGNORE_REGEXP:-^(Namespace::functions|Functions::myFunction|Namespace::requireSomething|IMPORT::dir::file|Acquire::ForceIPv4)$}"
# describe the files that do not contain function to be imported
NON_FRAMEWORK_FILES_REGEXP="${NON_FRAMEWORK_FILES_REGEXP:-(^bin/|^hooks/|.github/preCommitGeneration.sh|.framework-config|.bats$|/testsData/|^manualTests/|/_.sh$|/ZZZ.sh$|/__all.sh$|^src/_binaries|^src/_includes|^src/batsHeaders.sh$|^src/_standalone)}"
NON_FRAMEWORK_FILES_REGEXP="${NON_FRAMEWORK_FILES_REGEXP:-(^bin/|^hooks/|^.github/|.framework-config|.bats$|/testsData/|^manualTests/|/_.sh$|/ZZZ.sh$|/__all.sh$|^src/_binaries|^src/_includes|^src/batsHeaders.sh$|^src/_standalone)}"
# describe the files that are allowed to not have an associated bats file
BATS_FILE_NOT_NEEDED_REGEXP="${BATS_FILE_NOT_NEEDED_REGEXP:-(^bin/|.framework-config|.bats$|/testsData/|^manualTests/|/_.sh$|/ZZZ.sh$|/__all.sh$|^src/batsHeaders.sh$|^src/_includes)}"
# describe the files that are allowed to not have a function matching the filename
FRAMEWORK_FILES_FUNCTION_MATCHING_IGNORE_REGEXP="${FRAMEWORK_FILES_FUNCTION_MATCHING_IGNORE_REGEXP:-^bin/|^\.framework-config$|\.tpl$|/testsData/|^manualTests/|\.bats$|src/Options/_bats.sh}"
FRAMEWORK_FILES_FUNCTION_MATCHING_IGNORE_REGEXP="${FRAMEWORK_FILES_FUNCTION_MATCHING_IGNORE_REGEXP:-^bin/|^.github/|^\.framework-config$|\.tpl$|/testsData/|^manualTests/|\.bats$|src/Options/_bats.sh}"
# Source directories
if [[ ! -v FRAMEWORK_SRC_DIRS ]]; then
FRAMEWORK_SRC_DIRS=(
Expand Down
Loading

0 comments on commit 268dffb

Please sign in to comment.