Skip to content
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

WIP Adding docker #82

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -43,3 +52,4 @@ $shibSettings = array (
);
$auth = new \UNL\Templates\Auth\AuthModShib($shibSettings);
```

2 changes: 2 additions & 0 deletions data/goURL.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
-- Database: `goURL`
--

USE goURL;

-- --------------------------------------------------------

--
Expand Down
55 changes: 55 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
50 changes: 50 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -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 <your-package-list-here>

# [Optional] Uncomment this line to install global node packages.
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1