Skip to content

Commit d665787

Browse files
authored
Merge pull request #1 from geniusdynamics/dev
Dev
2 parents 2adc684 + 2e43bf3 commit d665787

6 files changed

Lines changed: 89 additions & 61 deletions

File tree

build-images.sh

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,23 @@ images=()
1414
repobase="${REPOBASE:-ghcr.io/geniusdynamics}"
1515
# Configure the image name
1616
reponame="mautic"
17+
mautic_version="6-apache"
1718

1819
# Create a new empty container image
1920
container=$(buildah from scratch)
2021

2122
# Reuse existing nodebuilder-mautic container, to speed up builds
2223
if ! buildah containers --format "{{.ContainerName}}" | grep -q nodebuilder-mautic; then
23-
echo "Pulling NodeJS runtime..."
24-
buildah from --name nodebuilder-mautic -v "${PWD}:/usr/src:Z" docker.io/library/node:lts
24+
echo "Pulling NodeJS runtime..."
25+
buildah from --name nodebuilder-mautic -v "${PWD}:/usr/src:Z" docker.io/library/node:lts
2526
fi
2627

2728
echo "Build static UI files with node..."
2829
buildah run \
29-
--workingdir=/usr/src/ui \
30-
--env="NODE_OPTIONS=--openssl-legacy-provider" \
31-
nodebuilder-mautic \
32-
sh -c "yarn install && yarn build"
30+
--workingdir=/usr/src/ui \
31+
--env="NODE_OPTIONS=--openssl-legacy-provider" \
32+
nodebuilder-mautic \
33+
sh -c "yarn install && yarn build"
3334

3435
# Add imageroot directory to the container image
3536
buildah add "${container}" imageroot /imageroot
@@ -42,11 +43,11 @@ buildah add "${container}" ui/dist /ui
4243
# rootfull=0 === rootless container
4344
# tcp-ports-demand=1 number of tcp Port to reserve , 1 is the minimum, can be udp or tcp
4445
buildah config --entrypoint=/ \
45-
--label="org.nethserver.authorizations=traefik@node:routeadm" \
46-
--label="org.nethserver.tcp-ports-demand=1" \
47-
--label="org.nethserver.rootfull=0" \
48-
--label="org.nethserver.images=docker.io/mariadb:10.11.5 docker.io/mautic/mautic:5.1-apache" \
49-
"${container}"
46+
--label="org.nethserver.authorizations=traefik@node:routeadm" \
47+
--label="org.nethserver.tcp-ports-demand=1" \
48+
--label="org.nethserver.rootfull=0" \
49+
--label="org.nethserver.images=docker.io/mariadb:10.11.5 docker.io/mautic/mautic:$mautic_version" \
50+
"${container}"
5051
# Commit the image
5152
buildah commit "${container}" "${repobase}/${reponame}"
5253

@@ -64,14 +65,14 @@ images+=("${repobase}/${reponame}")
6465
#
6566

6667
#
67-
# Setup CI when pushing to Github.
68+
# Setup CI when pushing to Github.
6869
# Warning! docker::// protocol expects lowercase letters (,,)
6970
if [[ -n "${CI}" ]]; then
70-
# Set output value for Github Actions
71-
printf "images=%s\n" "${images[*],,}" >> "${GITHUB_OUTPUT}"
71+
# Set output value for Github Actions
72+
printf "images=%s\n" "${images[*],,}" >>"${GITHUB_OUTPUT}"
7273
else
73-
# Just print info for manual push
74-
printf "Publish the images with:\n\n"
75-
for image in "${images[@],,}"; do printf " buildah push %s docker://%s:%s\n" "${image}" "${image}" "${IMAGETAG:-latest}" ; done
76-
printf "\n"
74+
# Just print info for manual push
75+
printf "Publish the images with:\n\n"
76+
for image in "${images[@],,}"; do printf " buildah push %s docker://%s:%s\n" "${image}" "${image}" "${IMAGETAG:-latest}"; done
77+
printf "\n"
7778
fi

imageroot/actions/configure-module/10configure_environment_vars

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,6 @@ import agent
1313
# If parsing fails, output everything to stderr
1414
data = json.load(sys.stdin)
1515

16-
#This is specific to you module, so you need to change it accordingly.
17-
18-
MARIADB_ROOT_PASSWORD = data.get("MARIADB_ROOT_PASSWORD", "Nethesis@1234")
19-
MARIADB_DATABASE = data.get("MARIADB_DATABASE", "mautic")
20-
MARIADB_USER = data.get("MARIADB_USER", "mautic")
21-
MARIADB_PASSWORD = data.get("MARIADB_PASSWORD", "Nethesis@1234")
22-
MARIADB_AUTO_UPGRADE = data.get("MARIADB_AUTO_UPGRADE", "1")
23-
24-
maria_db = {
25-
"MARIADB_ROOT_PASSWORD": MARIADB_ROOT_PASSWORD,
26-
"MARIADB_DATABASE": MARIADB_DATABASE,
27-
"MARIADB_USER": MARIADB_USER,
28-
"MARIADB_PASSWORD": MARIADB_PASSWORD,
29-
"MARIADB_AUTO_UPGRADE": MARIADB_AUTO_UPGRADE
30-
}
31-
agent.write_envfile("database.env", maria_db)
32-
33-
34-
app_config = {
35-
"MAUTIC_DB_HOST": "mariadb-app",
36-
"MAUTIC_DB_PORT": "3306",
37-
"MAUTIC_DB_DATABASE": MARIADB_DATABASE,
38-
"MAUTIC_DB_USER": MARIADB_USER,
39-
"MAUTIC_DB_PASSWORD": MARIADB_PASSWORD,
40-
"MAUTIC_MESSENGER_DSN_EMAIL": "doctrine://default",
41-
"MAUTIC_MESSENGER_DSN_HIT": "doctrine://default"
42-
}
43-
agent.write_envfile("app.env", app_config)
4416

