Skip to content

Commit

Permalink
Merge pull request #36 from City-of-Helsinki/UHF-11131
Browse files Browse the repository at this point in the history
UHF-11131: Alias to check helfi package statuses, build database sync script into oc image
  • Loading branch information
tuutti authored Dec 20, 2024
2 parents 8d2222b + d991109 commit 5644591
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 9 deletions.
3 changes: 3 additions & 0 deletions local/drupal/Makefile
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
5 changes: 5 additions & 0 deletions local/oc/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down
29 changes: 29 additions & 0 deletions local/oc/db-sync
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions local/oc/xdg-open
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#!/bin/sh
15 changes: 7 additions & 8 deletions openshift/drupal/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 && \
Expand Down
6 changes: 6 additions & 0 deletions openshift/drupal/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 #
###########
Expand Down
1 change: 0 additions & 1 deletion openshift/drupal/files/etc/profile
Original file line number Diff line number Diff line change
Expand Up @@ -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\] $ "
5 changes: 5 additions & 0 deletions openshift/drupal/files/etc/profile.d/aliases.sh
Original file line number Diff line number Diff line change
@@ -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'
1 change: 1 addition & 0 deletions openshift/drupal/files/etc/profile.d/ps1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export PS1="[${APP_ENV:-env}] \[\e[1;31m\][${HOSTNAME:-hostname}] \[\e[1;33m\]\w\[\e[0m\] $ "

0 comments on commit 5644591

Please sign in to comment.