initial commit
This commit is contained in:
50
entrypoint.sh
Normal file
50
entrypoint.sh
Normal file
@ -0,0 +1,50 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
error() {
|
||||
echo "[ERROR] $1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [ -z "$GIT_REPO" ]; then
|
||||
error "GIT_REPO is not set."
|
||||
fi
|
||||
|
||||
# Install runtime packages if specified
|
||||
if [ -n "$PACKAGES" ]; then
|
||||
echo "[PKG] Installing additional APK packages: $PACKAGES"
|
||||
apk update >/dev/null
|
||||
apk add --no-cache $(echo "$PACKAGES" | tr ',' ' ')
|
||||
fi
|
||||
|
||||
# Extract Git host
|
||||
GIT_HOST=$(echo "$GIT_REPO" | awk -F/ '{print $3}')
|
||||
|
||||
# Configure .netrc
|
||||
if [ -n "$GIT_USERNAME" ] && [ -n "$GIT_TOKEN" ]; then
|
||||
echo "[AUTH] Configuring .netrc for Git authentication..."
|
||||
cat <<EOF > ~/.netrc
|
||||
machine $GIT_HOST
|
||||
login $GIT_USERNAME
|
||||
password $GIT_TOKEN
|
||||
EOF
|
||||
chmod 600 ~/.netrc
|
||||
|
||||
# Prevent Git from prompting and force it to use .netrc
|
||||
export GIT_ASKPASS=true
|
||||
export GIT_TERMINAL_PROMPT=0
|
||||
fi
|
||||
|
||||
# Clean previous checkout
|
||||
rm -rf /app/repo
|
||||
|
||||
echo "[CLONE] Cloning repository: $GIT_REPO"
|
||||
git clone "$GIT_REPO" repo
|
||||
|
||||
cd repo/"${APP_PATH:-.}"
|
||||
|
||||
echo "[BUILD] Building..."
|
||||
go build -o /app/app .
|
||||
|
||||
echo "[RUN] Starting application..."
|
||||
exec /app/app
|
Reference in New Issue
Block a user