feat/docker-compose-update (#18)
Co-authored-by: jon brookes <marshyon@gmail.com> Reviewed-on: https://codeberg.org/headshed/share-lt/pulls/18
This commit is contained in:
parent
fd43495e2d
commit
1a22fd156d
70 changed files with 1068 additions and 745 deletions
|
|
@ -1,11 +1,10 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
LARAVEL_CONTAINER_NAME="quay.io/marshyon/share-lt"
|
||||
CONTAINER_LABEL="0.0.3"
|
||||
CONTAINER_LABEL="v0.0.5"
|
||||
CACHE="--no-cache"
|
||||
CACHE=""
|
||||
# CACHE=""
|
||||
|
||||
docker build \
|
||||
$CACHE \
|
||||
-t ${LARAVEL_CONTAINER_NAME}:${CONTAINER_LABEL} \
|
||||
-f Dockerfile.phpfpm .
|
||||
-t ${LARAVEL_CONTAINER_NAME}:${CONTAINER_LABEL} .
|
||||
|
|
|
|||
|
|
@ -6,8 +6,7 @@
|
|||
# tokens need to be created with tinker or similar method
|
||||
|
||||
|
||||
URL='http://127.0.0.1:8000/api/entries'
|
||||
|
||||
URL="${ADDRESS:-http://127.0.0.1:8000/api/entries}"
|
||||
curl -s -X GET \
|
||||
-H "Authorization: Bearer $TOKEN" \
|
||||
-H "Accept: application/json" \
|
||||
|
|
|
|||
|
|
@ -5,8 +5,7 @@
|
|||
# granted access to view entries by being given
|
||||
# a token
|
||||
|
||||
URL='http://127.0.0.1:8000/api/entries'
|
||||
|
||||
URL="${ADDRESS:-http://127.0.0.1:8000/api/entries}"
|
||||
curl -s -X GET \
|
||||
-H "Accept: application/json" \
|
||||
$URL
|
||||
|
|
|
|||
|
|
@ -1,36 +1,37 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
# run_as_www() {
|
||||
# # prefer su-exec (alpine), fallback to runuser if available, otherwise run directly
|
||||
# if command -v su-exec >/dev/null 2>&1; then
|
||||
# su-exec www "$@"
|
||||
# elif command -v runuser >/dev/null 2>&1; then
|
||||
# runuser -u www -- "$@"
|
||||
# else
|
||||
# "$@"
|
||||
# fi
|
||||
# }
|
||||
# Ensure APP_KEY is set and persisted
|
||||
PERSISTED_KEY="/var/www/storage/.app_key"
|
||||
|
||||
# Build front-end assets if Vite manifest is missing
|
||||
if [ ! -f /var/www/public/build/manifest.json ]; then
|
||||
echo "Building front-end assets (vite)..."
|
||||
run_as_www npm ci
|
||||
run_as_www npm run build
|
||||
if [ -z "$APP_KEY" ]; then
|
||||
if [ -f "$PERSISTED_KEY" ]; then
|
||||
echo "Using persisted APP_KEY from: $PERSISTED_KEY"
|
||||
export APP_KEY=$(cat "$PERSISTED_KEY")
|
||||
else
|
||||
# Generate key, strip "base64:", and save
|
||||
NEW_KEY=$(php artisan key:generate --show --no-interaction)
|
||||
echo "Generated new APP_KEY to: $PERSISTED_KEY"
|
||||
echo "$NEW_KEY" > "$PERSISTED_KEY"
|
||||
export APP_KEY="$NEW_KEY"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Wait for database directory to be mounted
|
||||
# if [ ! -f /var/www/database/database.sqlite ]; then
|
||||
# echo "Creating database..."
|
||||
# # create the sqlite file as the www user so ownership matches app files
|
||||
# run_as_www sh -c 'touch /var/www/database/database.sqlite'
|
||||
# run_as_www php artisan migrate --force
|
||||
# fi
|
||||
# check to see if /var/www/database/database.sqlite exists
|
||||
# if not, run migrations
|
||||
if [ ! -f /var/www/database/database.sqlite ]; then
|
||||
php artisan migrate --force
|
||||
fi
|
||||
|
||||
# Fix storage permissions
|
||||
# echo "Fixing storage permissions..."
|
||||
# chown -R www:www /var/www/storage /var/www/bootstrap/cache
|
||||
# chmod -R 775 /var/www/storage /var/www/bootstrap/cache
|
||||
# check to see if /var/www/public/storage exists
|
||||
# if not, run storage:link
|
||||
if [ ! -d /var/www/public/storage ]; then
|
||||
php artisan storage:link
|
||||
fi
|
||||
|
||||
# Execute the main command
|
||||
php artisan config:clear
|
||||
|
||||
|
||||
# Start supervisord directly
|
||||
exec "$@"
|
||||
|
||||
|
|
|
|||
33
cmd/handle_cms_updates.sh
Executable file
33
cmd/handle_cms_updates.sh
Executable file
|
|
@ -0,0 +1,33 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
LOG_FILE="/tmp/logfile.log"
|
||||
|
||||
# Redirect all output to both stdout and the log file
|
||||
exec > >(tee -a "$LOG_FILE") 2>&1
|
||||
|
||||
# Read the first two command line arguments
|
||||
ACTION=$1
|
||||
FILENAME=$2
|
||||
|
||||
# Check if the file exists and echo its contents
|
||||
if [[ -f "$FILENAME" ]]; then
|
||||
echo "Contents of the file $FILENAME:"
|
||||
cat "$FILENAME" | jq
|
||||
else
|
||||
echo "Error: File $FILENAME does not exist."
|
||||
fi
|
||||
|
||||
echo
|
||||
# Read and print command line arguments
|
||||
echo "=============================="
|
||||
echo "ACTION: $ACTION"
|
||||
echo "FILENAME: $FILENAME"
|
||||
echo "=============================="
|
||||
echo
|
||||
|
||||
# Publish message and check return code
|
||||
if nats pub $NATS_SUBJECT "$(cat "$FILENAME")" --server $NATS_URL --user $NATS_USERNAME --password $NATS_PASSWORD; then
|
||||
echo "Success: Message published to NATS successfully."
|
||||
else
|
||||
echo "Error: Failed to publish message to NATS."
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue