Support local runs

This commit is contained in:
thespad 2024-11-13 13:53:11 +00:00
parent 818b956eb4
commit e22ee740b2
No known key found for this signature in database
2 changed files with 46 additions and 22 deletions

View File

@ -4,7 +4,7 @@
Expects to run as part of the LSIO CI process. Not for public consumption.
## Running against local project
## Running against image
If you need to test functionality just run:
@ -13,6 +13,15 @@ docker pull lscr.io/linuxserver/d2-builder:latest && \
docker run -d --rm -v /tmp/d2:/output -e PUID=1000 -e PGID=1000 lscr.io/linuxserver/d2-builder:latest mastodon:latest
```
## Running against local project
If you need to test functionality, make sure you have the necessary repos cloned locally and the correct branches checked out then just run:
```bash
docker pull lscr.io/linuxserver/d2-builder:latest && \
docker run -d --rm -v /tmp/d2:/output -v /opt/repos:/input:ro -e PUID=1000 -e PGID=1000 -e LOCAL=true lscr.io/linuxserver/d2-builder:latest mastodon:latest
```
Generated svg files will be created in `/output`.
## Versions

View File

@ -16,13 +16,18 @@ OUTPUTNAME="${IMAGENAME}-${TAGNAME}.d2"
mkdir -p "/work/merge"
if [[ ! ${IMAGENAME} == "baseimage"* ]]; then
git clone --depth=1 "https://github.com/linuxserver/docker-${IMAGENAME}" "/tmp/${IMAGENAME}"
IMAGEBRANCH=$(grep -Po "/tmp/${IMAGENAME}/jenkins-vars.yml" -e "^release_tag: \K(.*)$" | tr -d '"')
if [[ "${IMAGEBRANCH}" != "${TAGNAME}" ]]; then
cd "/tmp/${IMAGENAME}" || exit
git remote set-branches origin "${TAGNAME}"
git fetch --depth=1
git checkout "${TAGNAME}"
if [[ -n ${LOCAL} ]]; then
mkdir -p "/tmp/${IMAGENAME}"
cp -R "/input/docker-${IMAGENAME}/"* "/tmp/${IMAGENAME}/"
else
git clone --depth=1 "https://github.com/linuxserver/docker-${IMAGENAME}" "/tmp/${IMAGENAME}"
IMAGEBRANCH=$(grep -Po "/tmp/${IMAGENAME}/jenkins-vars.yml" -e "^release_tag: \K(.*)$" | tr -d '"')
if [[ "${IMAGEBRANCH}" != "${TAGNAME}" ]]; then
cd "/tmp/${IMAGENAME}" || exit
git remote set-branches origin "${TAGNAME}"
git fetch --depth=1
git checkout "${TAGNAME}"
fi
fi
BASEIMAGE=$(grep "/tmp/${IMAGENAME}/Dockerfile" -e "^FROM" | tail -l)
@ -37,13 +42,18 @@ else
fi
if [[ ${BASEIMAGENAME} =~ "baseimage" ]]; then
git clone --depth=1 "https://github.com/linuxserver/docker-${BASEIMAGENAME}" "/tmp/${BASEIMAGENAME}"
BASEBRANCH=$(grep -Po "/tmp/${BASEIMAGENAME}/jenkins-vars.yml" -e "^release_tag: \K(.*)$" | tr -d '"')
if [[ "${BASEBRANCH}" != "${BASEIMAGETAG}" ]]; then
cd "/tmp/${BASEIMAGENAME}" || exit
git remote set-branches origin "${BASEIMAGETAG}"
git fetch --depth=1
git checkout "${BASEIMAGETAG}"
if [[ -n ${LOCAL} ]]; then
mkdir -p "/tmp/${BASEIMAGENAME}"
cp -R "/input/docker-${BASEIMAGENAME}/"* "/tmp/${BASEIMAGENAME}/"
else
git clone --depth=1 "https://github.com/linuxserver/docker-${BASEIMAGENAME}" "/tmp/${BASEIMAGENAME}"
BASEBRANCH=$(grep -Po "/tmp/${BASEIMAGENAME}/jenkins-vars.yml" -e "^release_tag: \K(.*)$" | tr -d '"')
if [[ "${BASEBRANCH}" != "${BASEIMAGETAG}" ]]; then
cd "/tmp/${BASEIMAGENAME}" || exit
git remote set-branches origin "${BASEIMAGETAG}"
git fetch --depth=1
git checkout "${BASEIMAGETAG}"
fi
fi
fi
@ -58,13 +68,18 @@ while [[ ${BASEIMAGENAME} =~ "baseimage" ]]; do
else
BASELIST="\"${BASEIMAGE}\""
fi
git clone --depth=1 "https://github.com/linuxserver/docker-${BASEIMAGENAME}" "/tmp/${BASEIMAGENAME}"
BASEBRANCH=$(grep -Po "/tmp/${BASEIMAGENAME}/jenkins-vars.yml" -e "^release_tag: \K(.*)$" | tr -d '"')
if [[ "${BASEBRANCH}" != "${BASEIMAGETAG}" ]]; then
cd "/tmp/${BASEIMAGENAME}" || exit
git remote set-branches origin "${BASEIMAGETAG}"
git fetch --depth=1
git checkout "${BASEIMAGETAG}"
if [[ -n ${LOCAL} ]]; then
mkdir -p "/tmp/${BASEIMAGENAME}"
cp -R "/input/docker-${BASEIMAGENAME}/"* "/tmp/${BASEIMAGENAME}/"
else
git clone --depth=1 "https://github.com/linuxserver/docker-${BASEIMAGENAME}" "/tmp/${BASEIMAGENAME}"
BASEBRANCH=$(grep -Po "/tmp/${BASEIMAGENAME}/jenkins-vars.yml" -e "^release_tag: \K(.*)$" | tr -d '"')
if [[ "${BASEBRANCH}" != "${BASEIMAGETAG}" ]]; then
cd "/tmp/${BASEIMAGENAME}" || exit
git remote set-branches origin "${BASEIMAGETAG}"
git fetch --depth=1
git checkout "${BASEIMAGETAG}"
fi
fi
BASEIMAGE=$(grep "/tmp/${BASEIMAGENAME}/Dockerfile" -e "^FROM" | tail -1)
BASEIMAGE=${BASEIMAGE##*/}