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

Docker for local development #31

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.DS_Store
/data/*
!data/.gitkeep
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does this file need to be created? And how?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scroll up a bit. ;) First paragraph under "Setup"

In the compass directory, copy .env.example to .env and fill in the details.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


```
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

Expand Down
Empty file added data/.gitkeep
Empty file.
36 changes: 36 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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:
8 changes: 8 additions & 0 deletions docker/apache/000-default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<VirtualHost *:80>
ServerName localhost
DocumentRoot "/var/www/html/compass/public"
<Directory "/var/www/html/compass/public">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
26 changes: 26 additions & 0 deletions docker/apache/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions docker/build.sh
Original file line number Diff line number Diff line change
@@ -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

14 changes: 14 additions & 0 deletions docker/down.sh
Original file line number Diff line number Diff line change
@@ -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

14 changes: 14 additions & 0 deletions docker/start.sh
Original file line number Diff line number Diff line change
@@ -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