Updated compose to build the docker image when required. Added env customisation options. Added update script
This commit is contained in:
29
.env.example
Normal file
29
.env.example
Normal file
@@ -0,0 +1,29 @@
|
||||
# This defines the way to get the moonlight docker image
|
||||
# By default moonlight will build the image locally. To pull
|
||||
# it from the registry, set the value to 'pull'
|
||||
MOONLIGHT_BUILD=build
|
||||
|
||||
# This defines the image name to use when building/pulling
|
||||
# the moonlight docker image
|
||||
MOONLIGHT_IMAGE=moonlightpanel/panel:2.1
|
||||
|
||||
# Specify where the fetch the moonlight source code when building
|
||||
# Uncomment this if you want to select a specific version of moonlight
|
||||
# Or you want to deploy a custom fork
|
||||
# MOONLIGHT_REPOSITORY=https://github.com/Moonlight-Panel/Moonlight
|
||||
# MOONLIGHT_BRANCH=v2_ChangeArchitecture
|
||||
|
||||
# Set this to the url moonlight is accessible through the internet
|
||||
MOONLIGHT_URL=http://localhost:9069
|
||||
|
||||
# This defines the port moonlight should run on
|
||||
MOONLIGHT_PORT=9069
|
||||
|
||||
# Here you can adjust where the moonlight instance will save
|
||||
# the application and database data
|
||||
MOONLIGHT_DATA=./data
|
||||
|
||||
# With the following settings you can adjust the database configuration
|
||||
MOONLIGHT_DATABASE_USER=moonlight
|
||||
MOONLIGHT_DATABASE_PASSWORD=s3cret
|
||||
MOONLIGHT_DATABASE_NAME=moonlight
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
**/.idea/**
|
||||
**/data/**
|
||||
**/data/**
|
||||
**/.env
|
||||
29
compose.yml
29
compose.yml
@@ -2,38 +2,41 @@ services:
|
||||
api-server:
|
||||
user: 0:0
|
||||
restart: always
|
||||
image: moonlightpanel/panel:custom
|
||||
image: ${MOONLIGHT_IMAGE}
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./Moonlight.ApiServer/Dockerfile
|
||||
dockerfile: ./Dockerfile
|
||||
args:
|
||||
- MOONLIGHT_REPO=${MOONLIGHT_REPOSITORY:-https://github.com/Moonlight-Panel/Moonlight}
|
||||
- MOONLIGHT_BRANCH=${MOONLIGHT_BRANCH:-v2_ChangeArchitecture}
|
||||
ports:
|
||||
- "9069:8080"
|
||||
- "${MOONLIGHT_PORT}:8080"
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
- MOONLIGHT_DATABASE_HOST=db
|
||||
- MOONLIGHT_DATABASE_PORT=5432
|
||||
- MOONLIGHT_DATABASE_USERNAME=moonlight
|
||||
- MOONLIGHT_DATABASE_PASSWORD=s3cret
|
||||
- MOONLIGHT_DATABASE_DATABASE=moonlight
|
||||
- MOONLIGHT_PUBLICURL=http://localhost:9069
|
||||
- MOONLIGHT_DATABASE_USERNAME=${MOONLIGHT_DATABASE_USER}
|
||||
- MOONLIGHT_DATABASE_PASSWORD=${MOONLIGHT_DATABASE_PASSWORD}
|
||||
- MOONLIGHT_DATABASE_DATABASE=${MOONLIGHT_DATABASE_NAME}
|
||||
- MOONLIGHT_PUBLICURL=${MOONLIGHT_URL}
|
||||
- MOONLIGHT_AUTHENTICATION_OAUTH2_ACCESSENDPOINT=http://localhost:8080/oauth2/handle # Use this when moonlight is using local oauth2 and a different port as the public url
|
||||
volumes:
|
||||
- ./data/moonlight:/app/storage
|
||||
- ${MOONLIGHT_DATA}/moonlight:/app/storage
|
||||
links:
|
||||
- db
|
||||
pull_policy: never
|
||||
pull_policy: build
|
||||
|
||||
db:
|
||||
image: postgres:latest
|
||||
restart: always
|
||||
environment:
|
||||
- POSTGRES_USER=moonlight
|
||||
- POSTGRES_DB=moonlight
|
||||
- POSTGRES_PASSWORD=s3cret
|
||||
- POSTGRES_USER=${MOONLIGHT_DATABASE_USER}
|
||||
- POSTGRES_DB=${MOONLIGHT_DATABASE_NAME}
|
||||
- POSTGRES_PASSWORD=${MOONLIGHT_DATABASE_PASSWORD}
|
||||
volumes:
|
||||
- ./data/database:/var/lib/postgresql/data
|
||||
- .${MOONLIGHT_DATA}/database:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready"]
|
||||
interval: 10s
|
||||
|
||||
48
update.sh
Executable file
48
update.sh
Executable file
@@ -0,0 +1,48 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
source .env
|
||||
|
||||
echo "[i] Updating your moonlight instance"
|
||||
|
||||
echo "[i] Checking for updates on deploy repo"
|
||||
|
||||
# Fetch remote updates
|
||||
git fetch
|
||||
|
||||
# Get current branch name
|
||||
branch=$(git rev-parse --abbrev-ref HEAD)
|
||||
|
||||
# Compare local and remote branch
|
||||
local_commit=$(git rev-parse "$branch")
|
||||
remote_commit=$(git rev-parse "origin/$branch")
|
||||
|
||||
if [ "$local_commit" != "$remote_commit" ]; then
|
||||
echo "[i] The deploy repository has updates. Fetching changes"
|
||||
git pull
|
||||
echo "[i] Updated deploy tools. Please rerun the update.sh"
|
||||
exit 0
|
||||
else
|
||||
echo "[i] No update of the deploy repository available"
|
||||
fi
|
||||
|
||||
if [ "$MOONLIGHT_BUILD" == "build" ]; then
|
||||
echo "[i] Rebuilding the docker image"
|
||||
docker compose build
|
||||
echo "[i] Rebuild done"
|
||||
fi
|
||||
|
||||
if [ "$MOONLIGHT_BUILD" == "pull" ]; then
|
||||
echo "[i] Pulling the latest docker image"
|
||||
docker compose build
|
||||
echo "[i] Pulling completed"
|
||||
fi
|
||||
|
||||
echo "[i] Stopping containers"
|
||||
docker compose down
|
||||
|
||||
echo "[i] Starting containers"
|
||||
docker compose up -d
|
||||
|
||||
echo "[i] Update done :>"
|
||||
Reference in New Issue
Block a user