mirror of
https://github.com/dockersrc/go
synced 2026-07-14 23:45:58 -04:00
📝 Migrate /var/lib/srv docker paths to /srv in docs 📝
Build and Push / build (push) Has been cancelled
Build and Push / build (push) Has been cancelled
Update volume mount examples from /var/lib/srv/$USER/docker to /srv/$USER/docker. - .env.scripts AI.md Dockerfile rootfs/root/docker/setup/00-init.sh rootfs/root/docker/setup/01-system.sh rootfs/root/docker/setup/02-packages.sh rootfs/root/docker/setup/03-files.sh rootfs/root/docker/setup/04-users.sh rootfs/root/docker/setup/05-custom.sh rootfs/root/docker/setup/06-post.sh rootfs/root/docker/setup/07-cleanup.sh rootfs/usr/local/bin/entrypoint.sh rootfs/usr/local/etc/docker/functions/entrypoint.sh : update path references to /srv/$USER/docker AI.md Dockerfile .env.scripts rootfs/root/docker/setup/00-init.sh rootfs/root/docker/setup/01-system.sh rootfs/root/docker/setup/02-packages.sh rootfs/root/docker/setup/03-files.sh rootfs/root/docker/setup/04-users.sh rootfs/root/docker/setup/05-custom.sh rootfs/root/docker/setup/06-post.sh rootfs/root/docker/setup/07-cleanup.sh rootfs/usr/local/bin/entrypoint.sh rootfs/usr/local/etc/docker/functions/entrypoint.sh
This commit is contained in:
+5
-8
@@ -1,10 +1,10 @@
|
|||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
##@Version : 202605292219-git
|
##@Version : 202607092001-git
|
||||||
# @@Author : CasjaysDev
|
# @@Author : CasjaysDev
|
||||||
# @@Contact : CasjaysDev <docker-admin@casjaysdev.pro>
|
# @@Contact : CasjaysDev <docker-admin@casjaysdev.pro>
|
||||||
# @@License : MIT
|
# @@License : WTFPL
|
||||||
# @@Copyright : Copyright 2026 CasjaysDev
|
# @@Copyright : Copyright 2026 CasjaysDev
|
||||||
# @@Created : Mon May 4 04:27:58 PM EDT 2026
|
# @@Created : Thu Jul 9 08:01:29 PM EDT 2026
|
||||||
# @@File : .env.scripts
|
# @@File : .env.scripts
|
||||||
# @@Description : Variables for gen-dockerfile and buildx scripts
|
# @@Description : Variables for gen-dockerfile and buildx scripts
|
||||||
# @@Changelog : newScript
|
# @@Changelog : newScript
|
||||||
@@ -54,7 +54,7 @@ ENV_ADD_IMAGE_PUSH=""
|
|||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# Pull Configuration
|
# Pull Configuration
|
||||||
# ENV_PULL_URL: Source image to pull from (base image)
|
# ENV_PULL_URL: Source image to pull from (base image)
|
||||||
ENV_PULL_URL="casjaysdev/alpine"
|
ENV_PULL_URL="alpine"
|
||||||
# ENV_DISTRO_TAG: Tag for the pull source image
|
# ENV_DISTRO_TAG: Tag for the pull source image
|
||||||
ENV_DISTRO_TAG="${IMAGE_VERSION}"
|
ENV_DISTRO_TAG="${IMAGE_VERSION}"
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
@@ -72,12 +72,9 @@ NODE_MANAGER="system"
|
|||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# Default directories
|
# Default directories
|
||||||
WWW_ROOT_DIR="/usr/local/share/httpd/default"
|
WWW_ROOT_DIR="/usr/local/share/httpd/default"
|
||||||
DEFAULT_FILE_DIR="/usr/local/share/template-files"
|
|
||||||
DEFAULT_DATA_DIR="/usr/local/share/template-files/data"
|
|
||||||
DEFAULT_CONF_DIR="/usr/local/share/template-files/config"
|
|
||||||
DEFAULT_TEMPLATE_DIR="/usr/local/share/template-files/defaults"
|
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
ENV_PACKAGES="git make bash tini ca-certificates openssh-client curl wget tar tzdata jq build-base gcc musl-dev pkgconf openssl-dev libffi-dev zlib-dev linux-headers protobuf protobuf-dev"
|
ENV_PACKAGES="git make bash tini ca-certificates openssh-client curl wget tar tzdata jq build-base gcc musl-dev pkgconf openssl-dev libffi-dev zlib-dev linux-headers protobuf protobuf-dev"
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# ex: ts=2 sw=2 et filetype=sh
|
# ex: ts=2 sw=2 et filetype=sh
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,174 @@ Files updated:
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## Template System Reference
|
||||||
|
|
||||||
|
This section documents the current state of `templates/dockerfiles/` and key
|
||||||
|
`bin/gen-dockerfile` variables. Keep it in sync whenever upstream templates change.
|
||||||
|
|
||||||
|
### Template inventory
|
||||||
|
|
||||||
|
| Template | Final stage | Init / PID 1 | Base OS |
|
||||||
|
|----------|-------------|--------------|---------|
|
||||||
|
| `alpine.template` | `scratch.template` | tini | Alpine |
|
||||||
|
| `debian.template` | `scratch.template` | tini | Debian |
|
||||||
|
| `ubuntu.template` | `scratch.template` | tini | Ubuntu |
|
||||||
|
| `rhel.template` | `scratch.template` | tini | AlmaLinux |
|
||||||
|
| `archlinux.template` | `scratch.template` | tini | Arch Linux (see multi-arch note) |
|
||||||
|
| `web.template` | `systemd.template` | `/sbin/init` | Debian |
|
||||||
|
| `xorg.template` | `systemd.template` | `/sbin/init` | Debian |
|
||||||
|
|
||||||
|
### Final-stage templates
|
||||||
|
|
||||||
|
`scratch.template` — used by all non-GUI templates.
|
||||||
|
- `ENTRYPOINT [ "tini", "-p", "SIGTERM","--", "/usr/local/bin/entrypoint.sh" ]`
|
||||||
|
- `STOPSIGNAL SIGRTMIN+3`
|
||||||
|
|
||||||
|
`systemd.template` — used by `web` and `xorg` (systemd runs as PID 1; tini is redundant).
|
||||||
|
- `ENTRYPOINT [ "/sbin/init" ]`
|
||||||
|
- `STOPSIGNAL SIGRTMIN+3`
|
||||||
|
- No `tini_provider` stage, no `COPY --from=tini_provider` line.
|
||||||
|
|
||||||
|
Both templates are identical apart from `ENTRYPOINT`. OCI labels, `ENV HOSTNAME`, and
|
||||||
|
`VOLUME`/`EXPOSE`/`HEALTHCHECK` are the same in both.
|
||||||
|
|
||||||
|
### OCI label standard
|
||||||
|
|
||||||
|
Both `scratch.template` and `systemd.template` emit these labels (no others):
|
||||||
|
|
||||||
|
```
|
||||||
|
LABEL maintainer="${GEN_DOCKERFILE_MAINTAINER}"
|
||||||
|
LABEL org.opencontainers.image.vendor="${GEN_DOCKERFILE_VENDOR:-CasjaysDev}"
|
||||||
|
LABEL org.opencontainers.image.authors="${GEN_DOCKERFILE_AUTHOR:-CasjaysDev}"
|
||||||
|
LABEL org.opencontainers.image.licenses="${LICENSE}"
|
||||||
|
LABEL org.opencontainers.image.title="${IMAGE_NAME}"
|
||||||
|
LABEL org.opencontainers.image.description="Containerized version of ${IMAGE_NAME}"
|
||||||
|
LABEL org.opencontainers.image.created="${BUILD_DATE}"
|
||||||
|
LABEL org.opencontainers.image.version="${BUILD_VERSION}"
|
||||||
|
LABEL org.opencontainers.image.revision="${GIT_COMMIT}"
|
||||||
|
LABEL org.opencontainers.image.url="${GEN_DOCKERFILE_HUB_REPO}"
|
||||||
|
LABEL org.opencontainers.image.source="${GEN_DOCKERFILE_GIT_REPO}"
|
||||||
|
LABEL org.opencontainers.image.documentation="${GEN_DOCKERFILE_GIT_REPO}"
|
||||||
|
LABEL org.opencontainers.image.vcs-type="Git"
|
||||||
|
LABEL com.github.containers.toolbox="false"
|
||||||
|
```
|
||||||
|
|
||||||
|
Shell-expanded values (no `\`) are evaluated at template-render time by
|
||||||
|
`gen-dockerfile`. Dollar-escaped values (`\${...}`) become literal Docker
|
||||||
|
`ARG`/`ENV` references in the generated `Dockerfile`.
|
||||||
|
|
||||||
|
Removed labels (do not re-add):
|
||||||
|
- `org.opencontainers.image.base.name` — belongs on the base image, not the app image
|
||||||
|
- `org.opencontainers.image.schema-version` — non-spec; redundant with `version`
|
||||||
|
- Any duplicate `authors` or `source` entries
|
||||||
|
|
||||||
|
### HOSTNAME convention
|
||||||
|
|
||||||
|
All templates set `ENV HOSTNAME="casjaysdevdocker-${IMAGE_NAME}"` in every stage
|
||||||
|
that declares it. The prefix is always `casjaysdevdocker-`, never `casjaysdev-`.
|
||||||
|
|
||||||
|
### `GEN_DOCKERFILE_APP_DIR` and pull URL logic
|
||||||
|
|
||||||
|
`GEN_DOCKERFILE_APP_DIR` is auto-detected in `bin/gen-dockerfile` from the parent
|
||||||
|
directory of `$PWD` (i.e. the GitHub org the project lives in):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
GEN_DOCKERFILE_APP_DIR="${GEN_DOCKERFILE_APP_DIR:-$(basename -- "$(dirname -- "$PWD")")}"
|
||||||
|
```
|
||||||
|
|
||||||
|
It controls which base images `GEN_DOCKER_SPECIFY_IMAGE_SOURCE_*` default to:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
if [ "${GEN_DOCKERFILE_APP_DIR}" = "casjaysdevdocker" ]; then
|
||||||
|
# Pull from pre-built casjaysdev/* base images on Docker Hub
|
||||||
|
GEN_DOCKER_SPECIFY_IMAGE_SOURCE_RHEL="${GEN_DOCKER_SPECIFY_IMAGE_SOURCE_RHEL:-casjaysdev/almalinux}"
|
||||||
|
GEN_DOCKER_SPECIFY_IMAGE_SOURCE_ALPINE="${GEN_DOCKER_SPECIFY_IMAGE_SOURCE_ALPINE:-casjaysdev/alpine}"
|
||||||
|
GEN_DOCKER_SPECIFY_IMAGE_SOURCE_DEBIAN="${GEN_DOCKER_SPECIFY_IMAGE_SOURCE_DEBIAN:-casjaysdev/debian}"
|
||||||
|
GEN_DOCKER_SPECIFY_IMAGE_SOURCE_UBUNTU="${GEN_DOCKER_SPECIFY_IMAGE_SOURCE_UBUNTU:-casjaysdev/ubuntu}"
|
||||||
|
GEN_DOCKER_SPECIFY_IMAGE_SOURCE_ARCHLINUX="${GEN_DOCKER_SPECIFY_IMAGE_SOURCE_ARCHLINUX:-casjaysdev/archlinux}"
|
||||||
|
else
|
||||||
|
# Pull from upstream official images (dockersrc/* builds its own base images)
|
||||||
|
GEN_DOCKER_SPECIFY_IMAGE_SOURCE_RHEL="${GEN_DOCKER_SPECIFY_IMAGE_SOURCE_RHEL:-almalinux}"
|
||||||
|
GEN_DOCKER_SPECIFY_IMAGE_SOURCE_ALPINE="${GEN_DOCKER_SPECIFY_IMAGE_SOURCE_ALPINE:-alpine}"
|
||||||
|
GEN_DOCKER_SPECIFY_IMAGE_SOURCE_DEBIAN="${GEN_DOCKER_SPECIFY_IMAGE_SOURCE_DEBIAN:-debian}"
|
||||||
|
GEN_DOCKER_SPECIFY_IMAGE_SOURCE_UBUNTU="${GEN_DOCKER_SPECIFY_IMAGE_SOURCE_UBUNTU:-ubuntu}"
|
||||||
|
GEN_DOCKER_SPECIFY_IMAGE_SOURCE_ARCHLINUX="${GEN_DOCKER_SPECIFY_IMAGE_SOURCE_ARCHLINUX:-archlinux}"
|
||||||
|
fi
|
||||||
|
```
|
||||||
|
|
||||||
|
Summary:
|
||||||
|
- `casjaysdevdocker/*` repos → `FROM casjaysdev/<distro>:latest` (already multi-arch)
|
||||||
|
- `dockersrc/*` and all other orgs → `FROM <distro>:latest` (upstream official images)
|
||||||
|
|
||||||
|
The Docker Hub push org (`casjaysdev`) is unchanged regardless of `GEN_DOCKERFILE_APP_DIR`.
|
||||||
|
|
||||||
|
### Toolchain build stages are exempt from the pull-URL org rule
|
||||||
|
|
||||||
|
Language toolchain images (e.g. `dockersrc/go`) add a dedicated build stage that pulls a
|
||||||
|
pre-built upstream toolchain image directly, independent of `PULL_URL`/`GEN_DOCKERFILE_APP_DIR`:
|
||||||
|
|
||||||
|
```dockerfile
|
||||||
|
FROM --platform=$BUILDPLATFORM golang:alpine AS go-tools
|
||||||
|
```
|
||||||
|
|
||||||
|
This is intentional and correct — it speeds up building the toolchain (e.g. Go binaries) by
|
||||||
|
reusing an official prebuilt image with the compiler already installed, rather than installing it
|
||||||
|
from scratch in the `PULL_URL` base stage. Do not change these stages to use `PULL_URL` or route
|
||||||
|
them through `GEN_DOCKERFILE_APP_DIR` logic; they are a separate concern from the OS base image.
|
||||||
|
|
||||||
|
### Arch Linux multi-arch (`archlinux.template`)
|
||||||
|
|
||||||
|
When `GEN_DOCKERFILE_APP_DIR != "casjaysdevdocker"` (i.e. building a base image in
|
||||||
|
`dockersrc/archlinux`), the template emits a three-stage FROM to support both
|
||||||
|
`linux/amd64` and `linux/arm64`:
|
||||||
|
|
||||||
|
```dockerfile
|
||||||
|
ARG TARGETARCH
|
||||||
|
ARG TARGETPLATFORM
|
||||||
|
FROM --platform=${TARGETPLATFORM} archlinux:latest AS base-amd64
|
||||||
|
FROM --platform=${TARGETPLATFORM} lopsided/archlinux-arm64v8:latest AS base-arm64
|
||||||
|
FROM base-${TARGETARCH} AS build
|
||||||
|
```
|
||||||
|
|
||||||
|
When `GEN_DOCKERFILE_APP_DIR = "casjaysdevdocker"`, `casjaysdev/archlinux` is a
|
||||||
|
multi-arch manifest so a single `FROM ${PULL_URL}:${DISTRO_VERSION} AS build` suffices.
|
||||||
|
|
||||||
|
### `web.template` packages
|
||||||
|
|
||||||
|
The `web` template installs the following systemd + noVNC stack in the build stage:
|
||||||
|
|
||||||
|
```
|
||||||
|
systemd systemd-sysv dbus dbus-x11 procps
|
||||||
|
tigervnc-standalone-server novnc openbox xdotool
|
||||||
|
```
|
||||||
|
|
||||||
|
Default ports: `SERVICE_PORT="5800"`, `EXPOSE_PORTS="5800 5900"`.
|
||||||
|
|
||||||
|
### `xorg.template` packages
|
||||||
|
|
||||||
|
The `xorg` template installs the following systemd + Xorg stack in the build stage:
|
||||||
|
|
||||||
|
```
|
||||||
|
systemd systemd-sysv dbus dbus-x11 procps
|
||||||
|
xserver-xorg x11-xserver-utils xinit
|
||||||
|
```
|
||||||
|
|
||||||
|
### `debian.template` / `ubuntu.template` — RUN continuation fix
|
||||||
|
|
||||||
|
The first `RUN` block must have `; \` after the `echo` line so
|
||||||
|
`export DEBIAN_FRONTEND=noninteractive` executes before `apt-get`:
|
||||||
|
|
||||||
|
```dockerfile
|
||||||
|
RUN set -e; \
|
||||||
|
echo "Updating the system"; \
|
||||||
|
export DEBIAN_FRONTEND=noninteractive; \
|
||||||
|
apt-get update && apt-get upgrade -yy && apt-get dist-upgrade -yy
|
||||||
|
```
|
||||||
|
|
||||||
|
Without the `; \` the export is a no-op and `apt-get` may prompt interactively.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Tool Reference
|
## Tool Reference
|
||||||
|
|
||||||
### `gen-dockerfile`
|
### `gen-dockerfile`
|
||||||
@@ -104,6 +272,11 @@ else
|
|||||||
REPO_TYPE="app"
|
REPO_TYPE="app"
|
||||||
org="casjaysdevdocker"
|
org="casjaysdevdocker"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# GEN_DOCKERFILE_APP_DIR is auto-detected by gen-dockerfile from the parent of $PWD.
|
||||||
|
# For repos under casjaysdevdocker/: pull base from casjaysdev/* (pre-built multi-arch).
|
||||||
|
# For repos under dockersrc/ or any other org: pull from upstream official images.
|
||||||
|
# Override by setting GEN_DOCKERFILE_APP_DIR in the environment before calling gen-dockerfile.
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -381,8 +554,8 @@ dockermgr update {name}
|
|||||||
## Install and run container
|
## Install and run container
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
dockerHome="/var/lib/srv/$USER/docker/casjaysdevdocker/{name}/{name}/latest/rootfs"
|
dockerHome="/srv/$USER/docker/casjaysdevdocker/{name}/{name}/latest/rootfs"
|
||||||
mkdir -p "/var/lib/srv/$USER/docker/{name}/rootfs"
|
mkdir -p "/srv/$USER/docker/{name}/rootfs"
|
||||||
git clone "https://github.com/dockermgr/{name}" "$HOME/.local/share/CasjaysDev/dockermgr/{name}"
|
git clone "https://github.com/dockermgr/{name}" "$HOME/.local/share/CasjaysDev/dockermgr/{name}"
|
||||||
cp -Rfva "$HOME/.local/share/CasjaysDev/dockermgr/{name}/rootfs/." "$dockerHome/"
|
cp -Rfva "$HOME/.local/share/CasjaysDev/dockermgr/{name}/rootfs/." "$dockerHome/"
|
||||||
docker run -d \
|
docker run -d \
|
||||||
@@ -409,8 +582,8 @@ services:
|
|||||||
- TZ=America/New_York
|
- TZ=America/New_York
|
||||||
- HOSTNAME={name}
|
- HOSTNAME={name}
|
||||||
volumes:
|
volumes:
|
||||||
- "/var/lib/srv/$USER/docker/casjaysdevdocker/{name}/{name}/latest/rootfs/data:/data:z"
|
- "/srv/$USER/docker/casjaysdevdocker/{name}/{name}/latest/rootfs/data:/data:z"
|
||||||
- "/var/lib/srv/$USER/docker/casjaysdevdocker/{name}/{name}/latest/rootfs/config:/config:z"
|
- "/srv/$USER/docker/casjaysdevdocker/{name}/{name}/latest/rootfs/config:/config:z"
|
||||||
ports:
|
ports:
|
||||||
- {port}:{port}
|
- {port}:{port}
|
||||||
restart: always
|
restart: always
|
||||||
@@ -465,17 +638,17 @@ dockermgr update os {name}
|
|||||||
## Install and run container
|
## Install and run container
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
mkdir -p "/var/lib/srv/root/docker/casjaysdev/{name}/latest"
|
mkdir -p "/srv/root/docker/casjaysdev/{name}/latest"
|
||||||
git clone "https://github.com/dockermgr/{name}" "$HOME/.local/share/CasjaysDev/dockermgr/{name}"
|
git clone "https://github.com/dockermgr/{name}" "$HOME/.local/share/CasjaysDev/dockermgr/{name}"
|
||||||
cp -Rfva "$HOME/.local/share/CasjaysDev/dockermgr/{name}/rootfs/." "/var/lib/srv/root/docker/casjaysdev/{name}/latest/"
|
cp -Rfva "$HOME/.local/share/CasjaysDev/dockermgr/{name}/rootfs/." "/srv/root/docker/casjaysdev/{name}/latest/"
|
||||||
docker run -d \
|
docker run -d \
|
||||||
--restart always \
|
--restart always \
|
||||||
--privileged \
|
--privileged \
|
||||||
--name casjaysdev-{name}-latest \
|
--name casjaysdev-{name}-latest \
|
||||||
--hostname {name} \
|
--hostname {name} \
|
||||||
-e TZ=${TIMEZONE:-America/New_York} \
|
-e TZ=${TIMEZONE:-America/New_York} \
|
||||||
-v "/var/lib/srv/root/docker/casjaysdev/{name}/latest/data:/data:z" \
|
-v "/srv/root/docker/casjaysdev/{name}/latest/data:/data:z" \
|
||||||
-v "/var/lib/srv/root/docker/casjaysdev/{name}/latest/config:/config:z" \
|
-v "/srv/root/docker/casjaysdev/{name}/latest/config:/config:z" \
|
||||||
casjaysdev/{name}:latest
|
casjaysdev/{name}:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -491,8 +664,8 @@ services:
|
|||||||
- TZ=America/New_York
|
- TZ=America/New_York
|
||||||
- HOSTNAME={name}
|
- HOSTNAME={name}
|
||||||
volumes:
|
volumes:
|
||||||
- "/var/lib/srv/root/docker/casjaysdev/{name}/latest/data:/data:z"
|
- "/srv/root/docker/casjaysdev/{name}/latest/data:/data:z"
|
||||||
- "/var/lib/srv/root/docker/casjaysdev/{name}/latest/config:/config:z"
|
- "/srv/root/docker/casjaysdev/{name}/latest/config:/config:z"
|
||||||
restart: always
|
restart: always
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
+8
-11
@@ -24,7 +24,7 @@ ARG IMAGE_REPO="casjaysdev/go"
|
|||||||
ARG IMAGE_VERSION="latest"
|
ARG IMAGE_VERSION="latest"
|
||||||
ARG CONTAINER_VERSION=""
|
ARG CONTAINER_VERSION=""
|
||||||
|
|
||||||
ARG PULL_URL="casjaysdev/alpine"
|
ARG PULL_URL="alpine"
|
||||||
ARG DISTRO_VERSION="${IMAGE_VERSION}"
|
ARG DISTRO_VERSION="${IMAGE_VERSION}"
|
||||||
ARG BUILD_VERSION="${BUILD_DATE}"
|
ARG BUILD_VERSION="${BUILD_DATE}"
|
||||||
|
|
||||||
@@ -247,19 +247,16 @@ WORKDIR /app
|
|||||||
LABEL maintainer="CasjaysDev <docker-admin@casjaysdev.pro>"
|
LABEL maintainer="CasjaysDev <docker-admin@casjaysdev.pro>"
|
||||||
LABEL org.opencontainers.image.vendor="CasjaysDev"
|
LABEL org.opencontainers.image.vendor="CasjaysDev"
|
||||||
LABEL org.opencontainers.image.authors="CasjaysDev"
|
LABEL org.opencontainers.image.authors="CasjaysDev"
|
||||||
LABEL org.opencontainers.image.description="Containerized version of ${IMAGE_NAME}"
|
LABEL org.opencontainers.image.licenses="${LICENSE}"
|
||||||
LABEL org.opencontainers.image.title="${IMAGE_NAME}"
|
LABEL org.opencontainers.image.title="${IMAGE_NAME}"
|
||||||
LABEL org.opencontainers.image.base.name="${IMAGE_NAME}"
|
LABEL org.opencontainers.image.description="Containerized version of ${IMAGE_NAME}"
|
||||||
LABEL org.opencontainers.image.authors="${LICENSE}"
|
|
||||||
LABEL org.opencontainers.image.created="${BUILD_DATE}"
|
LABEL org.opencontainers.image.created="${BUILD_DATE}"
|
||||||
LABEL org.opencontainers.image.version="${BUILD_VERSION}"
|
LABEL org.opencontainers.image.version="${BUILD_VERSION}"
|
||||||
LABEL org.opencontainers.image.schema-version="${BUILD_VERSION}"
|
|
||||||
LABEL org.opencontainers.image.url="https://hub.docker.com/casjaysdevdocker/go"
|
|
||||||
LABEL org.opencontainers.image.source="https://hub.docker.com/casjaysdevdocker/go"
|
|
||||||
LABEL org.opencontainers.image.vcs-type="Git"
|
|
||||||
LABEL org.opencontainers.image.revision="${GIT_COMMIT}"
|
LABEL org.opencontainers.image.revision="${GIT_COMMIT}"
|
||||||
LABEL org.opencontainers.image.source="https://github.com/casjaysdevdocker/go"
|
LABEL org.opencontainers.image.url="https://docker.io/casjaysdev/go"
|
||||||
LABEL org.opencontainers.image.documentation="https://github.com/casjaysdevdocker/go"
|
LABEL org.opencontainers.image.source="https://github.com/dockersrc/go"
|
||||||
|
LABEL org.opencontainers.image.documentation="https://github.com/dockersrc/go"
|
||||||
|
LABEL org.opencontainers.image.vcs-type="Git"
|
||||||
LABEL com.github.containers.toolbox="false"
|
LABEL com.github.containers.toolbox="false"
|
||||||
|
|
||||||
ENV ENV=~/.bashrc
|
ENV ENV=~/.bashrc
|
||||||
@@ -273,7 +270,7 @@ ENV TERM="xterm-256color"
|
|||||||
ENV PORT="${SERVICE_PORT}"
|
ENV PORT="${SERVICE_PORT}"
|
||||||
ENV ENV_PORTS="${ENV_PORTS}"
|
ENV ENV_PORTS="${ENV_PORTS}"
|
||||||
ENV CONTAINER_NAME="${IMAGE_NAME}"
|
ENV CONTAINER_NAME="${IMAGE_NAME}"
|
||||||
ENV HOSTNAME="casjaysdev-${IMAGE_NAME}"
|
ENV HOSTNAME="casjaysdevdocker-${IMAGE_NAME}"
|
||||||
ENV PHP_SERVER="${PHP_SERVER}"
|
ENV PHP_SERVER="${PHP_SERVER}"
|
||||||
ENV NODE_VERSION="${NODE_VERSION}"
|
ENV NODE_VERSION="${NODE_VERSION}"
|
||||||
ENV NODE_MANAGER="${NODE_MANAGER}"
|
ENV NODE_MANAGER="${NODE_MANAGER}"
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
##@Version : 202605292220-git
|
##@Version : 202607092021-git
|
||||||
# @@Author : CasjaysDev
|
# @@Author : CasjaysDev
|
||||||
# @@Contact : CasjaysDev <docker-admin@casjaysdev.pro>
|
# @@Contact : CasjaysDev <docker-admin@casjaysdev.pro>
|
||||||
# @@License : MIT
|
# @@License : WTFPL
|
||||||
# @@Copyright : Copyright 2026 CasjaysDev
|
# @@Copyright : Copyright 2026 CasjaysDev
|
||||||
# @@Created : Fri May 29 10:20:08 PM EDT 2026
|
# @@Created : Thu Jul 9 08:21:30 PM EDT 2026
|
||||||
# @@File : 00-init.sh
|
# @@File : 00-init.sh
|
||||||
# @@Description : script to run init
|
# @@Description : script to run init
|
||||||
# @@Changelog : newScript
|
# @@Changelog : newScript
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
# shellcheck disable=SC1001,SC1003,SC2001,SC2003,SC2016,SC2031,SC2090,SC2115,SC2120,SC2155,SC2199,SC2229,SC2317,SC2329
|
# shellcheck disable=SC1001,SC1003,SC2001,SC2003,SC2016,SC2031,SC2090,SC2115,SC2120,SC2155,SC2199,SC2229,SC2317,SC2329
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# Set bash options
|
# Set bash options
|
||||||
set -o pipefail
|
set -eo pipefail
|
||||||
[ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -x$DEBUGGER_OPTIONS
|
[ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -x$DEBUGGER_OPTIONS
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# Set env variables
|
# Set env variables
|
||||||
@@ -28,9 +28,7 @@ exitCode=0
|
|||||||
|
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# Predefined actions
|
# Predefined actions
|
||||||
if [ -d "/usr/local/share/template-files/data" ]; then rm -Rf "/usr/local/share/template-files/data"/*; fi
|
|
||||||
if [ -d "/usr/local/share/template-files/config" ]; then rm -Rf "/usr/local/share/template-files/config"/*; fi
|
|
||||||
if [ -d "/usr/local/share/template-files/defaults" ]; then rm -Rf "/usr/local/share/template-files/defaults"/*; fi
|
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# Main script
|
# Main script
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
##@Version : 202605292220-git
|
##@Version : 202607092021-git
|
||||||
# @@Author : CasjaysDev
|
# @@Author : CasjaysDev
|
||||||
# @@Contact : CasjaysDev <docker-admin@casjaysdev.pro>
|
# @@Contact : CasjaysDev <docker-admin@casjaysdev.pro>
|
||||||
# @@License : MIT
|
# @@License : WTFPL
|
||||||
# @@Copyright : Copyright 2026 CasjaysDev
|
# @@Copyright : Copyright 2026 CasjaysDev
|
||||||
# @@Created : Fri May 29 10:20:08 PM EDT 2026
|
# @@Created : Thu Jul 9 08:21:31 PM EDT 2026
|
||||||
# @@File : 01-system.sh
|
# @@File : 01-system.sh
|
||||||
# @@Description : script to run system
|
# @@Description : script to run system
|
||||||
# @@Changelog : newScript
|
# @@Changelog : newScript
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
# shellcheck disable=SC1001,SC1003,SC2001,SC2003,SC2016,SC2031,SC2090,SC2115,SC2120,SC2155,SC2199,SC2229,SC2317,SC2329
|
# shellcheck disable=SC1001,SC1003,SC2001,SC2003,SC2016,SC2031,SC2090,SC2115,SC2120,SC2155,SC2199,SC2229,SC2317,SC2329
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# Set bash options
|
# Set bash options
|
||||||
set -o pipefail
|
set -eo pipefail
|
||||||
[ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -x$DEBUGGER_OPTIONS
|
[ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -x$DEBUGGER_OPTIONS
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# Set env variables
|
# Set env variables
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
##@Version : 202605292220-git
|
##@Version : 202607092021-git
|
||||||
# @@Author : CasjaysDev
|
# @@Author : CasjaysDev
|
||||||
# @@Contact : CasjaysDev <docker-admin@casjaysdev.pro>
|
# @@Contact : CasjaysDev <docker-admin@casjaysdev.pro>
|
||||||
# @@License : MIT
|
# @@License : WTFPL
|
||||||
# @@Copyright : Copyright 2026 CasjaysDev
|
# @@Copyright : Copyright 2026 CasjaysDev
|
||||||
# @@Created : Fri May 29 10:20:09 PM EDT 2026
|
# @@Created : Thu Jul 9 08:21:32 PM EDT 2026
|
||||||
# @@File : 02-packages.sh
|
# @@File : 02-packages.sh
|
||||||
# @@Description : script to run packages
|
# @@Description : script to run packages
|
||||||
# @@Changelog : newScript
|
# @@Changelog : newScript
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
# shellcheck disable=SC1001,SC1003,SC2001,SC2003,SC2016,SC2031,SC2090,SC2115,SC2120,SC2155,SC2199,SC2229,SC2317,SC2329
|
# shellcheck disable=SC1001,SC1003,SC2001,SC2003,SC2016,SC2031,SC2090,SC2115,SC2120,SC2155,SC2199,SC2229,SC2317,SC2329
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# Set bash options
|
# Set bash options
|
||||||
set -o pipefail
|
set -eo pipefail
|
||||||
[ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -x$DEBUGGER_OPTIONS
|
[ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -x$DEBUGGER_OPTIONS
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# Set env variables
|
# Set env variables
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
##@Version : 202605292220-git
|
##@Version : 202607092021-git
|
||||||
# @@Author : CasjaysDev
|
# @@Author : CasjaysDev
|
||||||
# @@Contact : CasjaysDev <docker-admin@casjaysdev.pro>
|
# @@Contact : CasjaysDev <docker-admin@casjaysdev.pro>
|
||||||
# @@License : MIT
|
# @@License : WTFPL
|
||||||
# @@Copyright : Copyright 2026 CasjaysDev
|
# @@Copyright : Copyright 2026 CasjaysDev
|
||||||
# @@Created : Fri May 29 10:20:09 PM EDT 2026
|
# @@Created : Thu Jul 9 08:21:32 PM EDT 2026
|
||||||
# @@File : 03-files.sh
|
# @@File : 03-files.sh
|
||||||
# @@Description : script to run files
|
# @@Description : script to run files
|
||||||
# @@Changelog : newScript
|
# @@Changelog : newScript
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
# shellcheck disable=SC1001,SC1003,SC2001,SC2003,SC2016,SC2031,SC2090,SC2115,SC2120,SC2155,SC2199,SC2229,SC2317,SC2329
|
# shellcheck disable=SC1001,SC1003,SC2001,SC2003,SC2016,SC2031,SC2090,SC2115,SC2120,SC2155,SC2199,SC2229,SC2317,SC2329
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# Set bash options
|
# Set bash options
|
||||||
set -o pipefail
|
set -eo pipefail
|
||||||
[ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -x$DEBUGGER_OPTIONS
|
[ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -x$DEBUGGER_OPTIONS
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# Set env variables
|
# Set env variables
|
||||||
@@ -61,29 +61,23 @@ if [ -d "/tmp/etc" ]; then
|
|||||||
if [ -d "$config" ]; then
|
if [ -d "$config" ]; then
|
||||||
mkdir -p "/etc/$name"
|
mkdir -p "/etc/$name"
|
||||||
cp -Rf "$config/." "/etc/$name/"
|
cp -Rf "$config/." "/etc/$name/"
|
||||||
mkdir -p "/usr/local/share/template-files/config/$name"
|
|
||||||
cp -Rf "$config/." "/usr/local/share/template-files/config/$name/"
|
|
||||||
else
|
else
|
||||||
cp -Rf "$config" "/etc/$name"
|
cp -Rf "$config" "/etc/$name"
|
||||||
cp -Rf "$config" "/usr/local/share/template-files/config/$name"
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
unset config
|
unset config
|
||||||
if [ -d "/tmp/data" ]; then
|
if [ -d "/tmp/usr" ]; then
|
||||||
for data in "/tmp/data"/*; do
|
for share in "/tmp/usr"/*; do
|
||||||
[ -e "$data" ] || continue
|
[ -e "$share" ] || continue
|
||||||
name="${data##*/}"
|
name="${share##*/}"
|
||||||
echo "Installing $data to /usr/local/share/template-files/data"
|
dest="/usr/$name"
|
||||||
if [ -d "$data" ]; then
|
echo "Installing $share to $dest"
|
||||||
mkdir -p "/usr/local/share/template-files/data/$name"
|
mkdir -p "$dest"
|
||||||
cp -Rf "$data/." "/usr/local/share/template-files/data/$name/"
|
cp -Rf "$share/." "$dest/"
|
||||||
else
|
|
||||||
cp -Rf "$data" "/usr/local/share/template-files/data/$name"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
unset data
|
unset share
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# Main script
|
# Main script
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
##@Version : 202605292220-git
|
##@Version : 202607092021-git
|
||||||
# @@Author : CasjaysDev
|
# @@Author : CasjaysDev
|
||||||
# @@Contact : CasjaysDev <docker-admin@casjaysdev.pro>
|
# @@Contact : CasjaysDev <docker-admin@casjaysdev.pro>
|
||||||
# @@License : MIT
|
# @@License : WTFPL
|
||||||
# @@Copyright : Copyright 2026 CasjaysDev
|
# @@Copyright : Copyright 2026 CasjaysDev
|
||||||
# @@Created : Fri May 29 10:20:09 PM EDT 2026
|
# @@Created : Thu Jul 9 08:21:32 PM EDT 2026
|
||||||
# @@File : 04-users.sh
|
# @@File : 04-users.sh
|
||||||
# @@Description : script to run users
|
# @@Description : script to run users
|
||||||
# @@Changelog : newScript
|
# @@Changelog : newScript
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
# shellcheck disable=SC1001,SC1003,SC2001,SC2003,SC2016,SC2031,SC2090,SC2115,SC2120,SC2155,SC2199,SC2229,SC2317,SC2329
|
# shellcheck disable=SC1001,SC1003,SC2001,SC2003,SC2016,SC2031,SC2090,SC2115,SC2120,SC2155,SC2199,SC2229,SC2317,SC2329
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# Set bash options
|
# Set bash options
|
||||||
set -o pipefail
|
set -eo pipefail
|
||||||
[ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -x$DEBUGGER_OPTIONS
|
[ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -x$DEBUGGER_OPTIONS
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# Set env variables
|
# Set env variables
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
##@Version : 202606010000-git
|
##@Version : 202607092021-git
|
||||||
# @@Author : CasjaysDev
|
# @@Author : CasjaysDev
|
||||||
# @@Contact : CasjaysDev <docker-admin@casjaysdev.pro>
|
# @@Contact : CasjaysDev <docker-admin@casjaysdev.pro>
|
||||||
# @@License : MIT
|
# @@License : WTFPL
|
||||||
# @@Copyright : Copyright 2026 CasjaysDev
|
# @@Copyright : Copyright 2026 CasjaysDev
|
||||||
# @@Created : Fri May 29 10:20:10 PM EDT 2026
|
# @@Created : Thu Jul 9 08:21:32 PM EDT 2026
|
||||||
# @@File : 05-custom.sh
|
# @@File : 05-custom.sh
|
||||||
# @@Description : Install Go latest and Go tooling
|
# @@Description : script to run custom
|
||||||
# @@Changelog : Use pre-built binaries where available; go install for the rest
|
# @@Changelog : newScript
|
||||||
# @@TODO : N/A
|
# @@TODO : Refactor code
|
||||||
# @@Other : N/A
|
# @@Other : N/A
|
||||||
# @@Resource : https://go.dev/dl/
|
# @@Resource : N/A
|
||||||
# @@Terminal App : yes
|
# @@Terminal App : yes
|
||||||
# @@sudo/root : yes
|
# @@sudo/root : yes
|
||||||
# @@Template : templates/dockerfiles/init_scripts/05-custom.sh
|
# @@Template : templates/dockerfiles/init_scripts/05-custom.sh
|
||||||
@@ -22,193 +22,15 @@
|
|||||||
# Set bash options
|
# Set bash options
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
[ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -x$DEBUGGER_OPTIONS
|
[ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -x$DEBUGGER_OPTIONS
|
||||||
# Force IPv4 for all curl calls in this script — the base image IPv6 routing
|
|
||||||
# intercepts *.github.com and presents a cert for casjay.in, causing SAN mismatch
|
|
||||||
printf -- '-4\n' > /root/.curlrc
|
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# Set env variables
|
# Set env variables
|
||||||
exitCode=0
|
exitCode=0
|
||||||
|
|
||||||
# Installation root for the Go distribution (not GOPATH)
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
GOINSTALL_DIR="/usr/local/go"
|
# Predefined actions
|
||||||
# GOPATH: module cache, pkg index, user-installed binaries (declared VOLUME)
|
|
||||||
GOPATH_DIR="/usr/local/share/go"
|
|
||||||
# Baked-in tool binaries land here so they are on the default PATH
|
|
||||||
GOBIN_DIR="/usr/local/bin"
|
|
||||||
# Throwaway build cache used only during this image build layer
|
|
||||||
GOCACHE_BUILD="/tmp/go-build-cache"
|
|
||||||
|
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# Helpers
|
# Main script
|
||||||
|
|
||||||
# Return the latest release tag from GitHub; retries up to 3 times on transient errors
|
|
||||||
# (rate-limit 403s are common in parallel multi-platform builds without a token).
|
|
||||||
# Set GITHUB_TOKEN to raise the authenticated rate limit (5000 req/hr vs 60 req/hr).
|
|
||||||
_gh_latest() {
|
|
||||||
local repo="$1"
|
|
||||||
local filter="${2:-.tag_name}"
|
|
||||||
local auth_header=""
|
|
||||||
[ -n "${GITHUB_TOKEN:-}" ] && auth_header="-H Authorization: token ${GITHUB_TOKEN}"
|
|
||||||
local ver attempt
|
|
||||||
for attempt in 1 2 3; do
|
|
||||||
# shellcheck disable=SC2206
|
|
||||||
ver="$(curl -fsSL ${auth_header:+$auth_header} "https://api.github.com/repos/${repo}/releases/latest" | jq -r "${filter}")"
|
|
||||||
if [ -n "$ver" ] && [ "$ver" != "null" ]; then
|
|
||||||
echo "$ver"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
if [ "$attempt" -lt 3 ]; then
|
|
||||||
echo " rate-limited on ${repo} (attempt ${attempt}/3) — retrying in 60s..." >&2
|
|
||||||
sleep 60
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
echo "ERROR: could not resolve latest version for ${repo} after 3 attempts" >&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# Download a tar.gz asset, find a named binary anywhere inside, install to GOBIN_DIR
|
|
||||||
_install_tar() {
|
|
||||||
local url="$1"
|
|
||||||
local bin="$2"
|
|
||||||
local tmp
|
|
||||||
tmp="$(mktemp -d)"
|
|
||||||
echo " → ${bin} from ${url##*/}"
|
|
||||||
curl -fsSL "$url" | tar -C "$tmp" -xz
|
|
||||||
local found
|
|
||||||
found="$(find "$tmp" -name "$bin" -type f | head -1)"
|
|
||||||
if [ -z "$found" ]; then
|
|
||||||
echo "ERROR: binary '${bin}' not found in archive ${url##*/}" >&2
|
|
||||||
rm -rf "$tmp"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
install -m 0755 "$found" "${GOBIN_DIR}/${bin}"
|
|
||||||
rm -rf "$tmp"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Download a single binary asset directly to GOBIN_DIR
|
|
||||||
_install_bin() {
|
|
||||||
local url="$1"
|
|
||||||
local name="$2"
|
|
||||||
echo " → ${name} from ${url##*/}"
|
|
||||||
curl -fsSL "$url" -o "${GOBIN_DIR}/${name}"
|
|
||||||
chmod 0755 "${GOBIN_DIR}/${name}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
# Architecture detection
|
|
||||||
|
|
||||||
# Go convention: amd64 / arm64 / armv6l / 386
|
|
||||||
case "$(uname -m)" in
|
|
||||||
x86_64) _GOARCH="amd64" ;;
|
|
||||||
aarch64) _GOARCH="arm64" ;;
|
|
||||||
armv7l) _GOARCH="armv6l" ;;
|
|
||||||
i386|i686) _GOARCH="386" ;;
|
|
||||||
*)
|
|
||||||
echo "Unsupported architecture: $(uname -m)" >&2
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# uname -m verbatim: buf uses x86_64 / aarch64
|
|
||||||
_UNAME_M="$(uname -m)"
|
|
||||||
|
|
||||||
# goreleaser / ko / goose use x86_64 / arm64 (arm64 not aarch64)
|
|
||||||
if [ "$_UNAME_M" = "aarch64" ]; then
|
|
||||||
_ARCH_GLIBC="arm64"
|
|
||||||
else
|
|
||||||
_ARCH_GLIBC="$_UNAME_M"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
# Install Go distribution
|
|
||||||
|
|
||||||
_GO_VERSION="$(curl -fsSL 'https://go.dev/dl/?mode=json' | jq -r '.[0].version')"
|
|
||||||
echo "Installing ${_GO_VERSION} (linux/${_GOARCH})"
|
|
||||||
|
|
||||||
rm -rf "${GOINSTALL_DIR}"
|
|
||||||
curl -fsSL "https://dl.google.com/go/${_GO_VERSION}.linux-${_GOARCH}.tar.gz" | tar -C /usr/local -xz
|
|
||||||
|
|
||||||
ln -sf "${GOINSTALL_DIR}/bin/go" "${GOBIN_DIR}/go"
|
|
||||||
ln -sf "${GOINSTALL_DIR}/bin/gofmt" "${GOBIN_DIR}/gofmt"
|
|
||||||
|
|
||||||
export GOPATH="${GOPATH_DIR}"
|
|
||||||
export GOBIN="${GOBIN_DIR}"
|
|
||||||
export PATH="${GOINSTALL_DIR}/bin:${PATH}"
|
|
||||||
export GOCACHE="${GOCACHE_BUILD}"
|
|
||||||
export CGO_ENABLED="0"
|
|
||||||
export GOTOOLCHAIN="auto"
|
|
||||||
|
|
||||||
mkdir -p "${GOPATH_DIR}/pkg/mod" "${GOPATH_DIR}/cache" "${GOPATH_DIR}/bin"
|
|
||||||
|
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
# Pre-built binary installs (fast — no compilation)
|
|
||||||
|
|
||||||
echo "Installing pre-built tools"
|
|
||||||
|
|
||||||
# goreleaser — release automation (Linux/x86_64 or Linux/arm64)
|
|
||||||
_GR_VER="$(_gh_latest goreleaser/goreleaser)"
|
|
||||||
_install_tar \
|
|
||||||
"https://github.com/goreleaser/goreleaser/releases/download/${_GR_VER}/goreleaser_Linux_${_ARCH_GLIBC}.tar.gz" \
|
|
||||||
"goreleaser"
|
|
||||||
|
|
||||||
# golangci-lint — meta-linter (official installer handles its own version resolution)
|
|
||||||
curl -fsSL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh \
|
|
||||||
| sh -s -- -b "${GOBIN_DIR}" latest
|
|
||||||
|
|
||||||
# staticcheck — standalone advanced static analyser (linux_amd64 / linux_arm64)
|
|
||||||
_SC_VER="$(_gh_latest dominikh/go-tools)"
|
|
||||||
_install_tar \
|
|
||||||
"https://github.com/dominikh/go-tools/releases/download/${_SC_VER}/staticcheck_linux_${_GOARCH}.tar.gz" \
|
|
||||||
"staticcheck"
|
|
||||||
|
|
||||||
# gofumpt — stricter formatter; asset name includes version: gofumpt_v0.x.y_linux_amd64
|
|
||||||
_GF_VER="$(_gh_latest mvdan/gofumpt)"
|
|
||||||
_install_bin \
|
|
||||||
"https://github.com/mvdan/gofumpt/releases/download/${_GF_VER}/gofumpt_${_GF_VER}_linux_${_GOARCH}" \
|
|
||||||
"gofumpt"
|
|
||||||
|
|
||||||
# gotestsum — structured test runner; asset uses amd64/arm64 (not x86_64)
|
|
||||||
_GTS_VER="$(_gh_latest gotestyourself/gotestsum)"
|
|
||||||
_GTS_TAG="${_GTS_VER#v}"
|
|
||||||
_install_tar \
|
|
||||||
"https://github.com/gotestyourself/gotestsum/releases/download/${_GTS_VER}/gotestsum_${_GTS_TAG}_linux_${_GOARCH}.tar.gz" \
|
|
||||||
"gotestsum"
|
|
||||||
|
|
||||||
# ko — build Go container images without a Dockerfile (Linux/x86_64 or Linux/arm64)
|
|
||||||
_KO_VER="$(_gh_latest google/ko)"
|
|
||||||
_KO_TAG="${_KO_VER#v}"
|
|
||||||
_install_tar \
|
|
||||||
"https://github.com/google/ko/releases/download/${_KO_VER}/ko_${_KO_TAG}_Linux_${_ARCH_GLIBC}.tar.gz" \
|
|
||||||
"ko"
|
|
||||||
|
|
||||||
# air — live-reload dev server; asset: air_1.x.y_linux_amd64 (version without v prefix)
|
|
||||||
_AIR_VER="$(_gh_latest air-verse/air)"
|
|
||||||
_AIR_TAG="${_AIR_VER#v}"
|
|
||||||
_install_bin \
|
|
||||||
"https://github.com/air-verse/air/releases/download/${_AIR_VER}/air_${_AIR_TAG}_linux_${_GOARCH}" \
|
|
||||||
"air"
|
|
||||||
|
|
||||||
# buf — modern protobuf toolchain; uses x86_64/aarch64 (uname -m convention)
|
|
||||||
_BUF_VER="$(_gh_latest bufbuild/buf)"
|
|
||||||
_install_bin \
|
|
||||||
"https://github.com/bufbuild/buf/releases/download/${_BUF_VER}/buf-Linux-${_UNAME_M}" \
|
|
||||||
"buf"
|
|
||||||
|
|
||||||
# goose — DB migration runner (linux_x86_64 or linux_arm64)
|
|
||||||
_GOOSE_VER="$(_gh_latest pressly/goose)"
|
|
||||||
_install_bin \
|
|
||||||
"https://github.com/pressly/goose/releases/download/${_GOOSE_VER}/goose_linux_${_ARCH_GLIBC}" \
|
|
||||||
"goose"
|
|
||||||
|
|
||||||
# go install tools (goimports, stringer, gopls, govulncheck, dlv, gops, benchstat,
|
|
||||||
# wire, mockgen, protoc-gen-go, protoc-gen-go-grpc) are cross-compiled natively on
|
|
||||||
# the build platform in the Dockerfile go-tools stage and copied to /usr/local/bin
|
|
||||||
# before this script runs — no QEMU-emulated compilation needed here.
|
|
||||||
|
|
||||||
# Strip the module download cache and ephemeral build cache from this layer
|
|
||||||
go clean -modcache
|
|
||||||
go clean -cache
|
|
||||||
rm -rf "${GOCACHE_BUILD}"
|
|
||||||
|
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# Set the exit code
|
# Set the exit code
|
||||||
@@ -218,3 +40,4 @@ exit $exitCode
|
|||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# ex: ts=2 sw=2 et filetype=sh
|
# ex: ts=2 sw=2 et filetype=sh
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
##@Version : 202605292220-git
|
##@Version : 202607092021-git
|
||||||
# @@Author : CasjaysDev
|
# @@Author : CasjaysDev
|
||||||
# @@Contact : CasjaysDev <docker-admin@casjaysdev.pro>
|
# @@Contact : CasjaysDev <docker-admin@casjaysdev.pro>
|
||||||
# @@License : MIT
|
# @@License : WTFPL
|
||||||
# @@Copyright : Copyright 2026 CasjaysDev
|
# @@Copyright : Copyright 2026 CasjaysDev
|
||||||
# @@Created : Fri May 29 10:20:11 PM EDT 2026
|
# @@Created : Thu Jul 9 08:21:32 PM EDT 2026
|
||||||
# @@File : 06-post.sh
|
# @@File : 06-post.sh
|
||||||
# @@Description : script to run post
|
# @@Description : script to run post
|
||||||
# @@Changelog : newScript
|
# @@Changelog : newScript
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
# shellcheck disable=SC1001,SC1003,SC2001,SC2003,SC2016,SC2031,SC2090,SC2115,SC2120,SC2155,SC2199,SC2229,SC2317,SC2329
|
# shellcheck disable=SC1001,SC1003,SC2001,SC2003,SC2016,SC2031,SC2090,SC2115,SC2120,SC2155,SC2199,SC2229,SC2317,SC2329
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# Set bash options
|
# Set bash options
|
||||||
set -o pipefail
|
set -eo pipefail
|
||||||
[ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -x$DEBUGGER_OPTIONS
|
[ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -x$DEBUGGER_OPTIONS
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# Set env variables
|
# Set env variables
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
##@Version : 202605292220-git
|
##@Version : 202607092021-git
|
||||||
# @@Author : CasjaysDev
|
# @@Author : CasjaysDev
|
||||||
# @@Contact : CasjaysDev <docker-admin@casjaysdev.pro>
|
# @@Contact : CasjaysDev <docker-admin@casjaysdev.pro>
|
||||||
# @@License : MIT
|
# @@License : WTFPL
|
||||||
# @@Copyright : Copyright 2026 CasjaysDev
|
# @@Copyright : Copyright 2026 CasjaysDev
|
||||||
# @@Created : Fri May 29 10:20:11 PM EDT 2026
|
# @@Created : Thu Jul 9 08:21:33 PM EDT 2026
|
||||||
# @@File : 07-cleanup.sh
|
# @@File : 07-cleanup.sh
|
||||||
# @@Description : script to run cleanup
|
# @@Description : script to run cleanup
|
||||||
# @@Changelog : newScript
|
# @@Changelog : newScript
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
# shellcheck disable=SC1001,SC1003,SC2001,SC2003,SC2016,SC2031,SC2090,SC2115,SC2120,SC2155,SC2199,SC2229,SC2317,SC2329
|
# shellcheck disable=SC1001,SC1003,SC2001,SC2003,SC2016,SC2031,SC2090,SC2115,SC2120,SC2155,SC2199,SC2229,SC2317,SC2329
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# Set bash options
|
# Set bash options
|
||||||
set -o pipefail
|
set -eo pipefail
|
||||||
[ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -x$DEBUGGER_OPTIONS
|
[ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -x$DEBUGGER_OPTIONS
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# Load functions
|
# Load functions
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
##@Version : 202606261500-git
|
##@Version : 202607082023-git
|
||||||
# @@Author : Jason Hempstead
|
# @@Author : Jason Hempstead
|
||||||
# @@Contact : jason@casjaysdev.pro
|
# @@Contact : jason@casjaysdev.pro
|
||||||
# @@License : WTFPL
|
# @@License : WTFPL
|
||||||
# @@ReadME : entrypoint.sh --help
|
# @@ReadME : entrypoint.sh --help
|
||||||
# @@Copyright : Copyright: (c) 2026 Jason Hempstead, Casjays Developments
|
# @@Copyright : Copyright: (c) 2026 Jason Hempstead, Casjays Developments
|
||||||
# @@Created : Friday, May 29, 2026 22:19 EDT
|
# @@Created : Thursday, Jul 09, 2026 20:21 EDT
|
||||||
# @@File : entrypoint.sh
|
# @@File : entrypoint.sh
|
||||||
# @@Description : Entrypoint file for alpine
|
# @@Description : Entrypoint file for go
|
||||||
# @@Changelog : New script
|
# @@Changelog : New script
|
||||||
# @@TODO : Better documentation
|
# @@TODO : Better documentation
|
||||||
# @@Other :
|
# @@Other :
|
||||||
@@ -28,11 +28,11 @@ trap 'retVal=$?;[ "$SERVICE_IS_RUNNING" != "yes" ] && [ -f "$SERVICE_PID_FILE" ]
|
|||||||
[ -f "/config/.debug" ] && [ -z "$DEBUGGER_OPTIONS" ] && export DEBUGGER_OPTIONS="$(<"/config/.debug")" || DEBUGGER_OPTIONS="${DEBUGGER_OPTIONS:-}"
|
[ -f "/config/.debug" ] && [ -z "$DEBUGGER_OPTIONS" ] && export DEBUGGER_OPTIONS="$(<"/config/.debug")" || DEBUGGER_OPTIONS="${DEBUGGER_OPTIONS:-}"
|
||||||
if [ "$DEBUGGER" = "on" ] || [ -f "/config/.debug" ]; then
|
if [ "$DEBUGGER" = "on" ] || [ -f "/config/.debug" ]; then
|
||||||
echo "Enabling debugging"
|
echo "Enabling debugging"
|
||||||
set -o pipefail
|
set -eo pipefail
|
||||||
[ -n "$DEBUGGER_OPTIONS" ] && set -"$DEBUGGER_OPTIONS"
|
[ -n "$DEBUGGER_OPTIONS" ] && set -"$DEBUGGER_OPTIONS"
|
||||||
export DEBUGGER="on"
|
export DEBUGGER="on"
|
||||||
else
|
else
|
||||||
set -o pipefail
|
set -eo pipefail
|
||||||
fi
|
fi
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
PATH="/usr/local/etc/docker/bin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin"
|
PATH="/usr/local/etc/docker/bin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin"
|
||||||
@@ -95,8 +95,8 @@ SERVICE_UID="${SERVICE_UID:-0}"
|
|||||||
SERVICE_GID="${SERVICE_GID:-0}"
|
SERVICE_GID="${SERVICE_GID:-0}"
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# User and group in which the service switches to - IE: nginx,apache,mysql,postgres
|
# User and group in which the service switches to - IE: nginx,apache,mysql,postgres
|
||||||
#SERVICE_USER="${SERVICE_USER:-alpine}" # execute command as another user
|
#SERVICE_USER="${SERVICE_USER:-go}" # execute command as another user
|
||||||
#SERVICE_GROUP="${SERVICE_GROUP:-alpine}" # Set the service group
|
#SERVICE_GROUP="${SERVICE_GROUP:-go}" # Set the service group
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# Secondary ports
|
# Secondary ports
|
||||||
# specifiy other ports
|
# specifiy other ports
|
||||||
@@ -108,7 +108,7 @@ WEB_SERVER_PORT=""
|
|||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# Healthcheck variables
|
# Healthcheck variables
|
||||||
# enable healthcheck [yes/no]
|
# enable healthcheck [yes/no]
|
||||||
HEALTH_ENABLED="${HEALTH_ENABLED:-yes}"
|
HEALTH_ENABLED="yes"
|
||||||
# comma separated list of processes for the healthcheck
|
# comma separated list of processes for the healthcheck
|
||||||
SERVICES_LIST="tini"
|
SERVICES_LIST="tini"
|
||||||
# url endpoints: [http://localhost/health,http://localhost/test]
|
# url endpoints: [http://localhost/health,http://localhost/test]
|
||||||
@@ -123,7 +123,7 @@ export PATH RUNAS_USER SERVICE_USER SERVICE_GROUP SERVICE_UID SERVICE_GID WWW_RO
|
|||||||
# show message
|
# show message
|
||||||
__run_message() {
|
__run_message() {
|
||||||
|
|
||||||
return
|
return 0
|
||||||
}
|
}
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
################## END OF CONFIGURATION #####################
|
################## END OF CONFIGURATION #####################
|
||||||
@@ -155,9 +155,6 @@ export SSL_CA="${SSL_CA:-/config/ssl/ca.crt}"
|
|||||||
export SSL_KEY="${SSL_KEY:-/config/ssl/localhost.pem}"
|
export SSL_KEY="${SSL_KEY:-/config/ssl/localhost.pem}"
|
||||||
export SSL_CERT="${SSL_CERT:-/config/ssl/localhost.crt}"
|
export SSL_CERT="${SSL_CERT:-/config/ssl/localhost.crt}"
|
||||||
export LOCAL_BIN_DIR="${LOCAL_BIN_DIR:-/usr/local/bin}"
|
export LOCAL_BIN_DIR="${LOCAL_BIN_DIR:-/usr/local/bin}"
|
||||||
export DEFAULT_DATA_DIR="${DEFAULT_DATA_DIR:-/usr/local/share/template-files/data}"
|
|
||||||
export DEFAULT_CONF_DIR="${DEFAULT_CONF_DIR:-/usr/local/share/template-files/config}"
|
|
||||||
export DEFAULT_TEMPLATE_DIR="${DEFAULT_TEMPLATE_DIR:-/usr/local/share/template-files/defaults}"
|
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# Backup settings
|
# Backup settings
|
||||||
export BACKUP_MAX_DAYS="${BACKUP_MAX_DAYS:-}"
|
export BACKUP_MAX_DAYS="${BACKUP_MAX_DAYS:-}"
|
||||||
@@ -214,15 +211,15 @@ else
|
|||||||
fi
|
fi
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# clean ENV_PORTS variables
|
# clean ENV_PORTS variables
|
||||||
ENV_PORTS="${ENV_PORTS//,/ }" #
|
ENV_PORTS="${ENV_PORTS//,/ }"
|
||||||
ENV_PORTS="${ENV_PORTS//\/*/}" #
|
ENV_PORTS="${ENV_PORTS//\/*/}"
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# clean SERVER_PORTS variables
|
# clean SERVER_PORTS variables
|
||||||
SERVER_PORTS="${SERVER_PORTS//,/ }" #
|
SERVER_PORTS="${SERVER_PORTS//,/ }"
|
||||||
SERVER_PORTS="${SERVER_PORTS//\/*/}" #
|
SERVER_PORTS="${SERVER_PORTS//\/*/}"
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# clean WEB_SERVER_PORTS variables
|
# clean WEB_SERVER_PORTS variables
|
||||||
WEB_SERVER_PORTS="${WEB_SERVER_PORT//,/ } ${ENV_WEB_SERVER_PORTS//,/ }" #
|
WEB_SERVER_PORTS="${WEB_SERVER_PORT//,/ } ${ENV_WEB_SERVER_PORTS//,/ }"
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# rewrite and merge variables
|
# rewrite and merge variables
|
||||||
ENV_PORTS="$(__format_variables "$ENV_PORTS" || false)"
|
ENV_PORTS="$(__format_variables "$ENV_PORTS" || false)"
|
||||||
@@ -373,7 +370,7 @@ if [ "$ENTRYPOINT_FIRST_RUN" != "no" ]; then
|
|||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# import hosts file into container
|
# import hosts file into container
|
||||||
if [ -f "/usr/local/etc/hosts" ] && [ "$UPDATE_FILE_HOSTS" = "yes" ]; then
|
if [ -f "/usr/local/etc/hosts" ] && [ "$UPDATE_FILE_HOSTS" = "yes" ]; then
|
||||||
grep -vF "$HOSTNAME" "/usr/local/etc/hosts" 2>/dev/null >>"/etc/hosts" || true
|
grep -vF -- "$HOSTNAME" "/usr/local/etc/hosts" 2>/dev/null >>"/etc/hosts" || true
|
||||||
fi
|
fi
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# import resolv.conf file into container
|
# import resolv.conf file into container
|
||||||
@@ -425,8 +422,8 @@ if [ "$ENTRYPOINT_FIRST_RUN" != "no" ] || [ "$CONFIG_DIR_INITIALIZED" = "no" ] |
|
|||||||
echo "Initialized on: $INIT_DATE" >"$ENTRYPOINT_INIT_FILE" 2>/dev/null || true
|
echo "Initialized on: $INIT_DATE" >"$ENTRYPOINT_INIT_FILE" 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# setup the smtp server — non-fatal; this image does not use ssmtp
|
# setup the smtp server
|
||||||
__setup_mta || true
|
__setup_mta
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
ENTRYPOINT_FIRST_RUN="no"
|
ENTRYPOINT_FIRST_RUN="no"
|
||||||
fi
|
fi
|
||||||
@@ -491,11 +488,9 @@ if [ "$START_SERVICES" = "yes" ] || [ -z "$1" ]; then
|
|||||||
echo "$$" >"$ENTRYPOINT_PID_FILE"
|
echo "$$" >"$ENTRYPOINT_PID_FILE"
|
||||||
__start_init_scripts "/usr/local/etc/docker/init.d"
|
__start_init_scripts "/usr/local/etc/docker/init.d"
|
||||||
CONTAINER_INIT="${CONTAINER_INIT:-no}"
|
CONTAINER_INIT="${CONTAINER_INIT:-no}"
|
||||||
# No user command: run default Go workflow instead of blocking
|
# Services started successfully - enter monitoring mode
|
||||||
if [ $# -eq 0 ]; then
|
__no_exit
|
||||||
go-workflow "$@"
|
exit $?
|
||||||
exit $?
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
START_SERVICES="no"
|
START_SERVICES="no"
|
||||||
fi
|
fi
|
||||||
@@ -581,7 +576,7 @@ healthcheck)
|
|||||||
services+="$name "
|
services+="$name "
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
services="$(printf '%s\n' $services | sort -u | grep -v '^$')"
|
services="$(printf '%s\n' $services | sort -u | grep -v -- '^$')"
|
||||||
for proc in $services; do
|
for proc in $services; do
|
||||||
if [ -n "$proc" ]; then
|
if [ -n "$proc" ]; then
|
||||||
if ! __pgrep "$proc"; then
|
if ! __pgrep "$proc"; then
|
||||||
@@ -592,7 +587,7 @@ healthcheck)
|
|||||||
done
|
done
|
||||||
for port in $healthPorts; do
|
for port in $healthPorts; do
|
||||||
if command -v netstat &>/dev/null && [ -n "$port" ]; then
|
if command -v netstat &>/dev/null && [ -n "$port" ]; then
|
||||||
if ! netstat -taupln | grep -q ":$port "; then
|
if ! netstat -taupln | grep -q -- ":$port "; then
|
||||||
echo "$port isn't open" >&2
|
echo "$port isn't open" >&2
|
||||||
healthStatus=$((healthStatus + 1))
|
healthStatus=$((healthStatus + 1))
|
||||||
fi
|
fi
|
||||||
@@ -622,29 +617,25 @@ ports)
|
|||||||
# show running processes
|
# show running processes
|
||||||
procs)
|
procs)
|
||||||
shift 1
|
shift 1
|
||||||
ps="$(__ps axco command 2>/dev/null | grep -vE '^(COMMAND|grep|ps)$' | sort -u)"
|
ps="$(__ps axco command 2>/dev/null | grep -vE -- '^(COMMAND|grep|ps)$' | sort -u)"
|
||||||
[ -n "$ps" ] && printf '%s\n%s\n' "Found the following processes" "$ps" | tr '\n' ' '
|
[ -n "$ps" ] && printf '%s\n%s\n' "Found the following processes" "$ps" | tr '\n' ' '
|
||||||
exit $?
|
exit $?
|
||||||
;;
|
;;
|
||||||
# Launch shell
|
# Launch shell
|
||||||
*/bin/sh | */bin/bash | bash | sh | shell)
|
*/bin/sh | */bin/bash | bash | sh | shell)
|
||||||
shell_bin="$(type -P "${1}" 2>/dev/null || echo "/bin/bash")"
|
|
||||||
shift 1
|
shift 1
|
||||||
if [ $# -gt 0 ]; then
|
__exec_command "$@"
|
||||||
__exec_command "$shell_bin" "$@"
|
|
||||||
else
|
|
||||||
__exec_command "$shell_bin" -l
|
|
||||||
fi
|
|
||||||
exit $?
|
exit $?
|
||||||
;;
|
;;
|
||||||
# execute commands
|
# execute commands
|
||||||
exec)
|
exec)
|
||||||
shift 1
|
shift 1
|
||||||
if [ $# -eq 0 ]; then
|
if [ $# -eq 0 ]; then
|
||||||
echo "Error: exec requires a command" >&2
|
echo "No command given to exec" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
exec "$@"
|
__exec_command "$@"
|
||||||
|
exit $?
|
||||||
;;
|
;;
|
||||||
# show/start init scripts
|
# show/start init scripts
|
||||||
start)
|
start)
|
||||||
@@ -669,11 +660,15 @@ start)
|
|||||||
# Execute primary command
|
# Execute primary command
|
||||||
*)
|
*)
|
||||||
if [ $# -eq 0 ]; then
|
if [ $# -eq 0 ]; then
|
||||||
# No args: run the default Go workflow (tidy → fmt → vet → test → build)
|
if [ ! -f "$ENTRYPOINT_PID_FILE" ]; then
|
||||||
exec go-workflow
|
echo "$$" >"$ENTRYPOINT_PID_FILE"
|
||||||
|
[ "$START_SERVICES" = "no" ] && [ "$CONTAINER_INIT" = "yes" ] || __start_init_scripts "/usr/local/etc/docker/init.d"
|
||||||
|
fi
|
||||||
|
__no_exit
|
||||||
else
|
else
|
||||||
exec "$@"
|
__exec_command "$@"
|
||||||
fi
|
fi
|
||||||
|
exit $?
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
##@Version : 202606261430-git
|
##@Version : 202607082330-git
|
||||||
# @@Author : Jason Hempstead
|
# @@Author : Jason Hempstead
|
||||||
# @@Contact : git-admin@casjaysdev.pro
|
# @@Contact : git-admin@casjaysdev.pro
|
||||||
# @@License : LICENSE.md
|
# @@License : LICENSE.md
|
||||||
@@ -93,7 +93,11 @@ __is_in_file() { [ -e "$2" ] && grep -Rsq "$1" "$2" 2>/dev/null; }
|
|||||||
__curl() { curl -q -sfI --max-time 3 -k -o /dev/null "$@" 2>/dev/null || return 10; }
|
__curl() { curl -q -sfI --max-time 3 -k -o /dev/null "$@" 2>/dev/null || return 10; }
|
||||||
__find() {
|
__find() {
|
||||||
local result
|
local result
|
||||||
result=$(find "$1" -mindepth 1 -type "${2:-f,d}" 2>/dev/null)
|
if [ -n "$2" ]; then
|
||||||
|
result=$(find "$1" -mindepth 1 -type "$2" 2>/dev/null)
|
||||||
|
else
|
||||||
|
result=$(find "$1" -mindepth 1 \( -type f -o -type d \) 2>/dev/null)
|
||||||
|
fi
|
||||||
[ -n "$result" ] || return 10
|
[ -n "$result" ] || return 10
|
||||||
printf '%s\n' "$result"
|
printf '%s\n' "$result"
|
||||||
}
|
}
|
||||||
@@ -371,17 +375,23 @@ __init_working_dir() {
|
|||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
__exec_service() {
|
__exec_service() {
|
||||||
local count=6
|
local count=6
|
||||||
|
local bgpid
|
||||||
[ "$DEBUGGER" = "on" ] && echo "Starting $1"
|
[ "$DEBUGGER" = "on" ] && echo "Starting $1"
|
||||||
eval "$@" 2>>/dev/stderr >>/data/logs/start.log &
|
eval "$@" &
|
||||||
|
bgpid=$!
|
||||||
while [ $count -ne 0 ]; do
|
while [ $count -ne 0 ]; do
|
||||||
sleep 3
|
sleep 3
|
||||||
|
if ! kill -0 "$bgpid" 2>/dev/null; then
|
||||||
|
wait "$bgpid"
|
||||||
|
return $?
|
||||||
|
fi
|
||||||
if __pgrep "$1"; then
|
if __pgrep "$1"; then
|
||||||
touch "/run/init.d/$1.pid"
|
touch "/run/init.d/$1.pid"
|
||||||
break
|
return 0
|
||||||
else
|
|
||||||
count=$((count - 1))
|
|
||||||
fi
|
fi
|
||||||
|
count=$((count - 1))
|
||||||
done
|
done
|
||||||
|
return 1
|
||||||
}
|
}
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
__update_ssl_certs() {
|
__update_ssl_certs() {
|
||||||
@@ -791,26 +801,24 @@ __proc_check() {
|
|||||||
|
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
__set_user_group_id() {
|
__set_user_group_id() {
|
||||||
local exitStatus=0
|
|
||||||
local set_user="${1:-$SERVICE_USER}"
|
local set_user="${1:-$SERVICE_USER}"
|
||||||
local set_uid="${2:-${SERVICE_UID:-1000}}"
|
local set_uid="${2:-${SERVICE_UID:-1000}}"
|
||||||
local set_gid="${3:-${SERVICE_GID:-1000}}"
|
local set_gid="${3:-${SERVICE_GID:-1000}}"
|
||||||
local random_id="$(__generate_random_uids)"
|
# Nothing to do for root or unset
|
||||||
set_uid="$(__get_uid "$set_user" || echo "$set_uid")"
|
|
||||||
set_gid="$(__get_gid "$set_user" || echo "$set_gid")"
|
|
||||||
if ! grep -shq "^$set_user:" "/etc/passwd" "/etc/group"; then
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
if [ -z "$set_user" ] || [ "$set_user" = "root" ]; then
|
if [ -z "$set_user" ] || [ "$set_user" = "root" ]; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
if grep -shq "^$set_user:" "/etc/passwd" "/etc/group"; then
|
# Nothing to do if the user does not exist yet
|
||||||
if __check_for_guid "$set_gid"; then
|
if ! grep -shq "^$set_user:" "/etc/passwd" "/etc/group"; then
|
||||||
groupmod -g "${set_gid}" $set_user 2>/dev/stderr | tee -p -a "/data/logs/init.txt" >/dev/null
|
return 0
|
||||||
fi
|
fi
|
||||||
if __check_for_uid "$set_uid"; then
|
set_uid="$(__get_uid "$set_user" || echo "$set_uid")"
|
||||||
usermod -u "${set_uid}" -g "${set_gid}" $set_user 2>/dev/stderr | tee -p -a "/data/logs/init.txt" >/dev/null
|
set_gid="$(__get_gid "$set_user" || echo "$set_gid")"
|
||||||
fi
|
if __check_for_guid "$set_gid"; then
|
||||||
|
groupmod -g "${set_gid}" "$set_user" 2>/dev/stderr | tee -a "/data/logs/init.txt" >/dev/null
|
||||||
|
fi
|
||||||
|
if __check_for_uid "$set_uid"; then
|
||||||
|
usermod -u "${set_uid}" -g "${set_gid}" "$set_user" 2>/dev/stderr | tee -a "/data/logs/init.txt" >/dev/null
|
||||||
fi
|
fi
|
||||||
export SERVICE_UID="$set_uid"
|
export SERVICE_UID="$set_uid"
|
||||||
export SERVICE_GID="$set_gid"
|
export SERVICE_GID="$set_gid"
|
||||||
@@ -826,15 +834,14 @@ __create_service_user() {
|
|||||||
local create_uid="${4:-${SERVICE_UID:-$USER_UID}}"
|
local create_uid="${4:-${SERVICE_UID:-$USER_UID}}"
|
||||||
local create_gid="${5:-${SERVICE_GID:-$USER_GID}}"
|
local create_gid="${5:-${SERVICE_GID:-$USER_GID}}"
|
||||||
local random_id="$(__generate_random_uids)"
|
local random_id="$(__generate_random_uids)"
|
||||||
local create_home_dir="${create_home_dir:-/home/$create_user}"
|
|
||||||
local log_file="/data/logs/init.txt"
|
local log_file="/data/logs/init.txt"
|
||||||
# Ensure log directory exists
|
# Nothing to do for unset or root user — return silently
|
||||||
[ -d "$(dirname "$log_file")" ] || mkdir -p "$(dirname "$log_file")" 2>/dev/null
|
create_home_dir="${create_home_dir:-/home/$create_user}"
|
||||||
# Validate that we have at least a user or group to create
|
if [ -z "$create_user" ] || [ "$create_user" = "root" ]; then
|
||||||
if [ -z "$create_user" ] && [ -z "$create_group" ]; then
|
|
||||||
echo "No user or group specified to create" >&2
|
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
# Ensure log directory exists
|
||||||
|
[ -d "$(dirname "$log_file")" ] || mkdir -p "$(dirname "$log_file")" 2>/dev/null
|
||||||
# Validate user/group name format (alphanumeric, underscore, hyphen; must start with letter or underscore)
|
# Validate user/group name format (alphanumeric, underscore, hyphen; must start with letter or underscore)
|
||||||
if [ -n "$create_user" ] && [[ ! "$create_user" =~ ^[a-z_][a-z0-9_-]*$ ]]; then
|
if [ -n "$create_user" ] && [[ ! "$create_user" =~ ^[a-z_][a-z0-9_-]*$ ]]; then
|
||||||
echo "Error: Invalid username format '$create_user' - must start with letter/underscore, contain only lowercase alphanumeric, underscore, or hyphen" >&2
|
echo "Error: Invalid username format '$create_user' - must start with letter/underscore, contain only lowercase alphanumeric, underscore, or hyphen" >&2
|
||||||
@@ -848,10 +855,6 @@ __create_service_user() {
|
|||||||
if grep -shq "^$create_user:" "/etc/passwd" && grep -shq "^$create_group:" "/etc/group"; then
|
if grep -shq "^$create_user:" "/etc/passwd" && grep -shq "^$create_group:" "/etc/group"; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
# Root user/group - nothing to create
|
|
||||||
if [ "$create_user" = "root" ] && [ "$create_group" = "root" ]; then
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
# Override with RUNAS_USER if specified and not root
|
# Override with RUNAS_USER if specified and not root
|
||||||
if [ -n "$RUNAS_USER" ] && [ "$RUNAS_USER" != "root" ]; then
|
if [ -n "$RUNAS_USER" ] && [ "$RUNAS_USER" != "root" ]; then
|
||||||
create_user="$RUNAS_USER"
|
create_user="$RUNAS_USER"
|
||||||
@@ -968,7 +971,6 @@ __create_env_file() {
|
|||||||
}
|
}
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
__exec_command() {
|
__exec_command() {
|
||||||
local exitCode=0
|
|
||||||
if [ $# -eq 0 ]; then
|
if [ $# -eq 0 ]; then
|
||||||
exec bash -l
|
exec bash -l
|
||||||
fi
|
fi
|
||||||
@@ -1071,7 +1073,7 @@ __start_init_scripts() {
|
|||||||
__service_banner "✅" "Service $service started successfully -" "PID: ${retPID} ($found_process)"
|
__service_banner "✅" "Service $service started successfully -" "PID: ${retPID} ($found_process)"
|
||||||
elif [ -f "$expected_pid_file" ]; then
|
elif [ -f "$expected_pid_file" ]; then
|
||||||
# No running process but PID file exists - verify PID is valid
|
# No running process but PID file exists - verify PID is valid
|
||||||
file_pid=$(<"$expected_pid_file") 2>/dev/null
|
file_pid=$(cat "$expected_pid_file" 2>/dev/null)
|
||||||
if [ -n "$file_pid" ] && kill -0 "$file_pid" 2>/dev/null; then
|
if [ -n "$file_pid" ] && kill -0 "$file_pid" 2>/dev/null; then
|
||||||
initStatus="0"
|
initStatus="0"
|
||||||
__service_banner "✅" "Service $service started successfully -" "PID: $file_pid (from file)"
|
__service_banner "✅" "Service $service started successfully -" "PID: $file_pid (from file)"
|
||||||
@@ -1124,12 +1126,28 @@ __setup_mta() {
|
|||||||
# /etc/postfix ships in some base images (casjaysdev/alpine) even without postfix.
|
# /etc/postfix ships in some base images (casjaysdev/alpine) even without postfix.
|
||||||
command -v ssmtp &>/dev/null || command -v postfix &>/dev/null || return 0
|
command -v ssmtp &>/dev/null || command -v postfix &>/dev/null || return 0
|
||||||
local exitCode=0
|
local exitCode=0
|
||||||
local relay_port="${EMAIL_RELAY//*:/}"
|
# Extract server and port only when EMAIL_RELAY contains a colon
|
||||||
local relay_server="${EMAIL_RELAY//:*/}"
|
local relay_server="" relay_port=""
|
||||||
|
if [[ "$EMAIL_RELAY" == *:* ]]; then
|
||||||
|
relay_server="${EMAIL_RELAY%%:*}"
|
||||||
|
relay_port="${EMAIL_RELAY##*:}"
|
||||||
|
else
|
||||||
|
relay_server="$EMAIL_RELAY"
|
||||||
|
fi
|
||||||
local local_hostname="${FULL_DOMAIN_NAME:-}"
|
local local_hostname="${FULL_DOMAIN_NAME:-}"
|
||||||
local account_user="${SERVER_ADMIN//@*/}"
|
local account_user="${SERVER_ADMIN//@*/}"
|
||||||
local account_domain="${EMAIL_DOMAIN//*@/}"
|
local account_domain="${EMAIL_DOMAIN//*@/}"
|
||||||
[[ $EMAIL_RELAY == *[0-9][0-9]* ]] || relay_port="465"
|
# Default to port 25 — plain SMTP, no cert validation required
|
||||||
|
relay_port="${relay_port:-25}"
|
||||||
|
# Autodetect Docker host gateway as SMTP relay when EMAIL_RELAY is unset
|
||||||
|
if [ -z "$EMAIL_RELAY" ] && timeout 2 bash -c 'echo >/dev/tcp/172.17.0.1/25' 2>/dev/null; then
|
||||||
|
relay_server="172.17.0.1"
|
||||||
|
relay_port="25"
|
||||||
|
fi
|
||||||
|
# Port 25 is plain SMTP — no TLS; anything else defaults to TLS on
|
||||||
|
local relay_use_tls="Yes"
|
||||||
|
local relay_smtp_tls="yes"
|
||||||
|
[ "$relay_port" = "25" ] && relay_use_tls="No" && relay_smtp_tls="no"
|
||||||
################# sSMTP relay setup
|
################# sSMTP relay setup
|
||||||
if command -v ssmtp &>/dev/null; then
|
if command -v ssmtp &>/dev/null; then
|
||||||
[ -d "/config/ssmtp" ] || mkdir -p "/config/ssmtp"
|
[ -d "/config/ssmtp" ] || mkdir -p "/config/ssmtp"
|
||||||
@@ -1143,7 +1161,7 @@ mailhub=${relay_server:-172.17.0.1}:$relay_port
|
|||||||
rewriteDomain=$local_hostname
|
rewriteDomain=$local_hostname
|
||||||
hostname=$local_hostname
|
hostname=$local_hostname
|
||||||
TLS_CA_FILE=/etc/ssl/certs/ca-certificates.crt
|
TLS_CA_FILE=/etc/ssl/certs/ca-certificates.crt
|
||||||
UseTLS=Yes
|
UseTLS=${relay_use_tls}
|
||||||
UseSTARTTLS=No
|
UseSTARTTLS=No
|
||||||
AuthMethod=LOGIN
|
AuthMethod=LOGIN
|
||||||
FromLineOverride=yes
|
FromLineOverride=yes
|
||||||
@@ -1191,7 +1209,7 @@ transport_maps = hash:/etc/postfix/transport
|
|||||||
virtual_alias_maps = hash:/etc/postfix/virtual
|
virtual_alias_maps = hash:/etc/postfix/virtual
|
||||||
relay_domains = hash:/etc/postfix/mydomains, regexp:/etc/postfix/mydomains.pcre
|
relay_domains = hash:/etc/postfix/mydomains, regexp:/etc/postfix/mydomains.pcre
|
||||||
tls_random_source = dev:/dev/urandom
|
tls_random_source = dev:/dev/urandom
|
||||||
smtp_use_tls = yes
|
smtp_use_tls = ${relay_smtp_tls}
|
||||||
smtpd_use_tls = yes
|
smtpd_use_tls = yes
|
||||||
smtpd_tls_session_cache_database = btree:/etc/postfix/smtpd_scache
|
smtpd_tls_session_cache_database = btree:/etc/postfix/smtpd_scache
|
||||||
smtpd_tls_exclude_ciphers = aNULL, eNULL, EXPORT, DES, RC4, MD5, PSK, aECDH, EDH-DSS-DES-CBC3-SHA, EDH-RSA-DES-CBC3-SHA, KRB5-DES, CBC3-SHA
|
smtpd_tls_exclude_ciphers = aNULL, eNULL, EXPORT, DES, RC4, MD5, PSK, aECDH, EDH-DSS-DES-CBC3-SHA, EDH-RSA-DES-CBC3-SHA, KRB5-DES, CBC3-SHA
|
||||||
@@ -1432,16 +1450,18 @@ __initialize_ssl_certs() {
|
|||||||
}
|
}
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
__start_php_dev_server() {
|
__start_php_dev_server() {
|
||||||
if [ "$2" = "yes" ]; then
|
[ "$2" = "yes" ] || return 0
|
||||||
if [ -d "/usr/local/share/httpd" ]; then
|
local docroot=""
|
||||||
find "/usr/local/share/httpd" -type f -not -path '.git*' -iname '*.php' -exec sed -i 's|[<].*SERVER_ADDR.*[>]|'${CONTAINER_IP4_ADDRESS:-127.0.0.1}'|g' {} \; 2>/dev/null
|
# Prefer a custom doc root when it differs from the default share path
|
||||||
php -S 0.0.0.0:$PHP_DEV_SERVER_PORT -t "/usr/local/share/httpd"
|
if [ -n "$1" ] && [[ "$1" != "/usr/local/share/httpd"* ]]; then
|
||||||
fi
|
docroot="$1"
|
||||||
if [[ "$1" != "/usr/local/share/httpd"* ]]; then
|
elif [ -d "/usr/local/share/httpd" ]; then
|
||||||
find "$1" -type f -not -path '.git*' -iname '*.php' -exec sed -i 's|[<].*SERVER_ADDR.*[>]|'${CONTAINER_IP4_ADDRESS:-127.0.0.1}'|g' {} \; 2>/dev/null
|
docroot="/usr/local/share/httpd"
|
||||||
php -S 0.0.0.0:$PHP_DEV_SERVER_PORT -t "$1"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
[ -n "$docroot" ] || return 0
|
||||||
|
find "$docroot" -type f -not -path '.git*' -iname '*.php' \
|
||||||
|
-exec sed -i 's|[<].*SERVER_ADDR.*[>]|'"${CONTAINER_IP4_ADDRESS:-127.0.0.1}"'|g' {} \; 2>/dev/null
|
||||||
|
php -S "0.0.0.0:${PHP_DEV_SERVER_PORT}" -t "$docroot"
|
||||||
}
|
}
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
__check_service() {
|
__check_service() {
|
||||||
@@ -1484,7 +1504,7 @@ __switch_to_user() {
|
|||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# usage backup "days" "hours"
|
# usage backup "days" "hours"
|
||||||
__backup() {
|
__backup() {
|
||||||
local dirs="" backup_dir backup_name backup_exclude runTime cronTime maxDays
|
local dirs=() backup_dir backup_name backup_exclude runTime cronTime maxDays
|
||||||
if test -n "$1" && test -z "${1//[0-9]/}"; then
|
if test -n "$1" && test -z "${1//[0-9]/}"; then
|
||||||
maxDays="$1"
|
maxDays="$1"
|
||||||
shift 1
|
shift 1
|
||||||
@@ -1506,11 +1526,11 @@ __backup() {
|
|||||||
backup_dir="$BACKUP_DIR/$(date +'%y/%m')"
|
backup_dir="$BACKUP_DIR/$(date +'%y/%m')"
|
||||||
backup_name="$(date +'%d_%H-%M').tar.gz"
|
backup_name="$(date +'%d_%H-%M').tar.gz"
|
||||||
backup_exclude="/data/logs $BACKUP_DIR $BACK_EXCLUDE_DIR"
|
backup_exclude="/data/logs $BACKUP_DIR $BACK_EXCLUDE_DIR"
|
||||||
[ -d "/data" ] && dirs+="/data "
|
[ -d "/data" ] && dirs+=("/data")
|
||||||
[ -d "/config" ] && dirs+="/config "
|
[ -d "/config" ] && dirs+=("/config")
|
||||||
[ -d "$logDir" ] || mkdir -p "$logDir"
|
[ -d "$logDir" ] || mkdir -p "$logDir"
|
||||||
[ -d "$backup_dir" ] || mkdir -p "$backup_dir"
|
[ -d "$backup_dir" ] || mkdir -p "$backup_dir"
|
||||||
[ -z "$dirs" ] && echo "BACKUP_DIR is unset" >&2 && return 1
|
[ "${#dirs[@]}" -eq 0 ] && echo "BACKUP_DIR is unset" >&2 && return 1
|
||||||
[ -f "$pidFile" ] && echo "A backup job is already running" >&2 && return 1
|
[ -f "$pidFile" ] && echo "A backup job is already running" >&2 && return 1
|
||||||
echo "$$" >"$pidFile"
|
echo "$$" >"$pidFile"
|
||||||
trap "rm -f '$pidFile'" EXIT INT TERM
|
trap "rm -f '$pidFile'" EXIT INT TERM
|
||||||
@@ -1519,7 +1539,7 @@ __backup() {
|
|||||||
for excl in $backup_exclude; do
|
for excl in $backup_exclude; do
|
||||||
tar_excludes+=("--exclude=$excl")
|
tar_excludes+=("--exclude=$excl")
|
||||||
done
|
done
|
||||||
tar "${tar_excludes[@]}" -cfvz "$backup_dir/$backup_name" $dirs 2>/dev/stderr >>"$logDir/$CONTAINER_NAME" || exitCodeP=1
|
tar "${tar_excludes[@]}" -cfvz "$backup_dir/$backup_name" "${dirs[@]}" 2>/dev/stderr >>"$logDir/$CONTAINER_NAME" || exitCodeP=1
|
||||||
if [ $exitCodeP -eq 0 ]; then
|
if [ $exitCodeP -eq 0 ]; then
|
||||||
echo "Backup has completed and saved to: $backup_dir/$backup_name"
|
echo "Backup has completed and saved to: $backup_dir/$backup_name"
|
||||||
printf '%s\n\n' "Backup has completed on $(date)" >>"$logDir/$CONTAINER_NAME"
|
printf '%s\n\n' "Backup has completed on $(date)" >>"$logDir/$CONTAINER_NAME"
|
||||||
@@ -1536,7 +1556,11 @@ __backup() {
|
|||||||
else
|
else
|
||||||
return $exitStatus
|
return $exitStatus
|
||||||
fi
|
fi
|
||||||
sleep $runTime && __backup "$maxDays" "$cronTime"
|
# Loop instead of recurse — recursion adds a stack frame every interval
|
||||||
|
while true; do
|
||||||
|
sleep "$runTime"
|
||||||
|
__backup "$maxDays"
|
||||||
|
done
|
||||||
}
|
}
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# set variables from function calls
|
# set variables from function calls
|
||||||
|
|||||||
Reference in New Issue
Block a user