Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions .devcontainer/dev.docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
services:
nginx:
environment:
- NODE_HOST=dev
NODE_HOST: dev
dev:
user: devu
env_file:
Expand All @@ -16,13 +16,20 @@ services:
WORK_DIR: /workspace
BIN_DEPLOY_PREP: ${BIN_DEPLOY_PREP}
BIN_DEPLOY_REQ: ${BIN_DEPLOY_REQ}
SSH_AUTH_SOCK: /ssh-agent
BUN_BIN: ${BUN_BIN_R}
SSH_AUTH_SOCK: /ssh-agent
volumes:
- ${SSH_AUTH_SOCK:-/dev/null}:/ssh-agent
- .:/workspace
- ~/.config/git/config:/etc/gitconfig
- ~/.gitconfig:/etc/gitconfig:ro
networks:
- templrjs
- ollama
expose:
- '${NODE_PORT}'

networks:
ollama:
name: ollama
driver: bridge
13 changes: 2 additions & 11 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,14 @@
"customizations": {
"vscode": {
"extensions": [
"formulahendry.code-runner",
"Continue.continue",
"streetsidesoftware.code-spell-checker",
"kamikillerto.vscode-colorize",
"ms-azuretools.vscode-docker",
"donjayamanne.githistory",
"eamodio.gitlens",
"oderwat.indent-rainbow",
"yzhang.markdown-all-in-one",
"christian-kohler.path-intellisense",
"foxundermoon.shell-format",
"ms-vscode.test-adapter-converter",
"hbenl.vscode-test-explorer",
"Gruntfuggly.todo-tree",
"uctakeoff.vscode-counter",
"aaron-bond.better-comments",
"tamasfe.even-better-toml",
"wix.vscode-import-cost",
"Vue.volar"
]
}
Expand All @@ -29,7 +20,7 @@
"runServices": ["nginx"],
"service": "dev",
"shutdownAction": "stopCompose",
"updateRemoteUserUID": true,
"remoteUser": "devu",
"updateRemoteUserUID": true,
"workspaceFolder": "/workspace"
}
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ BIN_RUN_ENV_LINT=bin/lint/lint_env.sh
BIN_NGINX_ENTRY=bin/nginx/entry.sh

NODE_VER=22
BUN_VER=v1.2.22
BUN_VER=v1.3.1

BUN_DIR_R=.bun
BUN_BIN_R=.bun/bin
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ jobs:
sudo mkdir -p $HOME
sudo mkdir -p $HOME/.local/bin
sudo chown runner -R $HOME
sudo apt install -y curl git-lfs
sudo apt install -y curl git-lfs wget tar
scversion="stable"
wget -qO- "https://github.com/koalaman/shellcheck/releases/download/${scversion?}/shellcheck-${scversion?}.linux.x86_64.tar.xz" | tar -xJv
cp "shellcheck-${scversion}/shellcheck" $HOME/.local/bin/
shellcheck --version
- name: lint and test
run: |
export CONTAINER="container"
Expand Down
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/sh
eval make runPreCommit
eval make runChecksNew
11 changes: 6 additions & 5 deletions .husky/prepare-commit-msg
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/sh
CUR_DIR="$(dirname "$(realpath "$0")")"
eval make dev
. "$CUR_DIR/../.env"
exec </dev/tty && PATH=$PATH:$HOME/$BUN_BIN_R bun x cz --hook || true
#!/bin/bash
COMMIT_MSG_FILE="$1"

if [[ "$2" == "" ]]; then
exec </dev/tty && make COMMIT_MSG_FILE="$COMMIT_MSG_FILE" runMessage
fi
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARG NODE_VER="22"

FROM docker.io/rockylinux:9 AS appbuilder
FROM docker.io/almalinux:9 AS appbuilder

ARG BIN_DEPLOY
ARG CONTAINER="container"
Expand All @@ -12,10 +12,10 @@ WORKDIR /tmp/app
RUN dnf install -y bash
RUN bash "./${BIN_DEPLOY}"

FROM docker.io/rockylinux:9 AS release
FROM docker.io/almalinux:9 AS release

ARG USERNAME=runner
ARG USER_UID=1000
ARG USER_UID=1001
ARG USER_GID=${USER_UID}
ARG HOME_MAIN="/home/${USERNAME}"

Expand All @@ -31,6 +31,7 @@ RUN mkdir -p ${HOME_MAIN} \
ARG DOCKER_ENV_DIR
ARG BUN_VER
ARG BIN_DEPLOY_REQ_SERVER
ARG NODE_VER

COPY ./${BIN_DEPLOY_REQ_SERVER} /install.sh
RUN bash /install.sh && rm /install.sh
Expand Down
70 changes: 60 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@ else
$(error Error: Makefile disabled, exiting ...)
endif