4517
# just before starting systemd unit
46-
#agent.dump_env()
18+
# agent.dump_env()
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/env python3
2+
3+
#
4+
# Copyright (C) 2022 Nethesis S.r.l.
5+
# SPDX-License-Identifier: GPL-3.0-or-later
6+
#
7+
8+
import json
9+
import sys
10+
import agent
11+
import os
12+
13+
# Try to parse the stdin as JSON.
14+
# If parsing fails, output everything to stderr
15+
data = json.load(sys.stdin)
16+
17+
18+
def generate_random_password(length):
19+
# Generate random bytes and convert them to a hexadecimal string
20+
random_bytes = os.urandom(length)
21+
password = random_bytes.hex()
22+
return password[:length]
23+
24+
25+
MARIADB_ROOT_PASSWORD = generate_random_password(16)
26+
MARIADB_DATABASE = data.get("MARIADB_DATABASE", "mautic")
27+
MARIADB_USER = data.get("MARIADB_USER", "mautic")
28+
MARIADB_PASSWORD = generate_random_password(16)
29+
MARIADB_AUTO_UPGRADE = data.get("MARIADB_AUTO_UPGRADE", "1")
30+
31+
maria_db = {
32+
"MARIADB_ROOT_PASSWORD": MARIADB_ROOT_PASSWORD,
33+
"MARIADB_DATABASE": MARIADB_DATABASE,
34+
"MARIADB_USER": MARIADB_USER,
35+
"MARIADB_PASSWORD": MARIADB_PASSWORD,
36+
"MARIADB_AUTO_UPGRADE": MARIADB_AUTO_UPGRADE,
37+
}
38+
agent.write_envfile("database.env", maria_db)
39+
40+
41+
app_config = {
42+
"MAUTIC_DB_HOST": "mariadb-app",
43+
"MAUTIC_DB_PORT": "3306",
44+
"MAUTIC_DB_DATABASE": MARIADB_DATABASE,
45+
"MAUTIC_DB_USER": MARIADB_USER,
46+
"MAUTIC_DB_PASSWORD": MARIADB_PASSWORD,
47+
"MAUTIC_MESSENGER_DSN_EMAIL": "doctrine://default",
48+
"MAUTIC_MESSENGER_DSN_HIT": "doctrine://default",
49+
}
50+
agent.write_envfile("app.env", app_config)
51+
52+
# just before starting systemd unit
53+
# agent.dump_env()

imageroot/actions/restore-module/40restore_database

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,11 @@ trap 'rm -rfv initdb.d/' EXIT
2828
# at the end of mautic_restore.sh the dump is loaded and
2929
# we exit the container
3030
podman run \
31-
--rm \
32-
--interactive \
33-
--network=none \
34-
--volume=./initdb.d:/docker-entrypoint-initdb.d:z \
35-
--volume mysql-data:/var/lib/mysql/:Z \
36-
--env MARIADB_ROOT_PASSWORD=Nethesis,1234 \
37-
--env MARIADB_DATABASE=mautic \
38-
--env MARIADB_USER=mautic \
39-
--env MARIADB_PASSWORD=mautic \
40-
--replace --name=restore_db \
41-
${MARIADB_IMAGE}
31+
--rm \
32+
--interactive \
33+
--network=none \
34+
--volume=./initdb.d:/docker-entrypoint-initdb.d:z \
35+
--volume mysql-data:/var/lib/mysql/:Z \
36+
--env-file=database.env \
37+
--replace --name=restore_db \
38+
${MARIADB_IMAGE}

imageroot/etc/state-include.conf

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,12 @@
66

77

88
state/mautic.sql
9-
volumes/mautic-app
9+
state/database.env
10+
state/app.env
11+
12+
volumes/mautic-config
13+
volumes/mautic-logs
14+
volumes/mautic-files
15+
volumes/mautic-images
16+
volumes/mautic-cron
1017

imageroot/systemd/user/mariadb-app.service

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ ExecStart=/usr/bin/podman run --conmon-pidfile %t/mariadb-app.pid \
2222
--volume mysql-data:/var/lib/mysql/:Z \
2323
${MARIADB_IMAGE} \
2424
--character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
25-
ExecStartPost=/usr/bin/podman exec mariadb-app /bin/bash -c 'printf "[client] \npassword=Nethesis,1234" > /root/.my.cnf'
26-
ExecStartPost=/usr/bin/podman exec mariadb-app /bin/bash -c "while ! mysqladmin ping -h localhost -P 3306 -u root; do sleep 1; done"
2725
ExecStop=/usr/bin/podman stop --ignore --cidfile %t/mariadb-app.ctr-id -t 10
2826
ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/mariadb-app.ctr-id
2927
ExecReload=/usr/bin/podman kill -s HUP mariadb-app

0 commit comments

Comments
 (0)