diff --git a/.gitignore b/.gitignore index e43b0f9..73a7aa8 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ .DS_Store +/data/* +!data/.gitkeep diff --git a/README.md b/README.md index 83f6f43..ae3a1b7 100644 --- a/README.md +++ b/README.md @@ -153,6 +153,45 @@ Timestamps in Exif data do not include the timezone offset, and there is no stan This will query the database and find the closest matching location for when your clock read that time. +## Docker for local development (experimental) + +This repository comes with a bunch of shell scripts to get a local version of Compass running for development purposes. + +`./docker/start.sh` starts an apache webserver, a mysql database and a redis image +`./docker/build.sh` builds the containers without starting them +`./docker/down.sh` shuts down the containers + +You will still have to manually install Compass within these containers. When creating the `.env` file, the values are as follows: + +``` +BASE_URL=http://localhost/ + +DB_CONNECTION=mysql +DB_HOST=compass_db_1 +DB_PORT=3306 +DB_DATABASE=compass +DB_USERNAME=user +DB_PASSWORD=user + +QUEUE_DRIVER=redis +CACHE_DRIVER=redis + +REDIS_HOST=compass_redis_1 +``` + +The command line commands are a bit tricky, too: + +`docker exec -ti "compass_webserver_1" sh -c "cd compass && composer install"` + +runs the composer install, the `artisan` commands need to be run this way as well. For example the `key:generate` command: + +`docker exec -ti "compass_webserver_1" sh -c "cd compass && php artisan key:generate"` + +and the `migrate` command: + +`docker exec -ti "compass_webserver_1" sh -c "cd compass && php artisan migrate"` + + ## Credits diff --git a/data/.gitkeep b/data/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..4baa392 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,36 @@ +version: '3' + +services: + webserver: + build: ./docker/apache + restart: unless-stopped + depends_on: + - db + volumes: + - .:/var/www/html:cached + - ./data:/var/compass:cached + ports: + - ${portWebserver}:80 + db: + image: mysql:5.7 + restart: unless-stopped + volumes: + - db_data:/var/lib/mysql + - ./docker/tmp:/tmp + - ./docker/database:/docker-entrypoint-initdb.d/ + ports: + - ${portDatabase}:3306 + environment: + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: ${dbName} + MYSQL_USER: ${dbUser} + MYSQL_PASSWORD: ${dbPassword} + redis: + image: redis:5 + restart: unless-stopped + volumes: + - redis_data:/data + +volumes: + db_data: + redis_data: diff --git a/docker/apache/000-default.conf b/docker/apache/000-default.conf new file mode 100644 index 0000000..c1a7d84 --- /dev/null +++ b/docker/apache/000-default.conf @@ -0,0 +1,8 @@ + + ServerName localhost + DocumentRoot "/var/www/html/compass/public" + + AllowOverride All + Require all granted + + diff --git a/docker/apache/Dockerfile b/docker/apache/Dockerfile new file mode 100644 index 0000000..4cb60d1 --- /dev/null +++ b/docker/apache/Dockerfile @@ -0,0 +1,26 @@ +FROM php:7.1-apache-jessie + +RUN apt-get update --fix-missing + +RUN apt-get -y install sudo &&\ + apt-get -y install curl &&\ + apt-get -y install git &&\ + apt-get -y install zip unzip &&\ + apt-get -y install vim && \ + apt-get -y install libicu-dev + +RUN docker-php-ext-configure intl + +RUN docker-php-ext-install pdo pdo_mysql mysqli intl + +RUN curl -sS https://getcomposer.org/installer | php && chmod +x composer.phar && mv composer.phar /usr/local/bin/composer + + + +RUN a2enmod rewrite + +RUN echo "ServerName compass" | sudo tee /etc/apache2/conf-available/servername.conf && a2enconf servername + +COPY ./000-default.conf /etc/apache2/sites-enabled/000-default.conf + +RUN apachectl graceful \ No newline at end of file diff --git a/docker/build.sh b/docker/build.sh new file mode 100755 index 0000000..ab0aaf8 --- /dev/null +++ b/docker/build.sh @@ -0,0 +1,14 @@ +#!/bin/bash +export projectName='compass' + +export dbName=${projectName} +export dbUser='user' +export dbPassword='user' + + +export portWebserver='80' +export portDatabase='3306' + + +docker-compose -f docker-compose.yml -p ${projectName} build + diff --git a/docker/down.sh b/docker/down.sh new file mode 100755 index 0000000..c6b60f1 --- /dev/null +++ b/docker/down.sh @@ -0,0 +1,14 @@ +#!/bin/bash +export projectName='compass' + +export dbName=${projectName} +export dbUser='user' +export dbPassword='user' + + +export portWebserver='80' +export portDatabase='3306' + + +docker-compose -f docker-compose.yml -p ${projectName} down + diff --git a/docker/start.sh b/docker/start.sh new file mode 100755 index 0000000..1cf178f --- /dev/null +++ b/docker/start.sh @@ -0,0 +1,14 @@ +#!/bin/bash +export projectName='compass' + +export dbName=${projectName} +export dbUser='user' +export dbPassword='user' + + +export portWebserver='80' +export portDatabase='3306' + + +docker-compose -f docker-compose.yml -p ${projectName} up -d +