aspendigital / docker-octobercms

Dockerized October CMS: PHP, Composer, October core and dependencies
MIT License
150 stars 54 forks source link

Google Cloud Run Dockerfile version? #50

Open AntonieGeerts opened 3 years ago

AntonieGeerts commented 3 years ago

Hey Guys,

Great job! Any chance you will create a dockerfile version for deployment to Google Cloud Run in the future?

AntonieGeerts commented 3 years ago

See below a kinda working version to use with Google Cloud Run, just not able to find the "backend" :

`FROM php:7.4-apache

RUN apt-get update && apt-get install -y cron git-core jq unzip vim zip \ libjpeg-dev libpng-dev libpq-dev libsqlite3-dev libwebp-dev libzip-dev && \ rm -rf /var/lib/apt/lists/* && \ docker-php-ext-configure zip --with-zip && \ docker-php-ext-configure gd --with-jpeg --with-webp && \ docker-php-ext-install exif gd mysqli opcache pdo_pgsql pdo_mysql zip

RUN { \ echo 'opcache.memory_consumption=128'; \ echo 'opcache.interned_strings_buffer=8'; \ echo 'opcache.max_accelerated_files=4000'; \ echo 'opcache.revalidate_freq=2'; \ echo 'opcache.fast_shutdown=1'; \ echo 'opcache.enable_cli=1'; \ } > /usr/local/etc/php/conf.d/docker-oc-opcache.ini

RUN { \ echo 'log_errors=on'; \ echo 'display_errors=off'; \ echo 'upload_max_filesize=32M'; \ echo 'post_max_size=32M'; \ echo 'memory_limit=128M'; \ } > /usr/local/etc/php/conf.d/docker-oc-php.ini

ENV COMPOSER_ALLOW_SUPERUSER=1

RUN curl -sS https://getcomposer.org/installer | php -- --1 --install-dir=/usr/local/bin --filename=composer && \ /usr/local/bin/composer global require hirak/prestissimo

RUN a2enmod rewrite

COPY config/docker /usr/src/octobercms-config-docker

ENV OCTOBERCMS_TAG v1.0.473 ENV OCTOBERCMS_CHECKSUM f8667a36d1c23a761e5b7a5e2f362e44d0e754e8 ENV OCTOBERCMS_CORE_BUILD 473 ENV OCTOBERCMS_CORE_HASH 652ebd026445ccaeb3ba083f00830dc0 ENV COMPOSER_MEMORY_LIMIT=-1 ENV PORT=80 ENV CMS_LINK_POLICY=secure RUN git clone https://github.com/octobercms/october.git -b $OCTOBERCMS_TAG --depth 1 . && \ echo "Update composer.json: Set explicit build references for october module dependencies" && \ sed -i.orig "s/(\"october\/([rain|system|backend|cms])\": \"(~1.0)\")/\"october\/\2\": \"<=${OCTOBERCMS_TAG#v}\"/g" composer.json && \ egrep -o "['\"]october\/[rain|system|backend|cms]['\"]\s:\s'\"['\"]" composer.json && \ composer install --no-interaction --prefer-dist --no-scripts && \ composer clearcache && \ git status && git checkout modules/. && \ rm -rf .git && \ echo 'APP_ENV=docker' > .env && \ mv /usr/src/octobercms-config-docker config/docker && \ touch storage/database.sqlite && \ chmod 666 storage/database.sqlite && \ php artisan october:up && \ php artisan plugin:install october.drivers && \ chown -R www-data:www-data /var/www/html && \ find . -type d ( -path './plugins' -or -path './storage' -or -path './themes' -or -path './plugins/' -or -path './storage/' -or -path './themes/*' ) -exec chmod g+ws {} \;

RUN php -r "use System\Models\Parameter; \ require DIR.'/bootstrap/autoload.php'; \ \$app = require_once DIR.'/bootstrap/app.php'; \ \$app->make('Illuminate\Contracts\Console\Kernel')->bootstrap(); \ Parameter::set(['system::core.build'=>getenv('OCTOBERCMS_CORE_BUILD'), 'system::core.hash'=>getenv('OCTOBERCMS_CORE_HASH')]); \ echo \"October CMS \n Build: \",Parameter::get('system::core.build'), \"\n Hash: \", Parameter::get('system::core.hash'), \"\n\";"

RUN echo " * /usr/local/bin/php /var/www/html/artisan schedule:run > /proc/1/fd/1 2>/proc/1/fd/2" > /etc/cron.d/october-cron && \ crontab /etc/cron.d/october-cron

RUN echo 'exec php artisan "$@"' > /usr/local/bin/artisan && \ echo 'exec php artisan tinker' > /usr/local/bin/tinker && \ echo '[ $# -eq 0 ] && exec php artisan october || exec php artisan october:"$@"' > /usr/local/bin/october && \ sed -i '1s;^;#!/bin/bash\n[ "$PWD" != "/var/www/html" ] \&\& echo " - Helper must be run from /var/www/html" \&\& exit 1\n;' /usr/local/bin/artisan /usr/local/bin/tinker /usr/local/bin/october && \ chmod +x /usr/local/bin/artisan /usr/local/bin/tinker /usr/local/bin/october

COPY docker-oc-entrypoint /usr/local/bin/

RUN sed -i 's/80/${PORT}/g' $APACHE_CONFDIR/conf-available/docker-oc-apache.conf

EXPOSE 80 ENTRYPOINT ["docker-oc-entrypoint"] CMD ["apache2-foreground"] `