diff --git a/README.md b/README.md index 44d562a3..644230c0 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,15 @@ Copy config.sample.php to config.inc.php and modify connection details. Copy www/sample.htaccess to www/.htaccess and modify site path. +### Install with Docker + +1. Copy `config.sample.php` to `config.inc.php` and use recommended docker configs +2. Copy `www/sample.htaccess` to `www/.htaccess` and use recommended docker configs +3. Add `127.0.0.1 localhost.unl.edu` to `/etc/hosts` on your host machine +4. Run `docker-compose build` in the root directory to build the image for php +6. Run `docker-compose up` in the root directory to run the docker containers +7. Open GoURL in the browser using the URL [https://localhost.unl.edu:5507/](https://localhost.unl.edu:5507/) + ## About Originally based on lilURL: http://lilurl.sourceforge.net @@ -43,3 +52,4 @@ $shibSettings = array ( ); $auth = new \UNL\Templates\Auth\AuthModShib($shibSettings); ``` + diff --git a/data/goURL.sql b/data/goURL.sql index 62002a50..7f11ee32 100644 --- a/data/goURL.sql +++ b/data/goURL.sql @@ -13,6 +13,8 @@ SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; -- Database: `goURL` -- +USE goURL; + -- -------------------------------------------------------- -- diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..230ffcd7 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,55 @@ +version: '3.8' + +services: + app: + hostname: app + + # this is the URL to go to + domainname: localhost.unl.edu + build: + context: . + dockerfile: Dockerfile + args: + # Update 'VARIANT' to pick a version of PHP version: 8, 8.1, 8.0, 7, 7.4 + VARIANT: "7.4" + + # DIRROOT is where the files will be copied to in the docker container + DIRROOT: "/var/www/html" + + # DOCROOT is where the index.php is located typically the /www directory + DOCROOT: "/www" + + volumes: + - .:/var/www/html/:cached + + # this port on the left is also used in /www/.htaccess and config.inc.php + # Make sure all are the same + ports: + - "5507:80" + + depends_on: + - db + + stdin_open: true + tty: true + + command: sh -c "composer install && apachectl -D FOREGROUND" + + db: + image: mariadb:10.4 + restart: unless-stopped + volumes: + - mariadb-data:/var/lib/mysql + - ./data/goURL.sql:/data/application/init.sql + command: --init-file /data/application/init.sql + environment: + MYSQL_ROOT_PASSWORD: mariadb + MYSQL_DATABASE: goURL + MYSQL_USER: mariadb + MYSQL_PASSWORD: mariadb + + ports: + - "9906:3306" + +volumes: + mariadb-data: null \ No newline at end of file diff --git a/dockerfile b/dockerfile new file mode 100644 index 00000000..c13b3ea4 --- /dev/null +++ b/dockerfile @@ -0,0 +1,50 @@ +# [Choice] PHP version (use -bullseye variants on local arm64/Apple Silicon): 8, 8.1, 8.0, 7, 7.4, 7.3, 8-bullseye, 8.1-bullseye, 8.0-bullseye, 7-bullseye, 7.4-bullseye, 7.3-bullseye, 8-buster, 8.1-buster, 8.0-buster, 7-buster, 7.4-buster +ARG VARIANT="7.4" +FROM php:${VARIANT}-apache-bullseye + +# Install MariaDB client +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ + && apt-get install -y mariadb-client \ + && apt-get clean -y && rm -rf /var/lib/apt/lists/* + +RUN apt-get update && apt-get install -y libz-dev libmemcached-dev && \ + pecl install memcached && \ + docker-php-ext-enable memcached + +# install prerequisites +RUN apt-get update && apt-get install -y git zip unzip libpng-dev + + +# Install php-mysql driver +RUN docker-php-ext-install mysqli pdo pdo_mysql gd + + +# Install composer +RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer + +# removes error "Invalid command 'RewriteEngine'" +RUN a2enmod rewrite && service apache2 restart + +# changes the docroot so the domain points to the correct file +ARG DIRROOT="/var/www/html" +ARG DOCROOT="/www" +ENV APACHE_DOCUMENT_ROOT=${DIRROOT}${DOCROOT} +RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf +RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf + +WORKDIR ${DIRROOT} + +# can't do this since mounting the volume in the docker compose will remove the files made here +# COPY ./composer.json ${DIRROOT} +# RUN composer install + + +COPY . ${DIRROOT} + +# [Optional] Uncomment this section to install additional OS packages. +# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ +# && apt-get -y install --no-install-recommends + +# [Optional] Uncomment this line to install global node packages. +# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g " 2>&1 +