Skip to content

Commit

Permalink
Merge pull request #1141 from linuxjuggler/feature/docker-dev
Browse files Browse the repository at this point in the history
Feature/docker dev
  • Loading branch information
chartjes authored May 4, 2018
2 parents 33cd2b0 + c00e489 commit 16c733c
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 8 deletions.
12 changes: 6 additions & 6 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM zaherg/php-and-nginx-xdebug:latest
FROM zaherg/php-and-nginx:latest

ARG BUILD_DATE
ARG DOCKER_REPO
Expand All @@ -7,7 +7,7 @@ ARG IMAGE_NAME
ARG VERSION

LABEL Maintainer="Zaher Ghaibeh <[email protected]>" \
Description="This is the docker image for OpenCFP." \
Description="This is the docker image for OpenCFP, a PHP-based conference talk submission system." \
org.label-schema.name=$IMAGE_NAME \
org.label-schema.description="This is the docker image for OpenCFP, a PHP-based conference talk submission system." \
org.label-schema.build-date=$BUILD_DATE \
Expand All @@ -20,7 +20,6 @@ LABEL Maintainer="Zaher Ghaibeh <[email protected]>" \
ENV CFP_ENV ${CFP_ENV:-development}
ENV CFP_DB_HOST ${CFP_DB_HOST:-"127.0.0.1"}
ENV CFP_DB_PASS ${CFP_DB_PASS:-root}
ENV PHP_XDEBUG_DEFAULT_ENABLE ${PHP_XDEBUG_DEFAULT_ENABLE:-0}

COPY ./ /var/www

Expand All @@ -29,10 +28,11 @@ RUN set -ex \
&& sed -i "s/\/web\/html/\/var\/www\/web/" /etc/nginx/nginx.conf && \
sed -i "s/localhost/_/" /etc/nginx/nginx.conf && \
sed -i "s/#user nobody;/user www-data;/" /etc/nginx/nginx.conf && \
sed -i "s/#gzip on;/gzip on;/" /etc/nginx/nginx.conf && \
touch /usr/local/etc/php/php.ini && \
echo "cgi.fix_pathinfo=0" >> /usr/local/etc/php/php.ini && \
echo "upload_max_filesize = 30M" >> /usr/local/etc/php/php.ini && \
echo "post_max_size = 30M" >> /usr/local/etc/php/php.ini && \
echo "upload_max_filesize = 120M" >> /usr/local/etc/php/php.ini && \
echo "post_max_size = 120M" >> /usr/local/etc/php/php.ini && \
echo "memory_limit = 512M" >> /usr/local/etc/php/php.ini && \
echo 'variables_order = "EGPCS"' >> /usr/local/etc/php/php.ini && \
sed -i -e "s/;catch_workers_output\s*=\s*yes/catch_workers_output = yes/g" /usr/local/etc/php-fpm.d/www.conf && \
Expand All @@ -41,7 +41,7 @@ RUN set -ex \
sed -i -e "s/pm.min_spare_servers = 1/pm.min_spare_servers = 2/g" /usr/local/etc/php-fpm.d/www.conf && \
sed -i -e "s/pm.max_spare_servers = 3/pm.max_spare_servers = 4/g" /usr/local/etc/php-fpm.d/www.conf && \
sed -i -e "s/pm.max_requests = 500/pm.max_requests = 200/g" /usr/local/etc/php-fpm.d/www.conf && \
mkdir /var/www/cache && \
mkdir -p /var/www/cache && \
mkdir -p /var/www/cache/testing/sessions /var/www/cache/production/sessions /var/www/cache/development/sessions \
/var/www/cache/testing/twig /var/www/cache/production/twig /var/www/cache/development/twig && \
chgrp -R www-data /var/lib/nginx /var/www/web/uploads /var/www/cache /var/www/log && \
Expand Down
1 change: 0 additions & 1 deletion .docker/build
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export IMAGE_NAME=opencfp/opencfp:$TAG && \
--file ./.docker/Dockerfile \
--build-arg VCS_REF=$COMMIT_HASH \
--build-arg DOCKER_REPO=$DOCKER_REPO \
--build-arg VERSION=$BITBUCKET_BUILD_NUMBER \
--build-arg IMAGE_NAME=$IMAGE_NAME \
--squash --force-rm --compress --rm \
-t $IMAGE_NAME .
75 changes: 75 additions & 0 deletions DOCKER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# [![OpenCFP Banner](docs/img/banner.png)](https://github.com/opencfp/opencfp)

OpenCFP is a PHP-based conference talk submission system.

---
## Using Docker for Development

Now that we have [Docker](https://docker.com) image that we can build, it is easy for us to setup a docker
development environment, you need to follow the following steps:

* You need to create a new `docker-compose.yml` file from our `docker-compos.yml.dist` file.

* Modify the `app.environment` section to look like the following:

```
environment:
- "CFP_ENV=development"
- "CFP_DB_HOST=database"
- "CFP_DB_PASS=root"
```

* Modify the `app.volumes` section to look like the following:

```
volumes:
- ./:/var/www
- ./config/docker.yml.dist:/var/www/config/development.yml
- ./.docker/script:/var/www/script
```

The most important section is the `app.volumes` section, as it will make sure that we share our code with the docker
container.

The following, will create a shared volume with the container, so any file you create in your code will automatically
copied over to the container.

```
- ./:/var/www
```

Meanwhile, The following will create a copy from our `docker.yml.dist` file and call it `development.yml` file within
the container, you can remove this line and create your own `.yml` file.

```
- ./config/docker.yml.dist:/var/www/config/development.yml
```

The last part, is the important one, as the scripts was written in `bash` mean while the docker image depends on `alpine`
to make sure it has a small size (about **270MB** in total), so we needs to copy over the docker specific files to the
container, and replace the one on the container.

```
- ./.docker/script:/var/www/script
```

This will not overwrite the original `script` files, but will make our liver easier and will make the scripts
compatible with `sh`.

## Run Docker

Now all you have to do is to run the following command:

```
$ docker-compose up -d
```

Which will automatically build the images for your if its not already built.

and to stop your containers you can run:

```
$ docker-compose down
```

_PS_: You can access MySQL in the same way we described in the Docker section.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ OpenCFP is a PHP-based conference talk submission system.
* [Compiling Frontend Assets](#compiling-frontend-assets)
* [Testing](#testing)
* [Troubleshooting](#troubleshooting)
* [Build Docker Image](#build-docker-image)


## [Features](#features)
Expand Down Expand Up @@ -447,5 +448,14 @@ docker run -e CFP_ENV=production -e CFP_DB_HOST=database -e CFP_DB_PASS=root --n
Where `database` is the name of the running database container.


### Access MySQL container

To access MySQL you can use the following information:

- **Host**: 127.0.0.1
- **User**: root
- **Password**: root (or the one you specified in docker-compose)


_PS_: You can always modify the file `docker-compose.yml.dist` and have your own setup.

6 changes: 5 additions & 1 deletion docker-compose.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ services:
- "3306:3306"
networks:
- backend

volumes:
- database:/var/lib/mysql

networks:
backend:

volumes:
database:

0 comments on commit 16c733c

Please sign in to comment.