Skip to content
Snippets Groups Projects
Verified Commit 4d24cf1a authored by Martin Weise's avatar Martin Weise
Browse files

Merge branch 'master' into release-latest

parents 731b680a ff397504
No related branches found
No related tags found
No related merge requests found
#!/bin/bash #!/bin/bash
OVERRIDES_MAIN_HTML=""
SCRIPTS_EXTRA_JS=""
function generate_docs { function generate_docs {
BRANCH="release-$1"
echo "===================================================" echo "==================================================="
echo "Building DOCS for version $1 on branch $2" echo "Building DOCS for version $1 on branch $BRANCH"
echo "===================================================" echo "==================================================="
git checkout "$2" git reset --hard && git checkout "$BRANCH"
pip install -r ./requirements.txt pip install -r ./requirements.txt > /dev/null
mkdir -p ./final mkdir -p ./final
if [ "$1" = "latest" ]; then if [ "$1" = "latest" ]; then
sed -i -e "s/__APPVERSION__/${APP_VERSION}/g" .docs/redirect.html OVERRIDES_MAIN_HTML=$(cat .docs/overrides/main.html)
cp ./.docs/redirect.html ./final/index.html sed -i -e "s/__APPVERSION__/${APP_VERSION}/g" .docs/scripts/extra.js
SCRIPTS_EXTRA_JS=$(cat .docs/scripts/extra.js)
else
echo $OVERRIDES_MAIN_HTML > .docs/overrides/main.html
mkdir -p .docs/scripts
echo $SCRIPTS_EXTRA_JS > .docs/scripts/extra.js
fi fi
find .docs/ -type f -exec sed -i -e "s/__APPVERSION__/$1/g" {} \; find .docs/ -type f -exec sed -i -e "s/__APPVERSION__/$1/g" {} \;
find .docs/ -type f -exec sed -i -e "s/__CHARTVERSION__/$1/g" {} \; find .docs/ -type f -exec sed -i -e "s/__CHARTVERSION__/$1/g" {} \;
mkdocs build && cp -r ./site "./final/$1" mkdocs build > /dev/null && cp -r ./site "./final/$1"
cp -r "./swagger/$1" "./final/$1/swagger" cp -r "./swagger/$1" "./final/$1/swagger"
} }
function generate_api { function generate_api {
BRANCH="release-$1"
echo "===================================================" echo "==================================================="
echo "Building API for version $1 on branch $2" echo "Building API for version $1 on branch $BRANCH"
echo "===================================================" echo "==================================================="
git checkout "$2" git reset --hard && git checkout "$BRANCH"
bash .docs/.swagger/swagger-site.sh bash .docs/.swagger/swagger-site.sh
find ./site -type f -exec sed -i -e "s/__APPVERSION__/$1/g" {} \; find ./site -type f -exec sed -i -e "s/__APPVERSION__/$1/g" {} \;
mkdir -p "./swagger/$1" mkdir -p "./swagger/$1"
...@@ -29,34 +39,37 @@ function generate_api { ...@@ -29,34 +39,37 @@ function generate_api {
} }
# usage # usage
if [ -z "$v1_TAGS" ]; then if [ -z "$VERSIONS" ]; then
echo "Variable v1_TAGS not set" echo "Variable VERSIONS not set"
exit 1 exit 1
fi fi
tags=(${v1_TAGS//,/ }) versions=(${VERSIONS//,/ })
# usage # usage
if [ -z "$APP_VERSION" ]; then if [ -z "$APP_VERSION" ]; then
echo "Variable APP_VERSION not set" echo "Variable APP_VERSION not set"
exit 2 exit 2
fi fi
echo "==================================================="
echo "APP_VERSION=$APP_VERSION" echo "APP_VERSION=$APP_VERSION"
for i in "${!tags[@]}"; do echo "==================================================="
version="${tags[i]}"
echo " ~> $version"
done
echo " ~> latest"
# ensure branches exist on machine # ensure branches exist on machine
git fetch git fetch
# tags generate_api "latest"
for i in "${!tags[@]}"; do generate_docs "latest"
version="${tags[i]}"
generate_api "$version" "v$version" # versions
generate_docs "$version" "v$version" for i in "${!versions[@]}"; do
version="${versions[i]}"
generate_api "$version"
generate_docs "$version"
done done
# master
generate_api "latest" "master" # finalization
generate_docs "latest" "master" echo "==================================================="
echo "Moving default version $APP_VERSION docs to /"
cp -r ./final/${APP_VERSION}/* ./final/
echo "==================================================="
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Redirect Notice</title> <title>Redirect Notice</title>
<meta http-equiv="Refresh" content="0; url='https://www.ifs.tuwien.ac.at/infrastructures/dbrepo/__APPVERSION__/'" /> <meta http-equiv="Refresh" content="0; url='/infrastructures/dbrepo/__APPVERSION__/'" />
</head> </head>
<body> <body>
<h1>Redirect Notice</h1> <h1>Redirect Notice</h1>
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
available at: available at:
</p> </p>
<p> <p>
<a href="https://www.ifs.tuwien.ac.at/infrastructures/dbrepo/__APPVERSION__/">https://www.ifs.tuwien.ac.at/infrastructures/dbrepo/__APPVERSION__/</a> <a href="/infrastructures/dbrepo/__APPVERSION__/">/infrastructures/dbrepo/__APPVERSION__/</a>
</p> </p>
</body> </body>
</html> </html>
\ No newline at end of file
function getVersion() { function getVersion() {
const segments = location.pathname.split('/'); const segments = location.pathname.split('/');
if (segments.length >= 4) { if (segments.length > 4) {
console.debug('version', segments[3]);
return segments[3]; return segments[3];
} else { } else {
console.debug('default version', '__APPVERSION__');
return '__APPVERSION__'; return '__APPVERSION__';
} }
} }
......
...@@ -719,7 +719,7 @@ docs-1.4.0: ...@@ -719,7 +719,7 @@ docs-1.4.0:
- release-v1.3 - release-v1.3
- release-v1.4 - release-v1.4
script: script:
- apt-get update && apt-get install -y git make sed wget - apt-get update && apt-get install -y git
- git fetch --tags && git checkout v1.4.0 - git fetch --tags && git checkout v1.4.0
- pip install -r ./requirements.txt - pip install -r ./requirements.txt
- wget https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/-/raw/dev/.docs/overrides/main.html -O .docs/overrides/main.html -q - wget https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/-/raw/dev/.docs/overrides/main.html -O .docs/overrides/main.html -q
......
FROM python:3.11-slim as build
WORKDIR /app
RUN apt-get update && apt-get install -y git
ENV VERSIONS="1.4.1,1.4.0,1.3.0"
ENV APP_VERSION="1.4.1"
COPY .git/ .git/
COPY .docs/ .docs/
COPY ./requirements.txt ./requirements.txt
RUN bash .docs/build-website.sh
FROM nginx as runtime
WORKDIR /usr/share/nginx/html/infrastructures/dbrepo/
COPY --from=build /app/final /usr/share/nginx/html/infrastructures/dbrepo/
\ No newline at end of file
...@@ -10,6 +10,13 @@ volumes: ...@@ -10,6 +10,13 @@ volumes:
storage-service-data: storage-service-data:
services: services:
website:
restart: "no"
image: website
build: .
ports:
- 8000:80
dbrepo-metadata-db: dbrepo-metadata-db:
restart: "no" restart: "no"
container_name: dbrepo-metadata-db container_name: dbrepo-metadata-db
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment