-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(alpine-s): add alpine-s6 base image
Alpine Linux with s6-overlay (simplified version of linuxserver.io's alpine image)
- Loading branch information
Showing
3 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
########################################################################## | ||
|
||
# Builder image | ||
FROM alpine AS builder | ||
|
||
WORKDIR /app | ||
RUN apk add --no-cache dos2unix | ||
COPY root/ . | ||
RUN dos2unix * | ||
|
||
########################################################################## | ||
|
||
# Main image | ||
FROM alpine | ||
|
||
ENV TZ="UTC" | ||
|
||
COPY --from=builder /app / | ||
RUN apk add --no-cache bash s6-overlay shadow tzdata | ||
RUN groupmod -g 1000 users && \ | ||
useradd -u 911 -U -d /config -s /bin/ash abc && \ | ||
usermod -G users abc && \ | ||
mkdir -p /app /config /defaults && \ | ||
sed -i -e 's/^root::/root:!:/' /etc/shadow && \ | ||
rm -rf tmp/* | ||
|
||
ENTRYPOINT [ "/init" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/with-contenv bash | ||
# shellcheck shell=bash | ||
|
||
PUID=${PUID:-1000} | ||
PGID=${PGID:-1000} | ||
|
||
groupmod -o -g "$PGID" abc | ||
usermod -o -u "$PUID" abc | ||
|
||
chown abc:abc /app | ||
chown abc:abc /config | ||
chown abc:abc /defaults |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/with-contenv bash | ||
# shellcheck shell=bash | ||
|
||
# Directories | ||
SCRIPTS_DIR_OLD="/config/custom-cont-init.d" | ||
SCRIPTS_DIR="/custom-cont-init.d" | ||
|
||
SERVICES_DIR_OLD="/config/custom-services.d" | ||
|
||
# chown legacy folders if they exist | ||
if [[ -e "${SCRIPTS_DIR_OLD}" ]]; then | ||
chown -R 0:0 "${SCRIPTS_DIR_OLD}" | ||
fi | ||
|
||
# chown legacy folders if they exist | ||
if [[ -e "${SERVICES_DIR_OLD}" ]]; then | ||
chown -R 0:0 "${SERVICES_DIR_OLD}" | ||
fi | ||
|
||
# Make sure custom init directory exists and has files in it | ||
if [[ -e "${SCRIPTS_DIR}" ]] && [[ -n "$(/bin/ls -A ${SCRIPTS_DIR} 2>/dev/null)" ]]; then | ||
echo "[custom-init] Files found, executing" | ||
for SCRIPT in "${SCRIPTS_DIR}"/*; do | ||
NAME="$(basename "${SCRIPT}")" | ||
if [[ -f "${SCRIPT}" ]]; then | ||
echo "[custom-init] ${NAME}: executing..." | ||
/bin/bash "${SCRIPT}" | ||
echo "[custom-init] ${NAME}: exited $?" | ||
elif [[ ! -f "${SCRIPT}" ]]; then | ||
echo "[custom-init] ${NAME}: is not a file" | ||
fi | ||
done | ||
|
||
# Remove legacy folder if it's empty | ||
if [[ -e "${SCRIPTS_DIR_OLD}" ]] && [[ -z "$(/bin/ls -A ${SCRIPTS_DIR_OLD} 2>/dev/null)" ]]; then | ||
echo "[custom-init] Legacy files folder ${SCRIPTS_DIR_OLD} is empty, deleting..." | ||
rm -rf "${SCRIPTS_DIR_OLD}" | ||
fi | ||
elif [[ -e "${SCRIPTS_DIR_OLD}" ]] && [[ -n "$(/bin/ls -A ${SCRIPTS_DIR_OLD} 2>/dev/null)" ]]; then | ||
echo "[custom-init] Files found, executing" | ||
for SCRIPT in "${SCRIPTS_DIR_OLD}"/*; do | ||
NAME="$(basename "${SCRIPT}")" | ||
if [[ -f "${SCRIPT}" ]]; then | ||
echo "[custom-init] ${NAME}: executing..." | ||
/bin/bash "${SCRIPT}" | ||
echo "[custom-init] ${NAME}: exited $?" | ||
elif [[ ! -f "${SCRIPT}" ]]; then | ||
echo "[custom-init] ${NAME}: is not a file" | ||
fi | ||
done | ||
elif [[ -e "${SCRIPTS_DIR_OLD}" ]] && [[ -z "$(/bin/ls -A ${SCRIPTS_DIR_OLD} 2>/dev/null)" ]]; then | ||
echo "[custom-init] Legacy files folder ${SCRIPTS_DIR_OLD} is empty, deleting..." | ||
rm -rf "${SCRIPTS_DIR_OLD}" | ||
else | ||
echo "[custom-init] No custom files found, skipping..." | ||
fi |