-
Notifications
You must be signed in to change notification settings - Fork 402
feat(docker): application build via docker #2037
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v31.0.00
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,3 +38,5 @@ var/* | |
|
|
||
| # Ignore node_modules folder | ||
| node_modules | ||
|
|
||
| .phpactor.json | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| FROM php:8.2-apache | ||
|
|
||
| # 1. Install System Dependencies (Minimal required for Gibbon) | ||
| # TODO: Pin version in apt get install | ||
| RUN apt-get update && apt-get install -y \ | ||
| git \ | ||
| unzip \ | ||
| libicu-dev \ | ||
| libzip-dev \ | ||
| libpng-dev \ | ||
| libjpeg-dev \ | ||
| libfreetype6-dev \ | ||
| libxml2-dev \ | ||
| gettext \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # 2. Install PHP Extensions | ||
| RUN docker-php-ext-configure gd --with-freetype --with-jpeg \ | ||
| && docker-php-ext-install -j"$(nproc)" \ | ||
| mysqli \ | ||
| pdo_mysql \ | ||
| gd \ | ||
| zip \ | ||
| intl \ | ||
| xml \ | ||
| gettext \ | ||
| bcmath | ||
|
|
||
| # Enable Apache mod_rewrite | ||
| RUN a2enmod rewrite | ||
|
|
||
| # 3. Install Composer | ||
| COPY --from=composer:latest /usr/bin/composer /usr/bin/composer | ||
|
|
||
| WORKDIR /var/www/html | ||
|
|
||
| # 4. Clone Gibbon v31 (Latest Stable) | ||
| RUN git clone --depth 1 --branch v31.0.00 https://github.com/GibbonEdu/core.git . \ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this will bake in the Gibbon version 31 source code into the Docker image. For a local development environment, it would be better to mount the source code as a volume in docker-compose.yml. Any changes made to the source code can then be seen in your local Gibbon installation running as a Docker application. For a production deployment, baking in a specific version of Gibbon source code is correct, but the version number is still hard-coded. |
||
| && rm -rf .git | ||
|
|
||
| # 5. Install PHP Dependencies | ||
| RUN composer install --no-dev --optimize-autoloader | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another way is to install composer dependencies outside of the Docker build process by executing |
||
|
|
||
| # 6. Configure PHP for Gibbon (Upload limits, etc.) | ||
| RUN echo "upload_max_filesize = 50M" > /usr/local/etc/php/conf.d/gibbon.ini \ | ||
| && echo "post_max_size = 50M" >> /usr/local/etc/php/conf.d/gibbon.ini \ | ||
| && echo "max_input_vars = 5000" >> /usr/local/etc/php/conf.d/gibbon.ini \ | ||
| && echo "memory_limit = 256M" >> /usr/local/etc/php/conf.d/gibbon.ini | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The PHP environment values are hardcoded here. Instead, could have an external PHP config file with these values in it then mount this config file as a volume in docker-compose.yaml. |
||
|
|
||
| # 7. Permissions (Crucial for the Web Installer to work) | ||
| RUN chown -R www-data:www-data /var/www/html \ | ||
| && chmod -R 755 /var/www/html | ||
|
|
||
| CMD ["apache2-foreground"] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| version: "3.8" | ||
|
|
||
| services: | ||
| app: | ||
| ports: | ||
| - "8080:80" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| version: "3.8" | ||
|
|
||
| services: | ||
| app: | ||
| build: . | ||
| container_name: gibbon_app | ||
| depends_on: | ||
| - db | ||
| restart: always | ||
|
|
||
| db: | ||
| image: mysql:8.0 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The version of MySQL is hardcoded here. Could keep the version number in a .env file instead so it can be more easily configured. |
||
| container_name: gibbon_db | ||
| environment: | ||
| - MYSQL_DATABASE=${MYSQL_DATABASE:-gibbon} | ||
| - MYSQL_USER=${MYSQL_USER:-gibbon} | ||
| - MYSQL_PASSWORD=${MYSQL_PASSWORD:-gibbonpass} | ||
| - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-rootpass} | ||
| volumes: | ||
| - gibbon_db_data:/var/lib/mysql | ||
| # Native password plugin ensures PHP can connect easily | ||
| command: --default-authentication-plugin=mysql_native_password | ||
| restart: always | ||
|
|
||
| volumes: | ||
| gibbon_db_data: | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PHP version 8.2 is hard-coded into the Dockerfile here. In case developers want to use other PHP versions, might be better to declare a
PHP_VERSIONbuild time ARG variable and interpolate it into this FROM declaration. The value forPHP_VERSIONcan come from a .env file which is read in by docker-compose.yml.