Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
85afd501ce | |||
4dbc156439 | |||
fd3e8751fe | |||
21ea1aa56f
|
|||
eefc8d5b21
|
|||
41010b8a7b | |||
43583fb7f3 | |||
1f5b4163e7 | |||
38d3381ecd
|
|||
db769ca053
|
|||
536e933fef
|
|||
d469a7cf2c
|
|||
d308fd662a
|
@ -10,10 +10,29 @@ steps:
|
|||||||
from_secret: container_registry_username
|
from_secret: container_registry_username
|
||||||
password:
|
password:
|
||||||
from_secret: container_registry_password
|
from_secret: container_registry_password
|
||||||
|
build_args:
|
||||||
|
- VERSION_ID1=${CI_COMMIT_SHA}
|
||||||
|
- VERSION_ID2=${CI_COMMIT_TAG}
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
when:
|
when:
|
||||||
- event: [push, tag]
|
- event: [push, tag]
|
||||||
|
|
||||||
|
deploytest:
|
||||||
|
image: portainer/kubectl-shell:latest
|
||||||
|
secrets:
|
||||||
|
- source: kube_config
|
||||||
|
target: KUBE_CONFIG_CONTENT
|
||||||
|
- source: encryption_key
|
||||||
|
target: ENCRYPTION_KEY
|
||||||
|
- source: secrets_checksum
|
||||||
|
target: MD5_CHECKSUM
|
||||||
|
commands:
|
||||||
|
- printf "$KUBE_CONFIG_CONTENT" > /tmp/kubeconfig
|
||||||
|
- export KUBECONFIG=/tmp/kubeconfig
|
||||||
|
- ./deployment/deploy.sh test
|
||||||
|
when:
|
||||||
|
- event: [push, tag]
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
image: portainer/kubectl-shell:latest
|
image: portainer/kubectl-shell:latest
|
||||||
secrets:
|
secrets:
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
FROM python:3.12-alpine3.19
|
FROM python:3.12-alpine3.19
|
||||||
|
|
||||||
ARG APP_DIR="/opt/app"
|
ARG APP_DIR="/opt/app"
|
||||||
|
ARG VERSION_ID1="x"
|
||||||
|
ARG VERSION_ID2="alpha"
|
||||||
|
|
||||||
COPY ./src/ ${APP_DIR}/
|
COPY ./src/ ${APP_DIR}/
|
||||||
COPY start.sh ${APP_DIR}/
|
COPY start.sh ${APP_DIR}/
|
||||||
@ -9,7 +11,9 @@ WORKDIR ${APP_DIR}
|
|||||||
|
|
||||||
RUN \
|
RUN \
|
||||||
apk add --no-cache build-base libpq-dev && \
|
apk add --no-cache build-base libpq-dev && \
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt && \
|
||||||
|
if [ "${VERSION_ID2}" != "" ]; then VERSION_ID=${VERSION_ID2}; else VERSION_ID=${VERSION_ID1}; fi && \
|
||||||
|
sed -i -e 's/VERSION_ID/'$VERSION_ID'/' ${APP_DIR}/templates/index.html
|
||||||
|
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if [ "$ENCRYPTION_KEY" = "" ]; then
|
if [ "$ENCRYPTION_KEY" = "" ]; then
|
||||||
echo "ENCRYPTION_KEY not set"
|
echo "ENCRYPTION_KEY not set"
|
||||||
exit 1
|
exit 1
|
||||||
@ -10,6 +12,7 @@ if [ "$MD5_CHECKSUM" = "" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
SECRETS_CIPHERTEXT_FILE=secrets.enc
|
SECRETS_CIPHERTEXT_FILE=secrets.enc
|
||||||
SECRETS_PLAINTEXT_FILE=/tmp/secrets
|
SECRETS_PLAINTEXT_FILE=/tmp/secrets
|
||||||
TMP_FILE=`mktemp`
|
TMP_FILE=`mktemp`
|
||||||
|
@ -46,10 +46,10 @@ metadata:
|
|||||||
spec:
|
spec:
|
||||||
tls:
|
tls:
|
||||||
- hosts:
|
- hosts:
|
||||||
- nutri.hottis.de
|
- nutri%POSTFIX%.hottis.de
|
||||||
secretName: nutri-cert
|
secretName: nutri-cert
|
||||||
rules:
|
rules:
|
||||||
- host: nutri.hottis.de
|
- host: nutri%POSTFIX%.hottis.de
|
||||||
http:
|
http:
|
||||||
paths:
|
paths:
|
||||||
- path: /
|
- path: /
|
||||||
|
@ -1,13 +1,19 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ "$1" == "test" ]; then
|
||||||
|
POSTFIX="-test"
|
||||||
|
IMAGE_TAG=${CI_COMMIT_SHA}
|
||||||
|
else
|
||||||
|
POSTFIX=""
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$IMAGE_TAG" == "" ]; then
|
if [ "$IMAGE_TAG" == "" ]; then
|
||||||
echo "Make sure IMAGE_TAG is set"
|
echo "Make sure IMAGE_TAG is set"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
IMAGE_NAME=gitea.hottis.de/moerp/elo-rezept-rechner
|
IMAGE_NAME=gitea.hottis.de/moerp/elo-rezept-rechner
|
||||||
NAMESPACE=moerp
|
NAMESPACE=moerp${POSTFIX}
|
||||||
DEPLOYMENT_DIR=$PWD/deployment
|
DEPLOYMENT_DIR=$PWD/deployment
|
||||||
|
|
||||||
pushd $DEPLOYMENT_DIR > /dev/null
|
pushd $DEPLOYMENT_DIR > /dev/null
|
||||||
@ -15,7 +21,7 @@ pushd $DEPLOYMENT_DIR > /dev/null
|
|||||||
. /tmp/secrets
|
. /tmp/secrets
|
||||||
rm /tmp/secrets
|
rm /tmp/secrets
|
||||||
|
|
||||||
CLIENT_SECRETS=`cat oidc-config.json | sed -e's!%CLIENT_SECRET%!'$CLIENT_SECRET'!'`
|
CLIENT_SECRETS=`cat oidc-config${POSTFIX}.json | sed -e's!%CLIENT_SECRET%!'$CLIENT_SECRET'!'`
|
||||||
|
|
||||||
kubectl create namespace $NAMESPACE \
|
kubectl create namespace $NAMESPACE \
|
||||||
--dry-run=client \
|
--dry-run=client \
|
||||||
@ -37,6 +43,7 @@ kubectl create secret generic nutri-secrets \
|
|||||||
|
|
||||||
cat $DEPLOYMENT_DIR/deploy-yml.tmpl | \
|
cat $DEPLOYMENT_DIR/deploy-yml.tmpl | \
|
||||||
sed -e 's,%IMAGE%,'$IMAGE_NAME':'$IMAGE_TAG','g | \
|
sed -e 's,%IMAGE%,'$IMAGE_NAME':'$IMAGE_TAG','g | \
|
||||||
|
sed -e 's,%POSTFIX%,'$POSTFIX','g | \
|
||||||
kubectl apply -f - -n $NAMESPACE
|
kubectl apply -f - -n $NAMESPACE
|
||||||
|
|
||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
|
13
deployment/oidc-config-test.json
Normal file
13
deployment/oidc-config-test.json
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"web": {
|
||||||
|
"issuer": "https://auth2.hottis.de/realms/hottis",
|
||||||
|
"auth_uri": "https://auth2.hottis.de/ealms/hottis/protocol/openid-connect/auth",
|
||||||
|
"client_id": "nutri",
|
||||||
|
"client_secret": "%CLIENT_SECRET%",
|
||||||
|
"redirect_uris": [
|
||||||
|
"https://nutri-test.hottis.de/*"
|
||||||
|
],
|
||||||
|
"userinfo_uri": "https://auth2.hottis.de/realms/hottis/protocol/openid-connect/userinfo",
|
||||||
|
"token_uri": "https://auth2.hottis.de/realms/hottis/protocol/openid-connect/token"
|
||||||
|
}
|
||||||
|
}
|
@ -19,7 +19,7 @@ app.config.update({
|
|||||||
})
|
})
|
||||||
|
|
||||||
oidc = OpenIDConnect(app)
|
oidc = OpenIDConnect(app)
|
||||||
|
app.logger.handlers = logging.getLogger('gunicorn.error').handlers
|
||||||
|
|
||||||
def calculate_nutrition(food, weight):
|
def calculate_nutrition(food, weight):
|
||||||
try:
|
try:
|
||||||
@ -65,7 +65,7 @@ def get_products():
|
|||||||
try:
|
try:
|
||||||
conn = psycopg2.connect()
|
conn = psycopg2.connect()
|
||||||
with conn.cursor() as cursor:
|
with conn.cursor() as cursor:
|
||||||
cursor.execute('SELECT name FROM nutrition_table')
|
cursor.execute('SELECT name FROM nutrition_table ORDER BY name')
|
||||||
products = cursor.fetchall()
|
products = cursor.fetchall()
|
||||||
return {'products': [product[0] for product in products]}
|
return {'products': [product[0] for product in products]}
|
||||||
finally:
|
finally:
|
||||||
|
@ -72,7 +72,7 @@ tr:nth-child(even) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.selected, tr.selected {
|
.selected, tr.selected {
|
||||||
background-color: #e5b5b5; /* Hervorhebung der Auswahl */
|
background-color: #efcccc; /* Hervorhebung der Auswahl */
|
||||||
}
|
}
|
||||||
|
|
||||||
tr:hover:not(.selected) {
|
tr:hover:not(.selected) {
|
||||||
@ -172,7 +172,7 @@ tr:hover:not(.selected) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#database-nutrition-table tr.selected {
|
#database-nutrition-table tr.selected {
|
||||||
background-color: #f0e68c;
|
background-color: #efcccc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -177,6 +177,7 @@ function updateTotalNutrition() {
|
|||||||
<nav id="navbar">
|
<nav id="navbar">
|
||||||
<h1>Elo's Rezept Rechner</h1>
|
<h1>Elo's Rezept Rechner</h1>
|
||||||
<ul>
|
<ul>
|
||||||
|
<li class="versionid">VERSION_ID</li>
|
||||||
<li><a href="/" class="active">Rechner</a></li>
|
<li><a href="/" class="active">Rechner</a></li>
|
||||||
<li><a href="/nutrition">Neue Lebensmittel</a></li>
|
<li><a href="/nutrition">Neue Lebensmittel</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
@ -232,4 +233,4 @@ function updateTotalNutrition() {
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
// Beispielsweise das Formular zurücksetzen
|
// Beispielsweise das Formular zurücksetzen
|
||||||
form.reset();
|
form.reset();
|
||||||
updateSubmitButtonState();
|
updateSubmitButtonState();
|
||||||
|
loadDatabaseEntries();
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
console.error('Fehler:', error);
|
console.error('Fehler:', error);
|
||||||
});
|
});
|
||||||
@ -98,7 +99,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updateDeleteButtonState() {
|
function updateDeleteButtonState() {
|
||||||
const selectedRows = document.querySelectorAll('#nutrition-table .selected').length;
|
const selectedRows = document.querySelectorAll('#database-nutrition-table .selected').length;
|
||||||
const deleteButton = document.getElementById('delete-row-button');
|
const deleteButton = document.getElementById('delete-row-button');
|
||||||
deleteButton.disabled = selectedRows === 0;
|
deleteButton.disabled = selectedRows === 0;
|
||||||
if (selectedRows === 0) {
|
if (selectedRows === 0) {
|
||||||
@ -107,11 +108,13 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function loadDatabaseEntries() {
|
function loadDatabaseEntries() {
|
||||||
fetch('/get_database_entries') // Pfad zur entsprechenden Flask-Route
|
fetch('/get_database_entries') // Pfad zur entsprechenden Flask-Route
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
const tableBody = document.getElementById('database-nutrition-table').getElementsByTagName('tbody')[0];
|
const tableBody = document.getElementById('database-nutrition-table').getElementsByTagName('tbody')[0];
|
||||||
|
tableBody.innerHTML = '';
|
||||||
data.forEach(entry => {
|
data.forEach(entry => {
|
||||||
const row = tableBody.insertRow();
|
const row = tableBody.insertRow();
|
||||||
row.insertCell(0).innerHTML = entry.food;
|
row.insertCell(0).innerHTML = entry.food;
|
||||||
|
Reference in New Issue
Block a user