From 0c492308745e30c7da0aedddf830d28b38d9045c Mon Sep 17 00:00:00 2001 From: Kenichi Ishigaki Date: Sat, 29 Apr 2023 17:25:59 +0900 Subject: [PATCH] Introduce a proof of concept of docker pause on centos 7 to find any issues if we upgrade dependencies --- cpanfile | 2 +- docker-compose.yml | 4 +- docker/app/Dockerfile.centos7 | 20 ++++++++ docker/app/docker-entrypoint.centos7.sh | 67 +++++++++++++++++++++++++ 4 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 docker/app/Dockerfile.centos7 create mode 100644 docker/app/docker-entrypoint.centos7.sh diff --git a/cpanfile b/cpanfile index 6a3eb4900..295a01693 100644 --- a/cpanfile +++ b/cpanfile @@ -28,7 +28,7 @@ requires 'JSON::XS'; requires 'LWP'; requires 'List::MoreUtils'; requires 'Log::Dispatch::Config'; -requires 'Log::Dispatchouli'; +requires 'Log::Dispatchouli', '== 2.023'; requires 'Mail::Send'; requires 'Module::Signature'; requires 'MojoX::Log::Dispatch::Simple'; diff --git a/docker-compose.yml b/docker-compose.yml index fa4e52661..6ec221b01 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -20,7 +20,9 @@ services: NGINX_HOST: ${NGINX_HOST} hostname: ${NGINX_HOST} app: - build: ./docker/app + build: + context: ./docker/app + dockerfile: Dockerfile.centos7 container_name: app ports: - 5000:5000 diff --git a/docker/app/Dockerfile.centos7 b/docker/app/Dockerfile.centos7 new file mode 100644 index 000000000..e15a67829 --- /dev/null +++ b/docker/app/Dockerfile.centos7 @@ -0,0 +1,20 @@ +FROM centos:7 +WORKDIR /home/k/pause +RUN yum install -y \ + make gcc curl perl perl-core ssh git gpg gpg-agent openssl unzip bzip2 ca-certificates crontabs rsyslog \ + openssl-devel zlib-devel expat-devel libxml2-devel mariadb-libs mariadb-devel which procps \ + mariadb \ + nano && \ + yum install -y https://rpms.remirepo.net/enterprise/remi-release-7.rpm && \ + yum install -y --enablerepo=remi golang && \ + go install github.com/mailhog/mhsendmail@latest && mv /root/go/bin/mhsendmail /usr/sbin/sendmail && \ + curl -skL --compressed https://git.io/cpm > cpm && \ + chmod +x cpm && mv cpm /usr/local/bin && \ + curl -skL --compressed https://cpanmin.us > cpanm && \ + chmod +x cpanm && mv cpanm /usr/local/bin && \ + cpanm -n IPC::Run Log::Dispatchouli@2.023 && \ + curl -skL https://raw.githubusercontent.com/andk/pause/master/cpanfile > cpanfile && \ +# cpm install -g + cpanm --installdeps -n . +COPY ./docker-entrypoint.centos7.sh / +ENTRYPOINT ["/docker-entrypoint.centos7.sh"] diff --git a/docker/app/docker-entrypoint.centos7.sh b/docker/app/docker-entrypoint.centos7.sh new file mode 100644 index 000000000..2cffe4cf2 --- /dev/null +++ b/docker/app/docker-entrypoint.centos7.sh @@ -0,0 +1,67 @@ +#!/bin/bash +set -e + +AUTH="-u ${MYSQL_USER} --password=${MYSQL_ROOT_PASSWORD}" +AUTH_DB="$AUTH ${MYSQL_DATABASE}" + +for i in 1 2 3 4 5 6 7 8 9 10 +do + mysqladmin -h mysql $AUTH ping > /dev/null 2>&1 && break + sleep 10 +done + +if ! mysql -h mysql $AUTH_DB -e 'SELECT 1 FROM abrakadabra' > /dev/null 2>&1; then + mysql -h mysql $AUTH_DB < ./doc/authen_pause.schema.txt +fi +if ! mysql -h mysql $AUTH_DB -e 'SELECT 1 FROM applymod' > /dev/null 2>&1; then + mysql -h mysql $AUTH_DB < ./doc/mod.schema.txt +fi + +cd /root +tar xf /root/gnupg.tar.gz +cp -R /root/gnupg/* /root/.gnupg/ +cd /home/k/pause +chmod 0600 /root/.gnupg/* +chmod 0600 /root/.gnupg/private-keys-v1.d +chmod 0600 /root/.gnupg/openpgp-revocs.d +chmod 0700 /root/.gnupg + +perl -Ilib ./docker/app/insert_fixture.pl + +if [ ! -d /home/ftp/incoming ]; then + mkdir /home/ftp/incoming +fi +if [ ! -d /home/ftp/run ]; then + mkdir /home/ftp/run +fi +if [ ! -d /home/ftp/pub/PAUSE ]; then + mkdir /home/ftp/pub/PAUSE +fi +if [ ! -d /home/ftp/pub/PAUSE/PAUSE-git ]; then + mkdir -p /home/ftp/pub/PAUSE/PAUSE-git + cd /home/ftp/pub/PAUSE/PAUSE-git + git config --global init.defaultBranch main + git init + git config --global --add safe.directory /home/ftp/pub/PAUSE/PAUSE-git + git config --global user.email "${FTP}" + git config --global user.name "PAUSE-git" + cd /home/k/pause +fi +if [ ! -d /home/ftp/pub/PAUSE/PAUSE-data ]; then + mkdir -p /home/ftp/pub/PAUSE/PAUSE-data +fi +if [ ! -d /home/ftp/pub/PAUSE/modules ]; then + mkdir -p /home/ftp/pub/PAUSE/modules +fi + +cpm install -g + +perl ./bin/paused --pidfile=/var/run/paused.pid & + +# Or cron won't run it... +chmod 0600 /var/spool/cron/crontabs/root + +exec rsyslogd & +exec crond & + +plackup ./app_2017.psgi