refactoring , dockerizing

This commit is contained in:
Schneider Roland
2025-01-08 17:12:09 +01:00
parent a8b144f554
commit 9d7bb39769
119 changed files with 433 additions and 159 deletions

View File

@@ -3,7 +3,7 @@
CURRENT_DIR=$(dirname "$0")
# build docker image
source "${CURRENT_DIR}/build.docker.env.sh"
PROJECT_ROOT=$(readlink -f "${CURRENT_DIR}/../../../../../strapi-yoga")
PROJECT_ROOT=$(readlink -f "${CURRENT_DIR}/../../../../../yoga-app")
echo "build image ${TAG} from folder ${PROJECT_ROOT}"

View File

@@ -6,4 +6,4 @@ echo "Reading version file: ${VERSION_FILE}"
export VERSION=$(cat "${VERSION_FILE}")
export TAG=docker.rschneider.hu/infra/yoga-strapi:$VERSION
export TAG=docker.rschneider.hu/infra/yoga-app:$VERSION

View File

@@ -0,0 +1 @@
202501071722.a8b144f

View File

@@ -0,0 +1,54 @@
# Building the docker image
## Dockerfile
The Dockerfile can be found in the root folder of the project.
## Available Environment Variables
| property name | description | values |
|----------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| DB_TYPE | type of the db enginge. | mysql, h2 |
| DB_URL | jdbc url of the db | "jdbc:mysql://ucs-intranet-db-author:3306/magnolia" |
| DB_USER | username for the db | root |
| DB_PASSWORD | password for the db | root |
| CATALINA_OPTS_APPEND | Java options form tomcat | "-Xms512M -Xmx2048M " |
| JAVA_OPTS | addition java options for application | "-agentlib:jdwp=transport=dt_socket,address=*:54455,server=y,suspend=n" |
| MAGNOLIA_UPDATE_AUTO | set the property 'magnolia.update.auto' in magnolia.properties | ${MAGNOLIA_UPDATE_AUTO} |
| MAGNOLIA_AUTHORINSTANCE_URL | public accessible url of the author instance | http://author.ucsintranet.at |
| MAGNOLIA_UCSWEBSITE_AUTHORINSTANCE_URL | public accessible url of the author instance of the UCS website | http://author.ucsintranet.at |
| MAGNOLIA_PUBLICINSTANCE_URL | public accessible url of the public instance | http://public.ucsintranet.at |
| MAGNOLIA_PROFILE | the magnolia profile to use (see: https://docs.magnolia-cms.com/product-docs/6.2/releases/release-notes-for-magnolia-cms-6.2.2/#_profile_based_configuration_of_property_files) | magnoliaAuthor, magnoliaPublic |
| KEYCLOAK_REALM | the keycloak realm to use | magnolia |
| KEYCLOAK_CLIENT_ID_AUTHOR | the author keycloak client id | author.ucsintranet |
| KEYCLOAK_CLIENT_ID_PUBLIC | the author keycloak client id | author.ucsintranet |
| KEYCLOAK_AUTH_URL | <TBD> | ${KEYCLOAK_AUTH_URL} |
| KEYCLOAK_SSL_REQUIRED | <TBD> | external |
| KEYCLOAK_CREDENTIALS_SECRET_AUTHOR | author keycloak secret | |
| KEYCLOAK_CREDENTIALS_SECRET_PUBLIC | public keycloak secret | |
## About the image
The image is based on the cli provided by magnolia ( a.k.a mgnl).
To get more information about the mgnl cli tool, please visit the [mgnl documentation](https://docs.magnolia-cms.com/magnolia-cli/4.x/)
The project generated by the mgnl tool, already includes the author and public instances!
Be sure, that in production you restrict the access to the author instance, and to the admin components
The image is set up so, that it uses the folder "/magnolia/light-modules" as resources dir.
While build the image, the <PROJECT_ROOT>/magnolia/modules will be copied in to the image as "/magnolia/light-modules".
For development, the <PROJECT_ROOT>/magnolia/modules can be mounted, so the changes in the lightmodules are "live/instant"
## Building & pushing the image
The easiest way to build and pusht the image is, to run the next commands
```bash
npm run docker:build
```
```bash
npm run docker:push
```
For more details, pls examine the package.json file, and the scripts in docker/magnolia/scripts folder

View File

@@ -0,0 +1,5 @@
#!/usr/bin/env bash
CURRENT_DIR=$(dirname "$0")
source "${CURRENT_DIR}/build.docker.build.step.inc.version.sh"
source "${CURRENT_DIR}/build.docker.build.step.build.sh"

View File

@@ -0,0 +1,12 @@
#!/usr/bin/env bash
CURRENT_DIR=$(dirname "$0")
# build docker image
source "${CURRENT_DIR}/build.docker.env.sh"
PROJECT_ROOT=$(readlink -f "${CURRENT_DIR}/../../../../../yoga-cms")
echo "build image ${TAG} from folder ${PROJECT_ROOT}"
cd $PROJECT_ROOT
docker build --platform linux/amd64 -t $TAG .

View File

@@ -0,0 +1,17 @@
#!/usr/bin/env bash
# set the actual commit date and commit hash in version.txt
GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
GIT_BRANCH_SHORT=$(echo $GIT_BRANCH | cut -d "/" -f 1)
GIT_COMMIT_DATE=$(git log -1 --format=%cd --date=format:%Y%m%d%H%M)
GIT_COMMIT_ID_SHORT=$(git rev-parse --short HEAD)
VERSION=$GIT_COMMIT_DATE.$GIT_COMMIT_ID_SHORT
CURRENT_DIR=$(dirname "$0")
VERSION_FILE="${CURRENT_DIR}/version.txt"
echo "Saving version ${VERSION} to file ${VERSION_FILE}"
echo $VERSION
echo $VERSION > $VERSION_FILE

View File

@@ -0,0 +1,9 @@
#!/usr/bin/env bash
CURRENT_DIR=$(dirname "$0")
VERSION_FILE="${CURRENT_DIR}/version.txt"
echo "Reading version file: ${VERSION_FILE}"
export VERSION=$(cat "${VERSION_FILE}")
export TAG=docker.rschneider.hu/infra/yoga-cms:$VERSION

View File

@@ -0,0 +1,7 @@
#!/usr/bin/env bash
CURRENT_DIR=$(dirname "$0")
# push docker image
source "${CURRENT_DIR}/build.docker.env.sh"
echo "push image ${TAG}"
docker push $TAG

View File

@@ -0,0 +1 @@
202501071722.a8b144f

View File

@@ -1 +0,0 @@
202501062213.bed409f

View File

@@ -1,22 +1,69 @@
services:
vaultwarden:
labels:
- traefik.http.routers.yoga.rule=Host(`yoga.rschneider.net`)
- traefik.http.routers.yoga.tls=true
- traefik.http.routers.yoga.service=yoga
- traefik.http.services.yoga.loadbalancer.server.port=80
- traefik.http.routers.yoga-public.rule=Host(`yoga.rschneider.hu`)
- traefik.http.routers.yoga-public.tls=true
- traefik.http.routers.yoga-public.service=yoga-public
- traefik.http.services.yoga-public.loadbalancer.server.port=80
# - traefik.http.middlewares.test-redirectscheme.redirectscheme.scheme=https
# - traefik.http.middlewares.test-redirectscheme.redirectscheme.permanent=true
image: docker.rschneider.hu/infra/yogastic:202412282019.ae4bba3
container_name: yogastic
restart: always
networks:
traefik_traefik:
# yogastic:
# labels:
# - traefik.http.routers.yoga.rule=Host(`yoga.rschneider.net`)
# - traefik.http.routers.yoga.tls=true
# - traefik.http.routers.yoga.service=yoga
# - traefik.http.services.yoga.loadbalancer.server.port=80
# - traefik.http.routers.yoga-public.rule=Host(`yoga.rschneider.hu`)
# - traefik.http.routers.yoga-public.tls=true
# - traefik.http.routers.yoga-public.service=yoga-public
# - traefik.http.services.yoga-public.loadbalancer.server.port=80
## - traefik.http.middlewares.test-redirectscheme.redirectscheme.scheme=https
## - traefik.http.middlewares.test-redirectscheme.redirectscheme.permanent=true
# image: docker.rschneider.hu/infra/yogastic:202412282019.ae4bba3
# container_name: yogastic
# restart: always
# networks:
# traefik_traefik:
networks:
traefik_traefik:
external: true
strapi-db:
image: mariadb:11.6.2
environment:
MARIADB_ROOT_PASSWORD: strapi
MARIADB_DATABASE: strapi
MARIADB_USER: strapi
MARIADB_PASSWORD: strapi
volumes:
- strapi-db:/var/lib/mysql
ports:
- "4011:3306"
nextjs-db:
image: postgres:17
environment:
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DATABASE}
POSTGRES_USER: ${POSTGRES_USER}
volumes:
- next-db:/var/lib/postgresql/data
ports:
- "4012:5432"
app:
image: docker.rschneider.hu/infra/yoga-app:202501071722.a8b144f
ports:
- "4081:3000"
environment:
POSTGRES_URL: ${POSTGRES_URL}
POSTGRES_URL_NON_POOLING: ${POSTGRES_URL_NON_POOLING}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_HOST: ${POSTGRES_HOST}
POSTGRES_PORT: ${POSTGRES_PORT}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DATABASE: ${POSTGRES_DATABASE}
cms:
image: docker.rschneider.hu/infra/yoga-cms:202501071722.a8b144f
ports:
- "4082:1337"
volumes:
next-db: {}
strapi-db: {}
#networks:
# traefik_traefik:
# external: true