SHELL := /bin/bash
ROOT_MAKEFILE:=$(abspath $(patsubst %/, %, $(dir $(abspath $(lastword $(MAKEFILE_LIST))))))

include $(ROOT_MAKEFILE)/.env
include $(PRES_ENV)

export

BUN_DIR=$(HOME)/$(BUN_DIR_R)
BUN_BIN=$(HOME)/$(BUN_BIN_R)
BUN=$(BUN_BIN)/bun
BUN=$(BUN_BIN)/bun --bun

export PATH:=$(PATH):$(BUN_BIN)
OLLAMA_MODEL?=gpt-oss:20b

dev: NODE_ENV = development
dev: setupGit setupBun postInstall
Expand All @@ -42,16 +43,13 @@ cleanBuild:

clean: cleanBuild
rm -rf $(ROOT_MAKEFILE)/node_modules
rm -rf $(ROOT_MAKEFILE)/$(PRES_PKG)/node_modules
rm -rf $(ROOT_MAKEFILE)/$(CACHE_DIR)

uninstall: clean
[ -f "$(BUN)" ] && $(BUN) pm cache rm || echo "not installed"
rm -rf $(BUN_DIR)

runAct:
echo "starting environment"
bash

createBuild: NODE_ENV = production
createBuild: cleanBuild
$(BUN) run build || (echo "FAILED"; exit 1)
Expand All @@ -64,8 +62,8 @@ runChecks: dev
$(BUN) run lint:shell
$(BUN) run lint:format

runPreCommit: NODE_ENV = development
runPreCommit: createBuild
runChecksNew: NODE_ENV = development
runChecksNew: dev
$(BUN) run lint

runBuild: build createBuild
Expand All @@ -81,7 +79,59 @@ runDev: dev
runUpdate: %: export_% dev

export_runUpdate: NODE_ENV = development
export_runUpdate: clean
export_runUpdate:
echo "UPDATE NODE -> $(NODE_ENV)"
rm -f $(ROOT_MAKEFILE)/*.lock
rm -rf bun.lock
$(BUN) install --lockfile-only --exact --no-cache
$(BUN) update
$(BUN) pm cache rm
$(MAKE) clean

PROMPT=Generate a commit message in the Conventional Commits 1.0.0 format based on the following git diff. The commit message must: \n\
- Follow this structure: \n\
1. Commit type (e.g., feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert) \n\
2. Optional scope in parentheses (e.g., feat(auth):) \n\
3. A brief, lowercase description in present tense on the first line \n\
4. Optional body with detailed explanation (can use uppercase) \n\
5. Optional footer(s) with breaking changes, issue references (e.g., Closes \#123), or co-authors (e.g., Co-authored-by: Name) \n\
- Formatting rules: \n\
1. The first line must be entirely lowercase \n\
2. Body and footer may use uppercase letters \n\
3. Follow Conventional Commits 1.0.0 strictly \n\
4. Return only the commit message as plain text (no extra formatting, no markdown) \n\
5. Do NOT mention - no breaking changes \n\
6. Body lines must not be longer than 100 characters \n\
- Example: \n\
feat(auth): add user login API\n\
\n\
Added support for user login via OAuth2. This allows users to authenticate\n\
using their Google account.\n\
\n\
Closes \#42\n\

message:
@if [ -z "$(COMMIT_MSG_FILE)" ]; then \
echo "Error: COMMIT_MSG_FILE is not set"; \
exit 1; \
fi
git diff --staged -- . ':(exclude)*bun.lock' | \
jq -Rs --arg prompt "$(PROMPT)" '{"stream": false, "model": "$(OLLAMA_MODEL)", "prompt": (" <GIT_DIFF> " + . + " </GIT_DIFF> " + $$prompt)}' | \
curl -s -X POST http://ollama:11434/api/generate \
-H "Content-Type: application/json" \
-d @- | \
jq -r 'select(.done == true) | .response' > $(COMMIT_MSG_FILE)
vim $(COMMIT_MSG_FILE)
sed -i 's/^[ \t]*//; s/[ \t]*$$//' $(COMMIT_MSG_FILE)
@if [ -s $(COMMIT_MSG_FILE) ]; then \
$(BUN) run commitlint -e $(COMMIT_MSG_FILE); \
else \
echo "$(COMMIT_MSG_FILE) is empty, aborting."; \
exit 1; \
fi

runMessage: dev
@if curl -sf http://ollama:11434; then \
$(MAKE) message; \
else \
$(BUN) run cz --hook; \
fi
2 changes: 1 addition & 1 deletion bin/deploy/entry_web.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cd "/var/www/$APP_PRES_ROOT" || exit 1

