diff --git a/.github/workflows/deployment.yaml b/.github/workflows/deployment.yaml index 1e62132..55543ae 100644 --- a/.github/workflows/deployment.yaml +++ b/.github/workflows/deployment.yaml @@ -13,6 +13,7 @@ on: - init-grav - vault - terraform-agent + - mongo tag: required: true description: Version a tag l'image diff --git a/grav/Dockerfile b/grav/Dockerfile index a788651..558a967 100644 --- a/grav/Dockerfile +++ b/grav/Dockerfile @@ -1,4 +1,4 @@ -FROM php:8.2.12-apache-bullseye +FROM php:8.3.6-apache-bullseye LABEL maintainer="Andy Miller (@rhukster)" @@ -45,6 +45,7 @@ RUN { \ echo 'upload_max_filesize=128M'; \ echo 'post_max_size=128M'; \ echo 'expose_php=off'; \ + echo 'memory_limit=2048M'; \ } > /usr/local/etc/php/conf.d/php-recommended.ini RUN pecl channel-update pecl.php.net @@ -58,7 +59,7 @@ RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf RUN echo "Listen 8080" > /etc/apache2/ports.conf # Define Grav specific version of Grav or use latest stable -ARG GRAV_VERSION=1.7.43 +ARG GRAV_VERSION=1.7.45 ARG GRAV_SKELETON_URL=https://github.com/getgrav/grav/releases/download/$GRAV_VERSION/grav-admin-v$GRAV_VERSION.zip ARG GRAV_SKELETON_FOLDER=grav-admin #https://github.com/getgrav/grav-skeleton-gateway-site/releases/download/1.0.1/grav-skeleton-gateway-site+admin-1.0.1.zip @@ -90,4 +91,4 @@ VOLUME ["/var/www/html"] ENTRYPOINT ["/bin/sh", "/entrypoint.sh"] # CMD ["apache2-foreground"] -# CMD ["sh", "/entrypoint.sh"]pache2-foregroun \ No newline at end of file +# CMD ["sh", "/entrypoint.sh"]pache2-foregroun diff --git a/grav/entrypoint.sh b/grav/entrypoint.sh index b4f23ec..50ba009 100644 --- a/grav/entrypoint.sh +++ b/grav/entrypoint.sh @@ -7,14 +7,21 @@ ln -s "/vault/secrets/$GIT_VAULT_SECRET" "/var/www/html/user/config/plugins/git- bin/plugin git-sync init bin/plugin git-sync sync > /dev/null cd /var/www/html/user -git pull origin $HEAD_BRANCH +git fetch origin +git reset --hard origin/master echo "done" -echo "Creating admin user..." -cp "/vault/secrets/$ADMIN_VAULT_SECRET" /var/www/html/user/accounts/admin.yaml +if [ ! -f "/var/www/html/user/accounts/admin.yaml" ]; then + echo "Creating admin user..." + cp "/vault/secrets/$ADMIN_VAULT_SECRET" /var/www/html/user/accounts/admin.yaml + echo done +fi + +echo "Creating sre user..." +cp "/vault/secrets/$SRE_VAULT_SECRET" /var/www/html/user/accounts/sre.yaml echo done rm /var/www/html/user/config/security.yaml ln -s /vault/secrets/salt /var/www/html/user/config/security.yaml -apache2-foreground \ No newline at end of file +apache2-foreground diff --git a/init-grav/init.sh b/init-grav/init.sh index 45989c5..957c671 100644 --- a/init-grav/init.sh +++ b/init-grav/init.sh @@ -1,29 +1,34 @@ -#!/bin/sh -# copy-theme.sh +cd /var/www/ -THEMES_DIR=/var/www/html/user/themes - -echo " Copying theme..." +# GRAV_SKELETON_URL=https://github.com/getgrav/grav-skeleton-gateway-site/releases/download/1.0.1/grav-skeleton-gateway-site+admin-1.0.1.zip +# THEMES_DIR=/var/www/html/user/themes # Create the themes directory if it does not exist [ ! -d "$THEMES_DIR" ] && mkdir -p "$THEMES_DIR" - # Use rsync to copy the initial content if [ -z "$(ls -A "$THEMES_DIR")" ]; then - rsync -av /initial-content/ /var/www/html/ - # Change ownership of the copied content to www-data - chown -R 33:33 /var/www/html - # Install git-sync plugin - cd /var/www/html + echo " Copying theme..." + cd /var/www/html/ + wget "$GRAV_SKELETON_URL" -O theme.zip + unzip theme.zip + rm theme.zip + git clone https://github.com/getgrav/grav.git grav + # Install git-sync plugin bin/gpm install git-sync - # Configures git-sync plugin + # Configures git-sync plugin ln -s /vault/secrets/grav /var/www/html/user/config/plugins/git-sync.yaml else echo "Themes directory is not empty. Skipping copying initial content." fi if [ -z "$(ls -A /var/www/html/user/.git)" ]; then -echo "git not initialized, running init script..." + echo "git not initialized, running init script..." + cd /var/www/html/ + wget "$GRAV_SKELETON_URL" -O skeleton.zip + unzip skeleton.zip + # Install git-sync plugin + bin/gpm install git-sync + cd /var/www/html rm /var/www/html/user/config/plugins/git-sync.yaml ln -s "/vault/secrets/$GIT_VAULT_SECRET" "/var/www/html/user/config/plugins/git-sync.yaml" git config --global --add safe.directory /var/www/html/user diff --git a/mongo/Dockerfile b/mongo/Dockerfile new file mode 100644 index 0000000..500acf8 --- /dev/null +++ b/mongo/Dockerfile @@ -0,0 +1,7 @@ +FROM mongo:6-jammy + +ENV MONGO_INITDB_ROOT_USERNAME admin +ENV MONGO_INITDB_ROOT_PASSWORD secret +ENV MONGO_INITDB_DATABASE admin + +ADD mongo-init.js /docker-entrypoint-initdb.d/ diff --git a/mongo/mongo-init.js b/mongo/mongo-init.js new file mode 100755 index 0000000..ad1e5da --- /dev/null +++ b/mongo/mongo-init.js @@ -0,0 +1,16 @@ +db.auth(process.env.MONGO_INITDB_ROOT_USERNAME, process.env.MONGO_INITDB_ROOT_PASSWORD) + +db = db.getSiblingDB('admin') + +db.createUser({ + user: process.env.MONGO_USER, + pwd: process.env.MONGO_PASSWORD, + roles: [ + { + role: 'root', + db: 'admin', + }, + ], +}); + +db.dropUser(process.env.MONGO_INITDB_ROOT_USERNAME); \ No newline at end of file