diff --git a/local/drupal/Makefile b/local/drupal/Makefile index c48e259..678ef14 100644 --- a/local/drupal/Makefile +++ b/local/drupal/Makefile @@ -1,6 +1,9 @@ PHONY := REPOSITORY = ghcr.io/city-of-helsinki/drupal-web +PHONY += all +all: push-php-dev push-php + PHONY += push-php84-dev push-php84-dev: $(call push_image,8.4-dev,84) diff --git a/local/oc/Dockerfile b/local/oc/Dockerfile index 3f4598e..6c4f28d 100644 --- a/local/oc/Dockerfile +++ b/local/oc/Dockerfile @@ -1,7 +1,12 @@ FROM alpine:3.20 ENV OC_TAG=openshift-clients-4.17.0-202409111134 + +# oc login --web uses xdg-open to open link in a browser and the command will fail. +COPY --chmod=744 xdg-open db-sync /usr/local/bin/ + RUN \ + apk add --no-cache rsync; \ apk add --no-cache --virtual .build-deps \ git \ gpgme-dev \ diff --git a/local/oc/db-sync b/local/oc/db-sync new file mode 100644 index 0000000..1154773 --- /dev/null +++ b/local/oc/db-sync @@ -0,0 +1,29 @@ +#!/bin/sh + +set -e + +if [ ! -n "$OC_PROJECT_NAME" ]; then + echo "OC_PROJECT_NAME not set." + exit 1; +fi + + +if ! oc whoami > /dev/null 2>&1; then + oc login --server=https://api.arodevtest.hel.fi:6443 --web --callback-port 8280 +fi +oc project ${OC_PROJECT_NAME} + +OC_POD_NAME=$(oc get pods -o name | grep drupal-cron | grep -v deploy) + +if [ ! -n "$OC_POD_NAME" ]; then + echo "Failed to parse pod name." + exit 1 +fi + +oc rsh $OC_POD_NAME rm -f /tmp/dump.sql.gz +oc rsh $OC_POD_NAME drush sql:dump --structure-tables-key=common \ + --extra-dump='--no-tablespaces --hex-blob' \ + --result-file=/tmp/dump.sql \ + --gzip + +oc rsync $OC_POD_NAME:/tmp/dump.sql.gz /app diff --git a/local/oc/xdg-open b/local/oc/xdg-open new file mode 100644 index 0000000..1a24852 --- /dev/null +++ b/local/oc/xdg-open @@ -0,0 +1 @@ +#!/bin/sh diff --git a/openshift/drupal/Dockerfile b/openshift/drupal/Dockerfile index c6894b5..56a22f0 100644 --- a/openshift/drupal/Dockerfile +++ b/openshift/drupal/Dockerfile @@ -25,17 +25,9 @@ RUN set -eux; \ jq \ tini -RUN \ - touch /etc/bash/ps1.sh && \ - echo 'export PS1="[${APP_ENV:-env}] \[\e[1;31m\][${HOSTNAME:-hostname}] \[\e[1;33m\]\w\[\e[0m\] $ "' | tee /etc/profile /etc/bash/ps1.sh - COPY --from=composer:latest /usr/bin/composer /usr/local/bin/ COPY --from=amazeeio/envplate:v1.0.3 /usr/local/bin/ep /usr/local/bin/ep -ENV PATH=${PATH}:/app/vendor/bin:/var/www/html/vendor/bin -ENV COMPOSER_HOME=/.composer -ENV ENV="/etc/profile" - # Fetch the required certificate for the Azure MySQL flexible server service ENV AZURE_SQL_SSL_CA_PATH=/usr/local/share/ca-certificates/DigiCertGlobalRootCA.crt.pem RUN wget https://dl.cacerts.digicert.com/DigiCertGlobalRootCA.crt.pem -O $AZURE_SQL_SSL_CA_PATH @@ -53,9 +45,16 @@ EXPOSE 8080 # Copy configuration files and scripts COPY files/ / +# Copy /etc/profile.d shell scripts to bash equivalent as well. +COPY files/etc/profile.d/ /etc/bash + RUN chmod +x /entrypoints/* && \ chmod +x /usr/local/bin/entrypoint +ENV PATH=${PATH}:/app/vendor/bin:/var/www/html/vendor/bin +ENV COMPOSER_HOME=/.composer +ENV ENV="/etc/profile" + RUN \ # Create missing nginx folder. mkdir -p /run/nginx && \ diff --git a/openshift/drupal/Makefile b/openshift/drupal/Makefile index 8f213e1..582718b 100644 --- a/openshift/drupal/Makefile +++ b/openshift/drupal/Makefile @@ -6,6 +6,12 @@ PHONY += help help: @echo -e "See README.md for usage" +########### +# all # +########### +PHONY += all +all: push-php-dev push-php + ########### # php-dev # ########### diff --git a/openshift/drupal/files/etc/profile b/openshift/drupal/files/etc/profile index dcdad3c..3ab9f08 100755 --- a/openshift/drupal/files/etc/profile +++ b/openshift/drupal/files/etc/profile @@ -31,4 +31,3 @@ for script in /etc/profile.d/*.sh ; do fi done unset script -export PS1="[${APP_ENV:-env}] \[\e[1;31m\][${HOSTNAME:-hostname}] \[\e[1;33m\]\w\[\e[0m\] $ " diff --git a/openshift/drupal/files/etc/profile.d/aliases.sh b/openshift/drupal/files/etc/profile.d/aliases.sh new file mode 100644 index 0000000..1b8ad3e --- /dev/null +++ b/openshift/drupal/files/etc/profile.d/aliases.sh @@ -0,0 +1,5 @@ +function helfi_check_packages { + composer show "drupal/helfi_*" $@ + composer show "drupal/hdbt*" $@ +} +alias helfi_check_package_status='helfi_check_packages --outdated' diff --git a/openshift/drupal/files/etc/profile.d/ps1.sh b/openshift/drupal/files/etc/profile.d/ps1.sh new file mode 100644 index 0000000..3a7a29a --- /dev/null +++ b/openshift/drupal/files/etc/profile.d/ps1.sh @@ -0,0 +1 @@ +export PS1="[${APP_ENV:-env}] \[\e[1;31m\][${HOSTNAME:-hostname}] \[\e[1;33m\]\w\[\e[0m\] $ "