🦈🏠🐜 Initial Commit 🐜🦈🏠

This commit is contained in:
casjay 2022-10-12 16:07:07 -04:00
commit 7b37b18ae4
No known key found for this signature in database
GPG Key ID: 4F765975C1F0EE5F
9 changed files with 405 additions and 0 deletions

4
.dockerignore Normal file
View File

@ -0,0 +1,4 @@
# Files to ignore
.gitkeep
.gitignore
.node_modules/**

93
.gitignore vendored Normal file
View File

@ -0,0 +1,93 @@
# gitignore created on 10/12/22 at 16:07
# Disable reminder in prompt
ignoredirmessage
# OS generated files
### Linux ###
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### macOS Patch ###
# iCloud generated files
*.icloud
### Windows ###
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
# Other
**/.installed
# ignore commit message
**/.gitcommit
#ignore .failed
**/.build_failed
# ignore .bak files
**/*.bak
# ignore .no_push files
**/.no_push
# ignore .no_git files
**/.no_git

72
Dockerfile Normal file
View File

@ -0,0 +1,72 @@
FROM casjaysdevdocker/alpine:latest AS build
ARG alpine_version="v3.16"
ARG TIMEZONE="America/New_York" \
IMAGE_NAME="bun" \
LICENSE="MIT" \
PORTS=""
ENV TZ="$TIMEZONE" \
SHELL="/bin/bash" \
TERM="xterm-256color" \
HOSTNAME="${HOSTNAME:-casjaysdev-$IMAGE_NAME}" \
BUN_INSTALL="/usr/local/share/bun"
RUN set -ex; \
rm -Rf "/etc/apk/repositories"; \
echo "http://dl-cdn.alpinelinux.org/alpine/$alpine_version/main" >> "/etc/apk/repositories"; \
echo "http://dl-cdn.alpinelinux.org/alpine/$alpine_version/community" >> "/etc/apk/repositories"; \
if [ "$alpine_version" = "edge" ]; then echo "http://dl-cdn.alpinelinux.org/alpine/$alpine_version/testing" >> "/etc/apk/repositories" ; fi ; \
apk update --update-cache && \
curl -fsSL https://bun.sh/install | bash && \
ln -sf /usr/local/share/bun/bun /usr/local/bin
COPY ./bin/. /usr/local/bin/
COPY ./data/. /usr/local/share/template-files/data/
COPY ./config/. /usr/local/share/template-files/config/
RUN rm -Rf /bin/.gitkeep /config /data /var/cache/apk/*
FROM scratch
ARG BUILD_DATE="2022-10-12" \
BUILD_VERSION="latest" \
BUN_INSTALL="/usr/local/share/bun"
LABEL maintainer="CasjaysDev <docker-admin@casjaysdev.com>" \
org.opencontainers.image.vcs-type="Git" \
org.opencontainers.image.name="bun" \
org.opencontainers.image.base.name="bun" \
org.opencontainers.image.license="$LICENSE" \
org.opencontainers.image.vcs-ref="$BUILD_VERSION" \
org.opencontainers.image.build-date="$BUILD_DATE" \
org.opencontainers.image.version="$BUILD_VERSION" \
org.opencontainers.image.schema-version="$BUILD_VERSION" \
org.opencontainers.image.url="https://hub.docker.com/r/casjaysdevdocker/bun" \
org.opencontainers.image.vcs-url="https://github.com/casjaysdevdocker/bun" \
org.opencontainers.image.url.source="https://github.com/casjaysdevdocker/bun" \
org.opencontainers.image.documentation="https://hub.docker.com/r/casjaysdevdocker/bun" \
org.opencontainers.image.vendor="CasjaysDev" \
org.opencontainers.image.authors="CasjaysDev" \
org.opencontainers.image.description="Containerized version of bun"
ENV SHELL="/bin/bash" \
TERM="xterm-256color" \
HOSTNAME="casjaysdev-bun" \
TZ="${TZ:-America/New_York}" \
TIMEZONE="$$TIMEZONE" \
PHP_SERVER="none" \
PORT=""
COPY --from=build /. /
WORKDIR /root
VOLUME [ "/config","/data" ]
EXPOSE $PORTS
ENTRYPOINT [ "tini", "-p", "SIGTERM", "--" ]
CMD [ "/usr/local/bin/entrypoint-bun.sh" ]
HEALTHCHECK --start-period=1m --interval=2m --timeout=3s CMD [ "/usr/local/bin/entrypoint-bun.sh", "healthcheck" ]

13
LICENSE.md Normal file
View File

@ -0,0 +1,13 @@
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2022 casjay <git-admin@casjaysdev.com>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
1. You just DO WHAT THE FUCK YOU WANT TO.

36
README.md Normal file
View File

@ -0,0 +1,36 @@
## 👋 Welcome to bun 🚀
bun README
## Install my system scripts
```shell
sudo bash -c "$(curl -q -LSsf "https://github.com/systemmgr/installer/raw/main/install.sh")"
sudo systemmgr --config && sudo systemmgr install scripts
```
## Get source files
```shell
dockermgr download src bun
```
OR
```shell
git clone "https://github.com/casjaysdevdocker/bun" "$HOME/Projects/github/casjaysdevdocker/bun"
```
## Build container
```shell
cd "$HOME/Projects/github/casjaysdevdocker/bun"
buildx
```
## Authors
🤖 casjay: [Github](https://github.com/casjay) [Docker](https://hub.docker.com/r/casjay) 🤖
📽 dockermgr: [Github](https://github.com/dockermgr) [Docker](https://hub.docker.com/r/dockermgr) 📽
⛵ CasjaysDev Docker: [Github](https://github.com/casjaysdevdocker) [Docker](https://hub.docker.com/r/casjaysdevdocker) ⛵

0
bin/.gitkeep Normal file
View File

187
bin/entrypoint-bun.sh Executable file
View File

@ -0,0 +1,187 @@
#!/usr/bin/env bash
# shellcheck shell=bash
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
##@Version : 202210121546-git
# @@Author : Jason Hempstead
# @@Contact : jason@casjaysdev.com
# @@License : WTFPL
# @@ReadME : entrypoint-bun.sh --help
# @@Copyright : Copyright: (c) 2022 Jason Hempstead, Casjays Developments
# @@Created : Wednesday, Oct 12, 2022 15:46 EDT
# @@File : entrypoint-bun.sh
# @@Description :
# @@Changelog : New script
# @@TODO : Better documentation
# @@Other :
# @@Resource :
# @@Terminal App : no
# @@sudo/root : no
# @@Template : other/docker-entrypoint
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Set bash options
[ -n "$DEBUG" ] && set -x
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
APPNAME="$(basename "$0" 2>/dev/null)"
VERSION="202210121546-git"
HOME="${USER_HOME:-$HOME}"
USER="${SUDO_USER:-$USER}"
RUN_USER="${SUDO_USER:-$USER}"
SCRIPT_SRC_DIR="${BASH_SOURCE%/*}"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Set functions
__find() { ls -A "$*" 2>/dev/null || return 10; }
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
__exec_command() {
local cmd="${*:-/bin/bash -l}"
local exitCode=0
echo "Executing command: $cmd"
eval "$cmd" || exitCode=10
[ "$exitCode" = 0 ] || exitCode=10
return ${exitCode:-$?}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Functions
__heath_check() {
local status=0
#curl -q -LSsf -o /dev/null -s -w "200" "http://localhost/server-health" || status=$(($status + 1))
echo "$(uname -s) $(uname -m) is running"
return ${status:-$?}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Define default variables - don not change these
export TZ="${TZ:-America/New_York}"
export LOCAL_BIN_DIR="${LOCAL_BIN_DIR:-/usr/local/bin}"
export HOSTNAME="${HOSTNAME:-casjaysdev-bin}"
export SSL="${SSL:-false}"
export SSL_DIR="${SSL_DIR:-/config/ssl}"
export SSL_CA="${SSL_CA:-$SSL_DIR/ca.crt}"
export SSL_KEY="${SSL_KEY:-$SSL_DIR/server.key}"
export SSL_CERT="${SSL_CERT:-$SSL_DIR/server.crt}"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Additional variables and variable overrides
export HTTP_PORT="${HTTP_PORT:-80}"
export HTTPS_PORT="${HTTPS_PORT:-443}"
export SERVICE_PORT="${SERVICE_PORT:-}"
export DEFAULT_CONF_DIR="${DEFAULT_CONF_DIR:-/usr/local/share/template-files/config/defaults}"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# import variables from file
[ -f "/root/env.sh" ] && . "/root/env.sh"
[ -f "/config/env.sh" ] && "/config/env.sh"
[ -f "/config/.env.sh" ] && . "/config/.env.sh"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Set timezone
[ -n "${TZ}" ] && echo "${TZ}" >"/etc/timezone"
[ -f "/usr/share/zoneinfo/${TZ}" ] && ln -sf "/usr/share/zoneinfo/${TZ}" "/etc/localtime"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Set hostname
if [ -n "${HOSTNAME}" ]; then
echo "${HOSTNAME}" >"/etc/hostname"
echo "127.0.0.1 ${HOSTNAME} localhost ${HOSTNAME}.local" >"/etc/hosts"
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Delete any gitkeep files
[ -d "/data" ] && rm -Rf "/data/.gitkeep" "/data"/*/*.gitkeep
[ -d "/config" ] && rm -Rf "/config/.gitkeep" "/data"/*/*.gitkeep
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Setup bin directory
if [ -d "/config/bin" ]; then
for bin in /config/bin/*; do
name="$(basename "$bin")"
ln -sf "$bin" "/usr/local/bin/$name"
done
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Create directories
[ -d "/etc/ssl" ] || mkdir -p "/etc/ssl"
[ -d "/usr/local/bin" ] && rm -Rf "/usr/local/bin/.gitkeep"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if [ "$SSL" = "true" ] || [ "$SSL" = "yes" ]; then
if [ -f "/config/ssl/server.crt" ] && [ -f "/config/ssl/server.key" ]; then
export SSL="true"
if [ -n "$SSL_CA" ] && [ -f "$SSL_CA" ]; then
mkdir -p "/etc/ssl/certs"
cat "$SSL_CA" >>"/etc/ssl/certs/ca-certificates.crt"
fi
else
[ -d "$SSL_DIR" ] || mkdir -p "$SSL_DIR"
create-ssl-cert
fi
type update-ca-certificates &>/dev/null && update-ca-certificates
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[ -f "$SSL_CA" ] && cp -Rfv "$SSL_CA" "/etc/ssl/ca.crt"
[ -f "$SSL_KEY" ] && cp -Rfv "$SSL_KEY" "/etc/ssl/server.key"
[ -f "$SSL_CERT" ] && cp -Rfv "$SSL_CERT" "/etc/ssl/server.crt"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Create default config
if [ ! -e "/config/$APPNAME" ] && [ -e "$DEFAULT_CONF_DIR/$APPNAME" ]; then
cp -Rf "$DEFAULT_CONF_DIR/$APPNAME" "/config/$APPNAME"
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Create config symlinks
for conf in /config/*; do
if [ -e "/etc/$conf" ]; then
if [ ! -d "/config/bin" ]; then
rm -Rf "/etc/${conf:?}"
ln -sf "/config/$conf" "/etc/$conf"
fi
fi
done
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Setup bun
mkdir -p "/app" && cd "/app" || exit 10
if [ -z "$1" ] && [ -z "$(ls -A "/app"/* 2>/dev/null)" ]; then
mkdir -p "/app" && cd "/app"
bun upgrade && bun init
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Additional commands
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
case "$1" in
--help) # Help message
echo 'Docker container for '$APPNAME''
echo "Usage: $APPNAME [healthcheck, bash, command]"
echo "Failed command will have exit code 10"
echo ""
exit ${exitCode:-$?}
;;
healthcheck) # Docker healthcheck
__heath_check || exitCode=10
exit ${exitCode:-$?}
;;
*/bin/sh | */bin/bash | bash | shell | sh) # Launch shell
shift 1
__exec_command "${@:-/bin/bash}"
exit ${exitCode:-$?}
;;
bun)
shift 1
bun "$@"
;;
*) # Execute primary command
if [ $# -eq 0 ]; then
if [ -f "index.ts" ]; then
RUN_SCRIPT="index.ts"
elif [ -f "app.ts" ]; then
RUN_SCRIPT="app.ts"
elif [ -f "server.ts" ]; then
RUN_SCRIPT="server.ts"
fi
bun install
bun dev $RUN_SCRIPT
exit ${exitCode:-$?}
else
__exec_command "$@"
exitCode=$?
fi
;;
esac
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# end of entrypoint
exit ${exitCode:-$?}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

0
config/.gitkeep Normal file
View File

0
data/.gitkeep Normal file
View File