mirror of
https://github.com/gilbN/theme.park.git
synced 2024-11-20 01:52:32 +01:00
deploy: 478143dccf
This commit is contained in:
parent
217f7153d0
commit
4848e6cb56
28
.github/workflows/docker-build.yml
vendored
28
.github/workflows/docker-build.yml
vendored
@ -2,7 +2,10 @@ name: docker build
|
||||
on:
|
||||
release:
|
||||
types:
|
||||
- published
|
||||
- released
|
||||
push:
|
||||
branches:
|
||||
- develop
|
||||
jobs:
|
||||
push_to_ghcr_io:
|
||||
runs-on: ubuntu-latest
|
||||
@ -11,7 +14,6 @@ jobs:
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
ref: ${{ github.event.release.target_commitish }}
|
||||
- name: Get the version
|
||||
id: get_version
|
||||
run: echo ::set-output name=VERSION::${{ github.event.release.tag_name }}
|
||||
@ -24,15 +26,15 @@ jobs:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.GH_PAT }}
|
||||
- name: build&push live
|
||||
- name: build&push master
|
||||
if: ${{ github.event.release.target_commitish == 'live' }}
|
||||
run: |
|
||||
docker build docker/ --build-arg TP_RELEASE=${{ steps.get_version.outputs.VERSION }} --build-arg BUILD_DATE=${{ steps.date_time.outputs.NOW }} --tag ghcr.io/gilbn/theme.park --tag ghcr.io/gilbn/theme.park:${{ steps.get_version.outputs.VERSION }}
|
||||
docker build --build-arg TP_RELEASE=${{ steps.get_version.outputs.VERSION }} --build-arg BUILD_DATE=${{ steps.date_time.outputs.NOW }} --tag ghcr.io/gilbn/theme.park --tag ghcr.io/gilbn/theme.park:${{ steps.get_version.outputs.VERSION }}
|
||||
docker push ghcr.io/gilbn/theme.park
|
||||
- name: build&push dev
|
||||
if: ${{ github.event.release.target_commitish == 'live_develop' }}
|
||||
- name: build&push develop
|
||||
if: ${{ github.ref == 'refs/heads/develop' }}
|
||||
run: |
|
||||
docker build docker/ --build-arg TP_RELEASE=${{ steps.get_version.outputs.VERSION }} --build-arg BUILD_DATE=${{ steps.date_time.outputs.NOW }} --tag ghcr.io/gilbn/theme.park:develop --tag ghcr.io/gilbn/theme.park:${{ steps.get_version.outputs.VERSION }}
|
||||
docker build --build-arg TP_RELEASE=${{ steps.get_version.outputs.VERSION }} --build-arg BUILD_DATE=${{ steps.date_time.outputs.NOW }} --tag ghcr.io/gilbn/theme.park:develop }}
|
||||
docker push --all-tags ghcr.io/gilbn/theme.park
|
||||
push_to_dockerhub:
|
||||
runs-on: ubuntu-latest
|
||||
@ -52,14 +54,14 @@ jobs:
|
||||
with:
|
||||
username: ${{ secrets.DH_USER }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- name: build&push dh live
|
||||
- name: build&push dh master
|
||||
if: ${{ github.event.release.target_commitish == 'live' }}
|
||||
run: |
|
||||
docker build docker/ --build-arg TP_RELEASE=${{ steps.get_version.outputs.VERSION }} --build-arg BUILD_DATE=${{ steps.date_time.outputs.NOW }} --tag ghcr.io/gilbn/theme.park --tag ghcr.io/gilbn/theme.park:${{ steps.get_version.outputs.VERSION }}
|
||||
docker push ghcr.io/gilbn/theme.park
|
||||
- name: build&push dh dev
|
||||
if: ${{ github.event.release.target_commitish == 'live_develop' }}
|
||||
docker build --build-arg TP_RELEASE=${{ steps.get_version.outputs.VERSION }} --build-arg BUILD_DATE=${{ steps.date_time.outputs.NOW }} --tag ghcr.io/gilbn/theme.park --tag gilbn/theme.park:${{ steps.get_version.outputs.VERSION }}
|
||||
docker push gilbn/theme.park
|
||||
- name: build&push dh develop
|
||||
if: ${{ github.ref == 'refs/heads/develop' }}
|
||||
run: |
|
||||
docker build docker/ --build-arg TP_RELEASE=${{ steps.get_version.outputs.VERSION }} --build-arg BUILD_DATE=${{ steps.date_time.outputs.NOW }} --tag gilbn/theme.park:develop --tag gilbn/theme.park:${{ steps.get_version.outputs.VERSION }}
|
||||
docker build --build-arg TP_RELEASE=${{ steps.get_version.outputs.VERSION }} --build-arg BUILD_DATE=${{ steps.date_time.outputs.NOW }} --tag gilbn/theme.park:develop --tag }}
|
||||
docker push --all-tags gilbn/theme.park
|
||||
|
||||
|
23
Dockerfile
Normal file
23
Dockerfile
Normal file
@ -0,0 +1,23 @@
|
||||
FROM ghcr.io/linuxserver/baseimage-alpine-nginx:3.14
|
||||
|
||||
# set version label
|
||||
ARG BUILD_DATE
|
||||
ARG TP_RELEASE
|
||||
LABEL build_version="Version:- ${VERSION} Build-date:- ${BUILD_DATE}"
|
||||
LABEL maintainer="gilbn"
|
||||
|
||||
RUN \
|
||||
echo " ## Installing packages ## " && \
|
||||
apk add --no-cache --virtual=build-dependencies \
|
||||
python3 \
|
||||
curl && \
|
||||
echo "**** install theme.park ****" && \
|
||||
mkdir -p /app/themepark
|
||||
|
||||
# copy local files
|
||||
WORKDIR /app
|
||||
COPY css/ /app/themepark/css/
|
||||
COPY resources/ /app/themepark/resources/
|
||||
COPY themes.py index.html /app/themepark/
|
||||
|
||||
COPY docker/root/ /
|
@ -1,36 +0,0 @@
|
||||
FROM ghcr.io/linuxserver/baseimage-alpine-nginx:3.14
|
||||
|
||||
# set version label
|
||||
ARG BUILD_DATE
|
||||
ARG TP_RELEASE
|
||||
LABEL build_version="Version:- ${VERSION} Build-date:- ${BUILD_DATE}"
|
||||
LABEL maintainer="gilbn"
|
||||
|
||||
RUN \
|
||||
echo " ## Installing packages ## " && \
|
||||
apk add --no-cache --virtual=build-dependencies \
|
||||
curl && \
|
||||
echo "**** install theme.park ****" && \
|
||||
mkdir -p /app/themepark && \
|
||||
if [ -z ${TP_RELEASE+x} ]; then \
|
||||
TP_RELEASE=$(curl -sX GET "https://api.github.com/repos/gilbn/theme.park/releases/latest" \
|
||||
| awk '/tag_name/{print $4;exit}' FS='[""]'); \
|
||||
fi && \
|
||||
curl -o \
|
||||
/tmp/themepark.tar.gz -L \
|
||||
"https://github.com/GilbN/theme.park/archive/refs/tags/${TP_RELEASE}.tar.gz" && \
|
||||
tar xf \
|
||||
/tmp/themepark.tar.gz -C \
|
||||
/app/themepark/ --strip-components=1 && \
|
||||
cd /app/themepark && \
|
||||
echo "**** cleanup ****" && \
|
||||
apk del --purge \
|
||||
build-dependencies && \
|
||||
rm -rf \
|
||||
/root/.cache \
|
||||
/tmp/* \
|
||||
/app/themepark/docker-mods \
|
||||
/app/themepark/resources/organizr
|
||||
|
||||
# copy local files
|
||||
COPY root/ /
|
@ -4,7 +4,7 @@ server {
|
||||
|
||||
server_name _;
|
||||
|
||||
root /app/themepark;
|
||||
root /config/www;
|
||||
index index.html index.htm index.php;
|
||||
|
||||
location / {
|
||||
@ -12,7 +12,7 @@ server {
|
||||
sub_filter 'https://theme-park.dev' $scheme://TP_DOMAIN;
|
||||
sub_filter 'https://develop.theme-park.dev' $scheme://TP_DOMAIN;
|
||||
sub_filter_once off;
|
||||
try_files $uri $uri/ /index.html /index.php?$args =404;
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
# Don't cache
|
||||
|
@ -6,7 +6,10 @@ echo '------------------'
|
||||
|
||||
# Display variables for troubleshooting
|
||||
echo -e "Variables set:\\n\
|
||||
'TP_DOMAIN'=${TP_DOMAIN}\\n"
|
||||
PUID=${PUID}\\n\
|
||||
PGID=${PGID}\\n\
|
||||
TZ=${TZ}\\n\
|
||||
TP_DOMAIN=${TP_DOMAIN}\\n"
|
||||
|
||||
if [[ -z ${TP_DOMAIN} ]]; then
|
||||
echo 'No domain set, defaulting to $http_host'
|
||||
@ -18,3 +21,17 @@ if ! grep -q "sub_filter 'https://theme-park.dev' \$scheme://${TP_DOMAIN};" ${D
|
||||
sed -i "s/sub_filter 'https:\/\/theme-park.dev' \$scheme:\/\/TP_DOMAIN;/sub_filter 'https:\/\/theme-park.dev' \$scheme:\/\/${TP_DOMAIN}; /g" ${DEFAULT}
|
||||
sed -i "s/sub_filter 'https:\/\/develop.theme-park.dev' \$scheme:\/\/TP_DOMAIN;/sub_filter 'https:\/\/develop.theme-park.dev' \$scheme:\/\/${TP_DOMAIN}; /g" ${DEFAULT}
|
||||
fi
|
||||
|
||||
# make our folders and links
|
||||
mkdir -p \
|
||||
/config/www/{css,resources}
|
||||
|
||||
# copy theme files
|
||||
cp -R /app/themepark/css /config/www
|
||||
cp -R /app/themepark/resources /config/www
|
||||
cp /app/themepark/index.html /config/www
|
||||
cp /app/themepark/themes.py /config/www
|
||||
|
||||
# permissions
|
||||
chown -R abc:abc \
|
||||
/config
|
4
docker/root/etc/services.d/themepark/run
Normal file
4
docker/root/etc/services.d/themepark/run
Normal file
@ -0,0 +1,4 @@
|
||||
#!/usr/bin/with-contenv bash
|
||||
|
||||
exec \
|
||||
python3 /config/www/themes.py
|
51
themes.py
51
themes.py
@ -1,12 +1,15 @@
|
||||
from os import listdir
|
||||
from os.path import isdir, isfile, join
|
||||
#! /usr/bin/env python3
|
||||
|
||||
from os import listdir, environ as env, chdir
|
||||
from os.path import isdir, isfile, join, dirname, abspath
|
||||
from json import dump, dumps, loads, load
|
||||
import subprocess
|
||||
import shutil
|
||||
|
||||
chdir(dirname(abspath(__file__))) # Set working dir
|
||||
|
||||
def get_shas(output):
|
||||
"""Returns a dict of CSS files and SHAs"""
|
||||
output_lines = output.splitlines()
|
||||
output_lines = output.splitlines() if output else []
|
||||
sha_dict = {}
|
||||
for line in output_lines:
|
||||
line = line.decode('utf-8').replace("0\t", "").split(" ")
|
||||
@ -17,8 +20,7 @@ def get_shas(output):
|
||||
|
||||
|
||||
def create_addons_json():
|
||||
addon_shas = subprocess.check_output(
|
||||
["git", "ls-files", "-s", "./css/addons/*.css"])
|
||||
addon_shas = subprocess.check_output(["git", "ls-files", "-s", "./css/addons/*.css"]) if isdir(".git") else []
|
||||
SHAS = get_shas(addon_shas)
|
||||
ADDONS = {"addons": {}}
|
||||
addon_root = './css/addons'
|
||||
@ -62,8 +64,8 @@ def create_addons_json():
|
||||
def create_json(app_folders: list = None, themes: list = None, community_themes: list = None, no_sub_folders=False):
|
||||
if no_sub_folders:
|
||||
THEMES_DICT = {}
|
||||
theme_shas = subprocess.check_output(["git", "ls-files", "-s", "./css/theme-options/*.css"])
|
||||
community_theme_shas = subprocess.check_output(["git", "ls-files", "-s", "./css/community-theme-options/*.css"])
|
||||
theme_shas = subprocess.check_output(["git", "ls-files", "-s", "./css/theme-options/*.css"]) if isdir(".git") else []
|
||||
community_theme_shas = subprocess.check_output(["git", "ls-files", "-s", "./css/community-theme-options/*.css"]) if isdir(".git") else []
|
||||
THEME_SHAS = get_shas(theme_shas)
|
||||
COMMUNITY_THEME_SHAS = get_shas(community_theme_shas)
|
||||
THEMES = {
|
||||
@ -91,7 +93,7 @@ def create_json(app_folders: list = None, themes: list = None, community_themes:
|
||||
else:
|
||||
ADDONS = loads(create_addons_json())
|
||||
APPS = {}
|
||||
app_shas = subprocess.check_output(["git", "ls-files", "-s", "./css/base/*base.css"])
|
||||
app_shas = subprocess.check_output(["git", "ls-files", "-s", "./css/base/*base.css"]) if isdir(".git") else []
|
||||
SHAS = get_shas(app_shas)
|
||||
APPS.update(dict(sorted({
|
||||
"applications": {
|
||||
@ -114,25 +116,6 @@ def create_json(app_folders: list = None, themes: list = None, community_themes:
|
||||
APPS.update(THEMES)
|
||||
return dumps(APPS)
|
||||
|
||||
# def temporary_copy_files():
|
||||
# shutil.rmtree("./CSS", ignore_errors=True)
|
||||
# shutil.rmtree("./Resources", ignore_errors=True)
|
||||
# src_dst = {
|
||||
# "./css/base/": "./CSS/themes",
|
||||
# "./css/theme-options": "./CSS/variables",
|
||||
# "./css/community-theme-options": "./CSS/variables",
|
||||
# "./resources/": "./Resources/",
|
||||
# "./css/addons/": "./CSS/addons",
|
||||
# "./css/defaults/": "./CSS/defaults",
|
||||
# "./css/theme-options/organizr.css": "./CSS/variables/organizr-dark.css",
|
||||
# "./css/theme-options/organizr.css": "./css/theme-options/organizr-dark.css"
|
||||
# }
|
||||
# for src in src_dst:
|
||||
# if ".css" in src:
|
||||
# shutil.copy(src,src_dst[src])
|
||||
# continue
|
||||
# shutil.copytree(src,src_dst[src],dirs_exist_ok=True)
|
||||
|
||||
def create_theme_options():
|
||||
def create_css(folder):
|
||||
with open(f"{folder}/{app}/{theme.lower()}.css", "w") as create_app:
|
||||
@ -148,15 +131,19 @@ def create_theme_options():
|
||||
for folder in folders:
|
||||
create_css(folder)
|
||||
|
||||
env_domain = env.get('TP_DOMAIN')
|
||||
|
||||
if __name__ == "__main__":
|
||||
app_folders = [name for name in listdir('./css/base') if isdir(join('./css/base', name))]
|
||||
themes = [name for name in listdir('./css/theme-options') if isfile(join('./css/theme-options', name))]
|
||||
community_themes = [name for name in listdir('./css/community-theme-options') if isfile(join('./css/community-theme-options', name))]
|
||||
with open("CNAME", "rt", closefd=True) as cname:
|
||||
CNAME = cname.readline()
|
||||
develop = True if subprocess.check_output(["git", "symbolic-ref", "--short", "HEAD"]).decode('ascii').strip() == "develop" else False
|
||||
DOMAIN = CNAME if not develop else f"develop.{CNAME}"
|
||||
develop = True if isdir(".git") and subprocess.check_output(["git", "symbolic-ref", "--short", "HEAD"]).decode('ascii').strip() == "develop" else False
|
||||
if env_domain:
|
||||
DOMAIN = env_domain
|
||||
else:
|
||||
with open("CNAME", "rt", closefd=True) as cname:
|
||||
CNAME = cname.readline()
|
||||
DOMAIN = CNAME if not develop else f"develop.{CNAME}"
|
||||
apps = loads(create_json(app_folders=app_folders, themes=themes, community_themes=community_themes))
|
||||
with open("themes.json", "w") as outfile:
|
||||
dump(apps, outfile, indent=2, sort_keys=True)
|
||||
|
Loading…
Reference in New Issue
Block a user