for cnt in $(seq 0 $((PM2_WORKER - 1))); do
NODE_ENV=production PORT="$((NODE_PORT + cnt))" \
pm2 start --interpreter bun serve --directory "$APP_PRES_PUB_ROOT" -n "server-$cnt"
pm2 start --interpreter bun serve --directory "$APP_PRES_PUB_ROOT" -n "server-$cnt" -- --bun
done

pm2 logs
43 changes: 33 additions & 10 deletions bin/deploy/req.server.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,42 @@
#!/bin/sh
#!/bin/bash

echo "installing ps"
apk add --no-cache procps-ng curl bash
echo "installing bun -> /opt/bun"
apk add --no-cache unzip
echo "Installing ps (procps), curl, bash..."
dnf install -y procps-ng curl bash --allowerasing

echo "Installing unzip..."
dnf install -y unzip

echo "Installing pm2 (requires build tools)..."
dnf groupinstall -y "Development Tools"
dnf install -y gcc-c++ make python3

# Install Node.js & npm if not already present
if ! command -v node &> /dev/null; then
# Reset and enable the desired module stream
dnf module reset -y nodejs
fi

echo "Installing Node.js v$NODE_VER..."
dnf module enable -y nodejs:"$NODE_VER"
# Install Node.js and npm
dnf install -y nodejs npm

# Install pm2 and node-gyp
npm i -g npm node-gyp pm2

# Install Bun (requires $BUN_VER to be set)
if [ ! -d "/opt/bun" ]; then
echo "Installing Bun in /opt/bun..."
curl -fsSl https://bun.sh/install | bash -s "bun-$BUN_VER"
mv "$HOME/.bun" /opt/bun
chmod -R 755 /opt/bun
ln -s /opt/bun/bin/bun /usr/bin/bun
fi
echo "installing pm2"
apk add --no-cache build-base make
npm i -g npm
npm i -g pm2

apk del unzip build-base make curl bash
# Install OpenSSL (for nuxt-auth-utils or others)
dnf install -y openssl

# Optional cleanup to reduce image size (comment this out if tools are still needed)
echo "Cleaning up..."
dnf remove -y unzip gcc-c++ make
dnf autoremove -y
10 changes: 6 additions & 4 deletions bin/deploy/req.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ source "$ROOT/.env"
echo "update"
dnf -y update
echo "installing requirements"
dnf -y install zlib gzip vim git git-lfs make gcc-c++ findutils wget unzip
dnf -y install zlib gzip vim git git-lfs make gcc-c++ findutils wget unzip jq
echo "requirements installed"
echo "installing nodejs"
dnf -y module enable nodejs:"$NODE_VER"
dnf -y install nodejs
# for bun
dnf -y install nodejs npm
echo "installing other dependencies"
# for bun
npm install -g node-gyp
echo "nodejs installed"
# for shellcheck
dnf -y install ShellCheck
6 changes: 3 additions & 3 deletions bin/lint/lint_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ROOT="$(dirname "$(realpath "$0")")/../.."
ROOT_ENV="$ROOT/.env"
ENV_FILES=("$ROOT_ENV" "$PRES_ENV")

ALL_ENV=("MAKEFILE_LIST" "HOME" "PATH" "APP_PRES_SHADOW")
ALL_ENV=("MAKEFILE_LIST" "HOME" "PATH" "APP_PRES_SHADOW" "COMMIT_MSG_FILE" "MAKE")

check_env_uniqueness() {
cmd="$(awk 'match($0, /^.*=/) {print substr($0, RSTART, RLENGTH-1)}' "$1")"
Expand Down Expand Up @@ -51,13 +51,13 @@ check_name_occurrence() {
if [[ "$(grep -Rnw "$ROOT/.devcontainer" -e "$docker_reg" | wc -l)" -gt 0 ]]; then
return 0
fi
if [[ "$(grep --exclude-dir=src -Rnw "$PKGS" -e "$norm_reg" | wc -l)" -gt 0 ]]; then
if [[ "$(grep --exclude-dir={src,bin,node_modules} -Rnw "$PKGS" -e "$norm_reg" | wc -l)" -gt 0 ]]; then
return 0
fi
if [[ "$2" = 1 ]]; then
return 1
fi
if [[ "$(grep --exclude-dir=src --exclude-dir=bin -Rnw "$PKGS" -e "$1" | wc -l)" -gt 0 ]]; then
if [[ "$(grep --exclude-dir={src,bin,node_modules} -Rnw "$PKGS" -e "$1" | wc -l)" -gt 0 ]]; then
return 0
fi
return 1
Expand Down
11 changes: 11 additions & 0 deletions bin/lint/wrap_bash.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
set -e

ROOT=$(dirname "$(realpath "$0")")
source "$ROOT/../../.env"

CMD="$1"
shift

FULL_CMD="$CMD $*"
eval "$FULL_CMD"
Loading