Skip to content

Commit

Permalink
Merge pull request #46 from 20uf/feat/improve-docker
Browse files Browse the repository at this point in the history
Refactoring docker
  • Loading branch information
mickaelandrieu authored Jun 22, 2017
2 parents 33f51ed + dffbd6d commit 44a6575
Show file tree
Hide file tree
Showing 9 changed files with 174 additions and 98 deletions.
55 changes: 0 additions & 55 deletions Dockerfile

This file was deleted.

30 changes: 30 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
DC=docker-compose
RUN=$(DC) run --rm app

.DEFAULT_GOAL := help
.PHONY: help start bash stop

help:
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'

start: ## Start the project
start: build up vendor go_bash

bash: ## Go to the bash container of the application
bash: go_bash

stop: ## Stop docker containers
$(DC) kill

# Internal rules
build:
$(DC) build

up:
$(DC) up -d

go_bash:
@$(RUN) bash

vendor: composer.lock
@$(RUN) composer install
109 changes: 100 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
Certificationy CLI
==================
<p align="center">
<img src="https://avatars0.githubusercontent.com/u/8029934?v=3&s=200">
</p>

# Certificationy CLI
> This is the CLI tool to train on certifications.
[![Build Status](https://secure.travis-ci.org/certificationy/certificationy-cli.png?branch=master)](http://travis-ci.org/certificationy/certificationy-cli)
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/cd3b6bc1-632e-491a-abfc-43edc390e1cc/mini.png)](https://insight.sensiolabs.com/projects/cd3b6bc1-632e-491a-abfc-43edc390e1cc)

This is the CLI tool to train on certifications.

# How it looks?

![Certificationy application](https://cloud.githubusercontent.com/assets/1247388/17698070/434e3944-63b9-11e6-80c6-91706dbbea50.png "Certificationy application")
Expand All @@ -20,13 +22,98 @@ $ php certificationy.php

## With Docker and Docker compose

To install it, run the following commands (Docker must be installed on your system):
### Install the project prerequisites
The project has prerequisites:

- [Docker][docker] (1.12+)
- [Docker-composer][docker-compose] (1.10+)
- [GNU make][make]

To install Docker, refer to the official documentation for your operating system: https://docs.docker.com/engine/installation/.

Once Docker installed, to check its smooth running, run docker -v, you should get something like suit:

```
$ docker -v
Docker version 1.12.4, build 1564f02
```
> You must use the minimum version 1.12 of Docker.
To install the docker-composer, please also refer to the official documentation: https://docs.docker.com/compose/install/.

Once docker-composes installed (install it globally to be able and access from anywhere), to check its proper functioning, run docker-compose -v, you should get something like suit:

```
$ docker-compose up -d # Download, build and run Docker images
$ sh docker-ssh # ssh into local docker instance"
$ php certificationy.php # Run Certificationy CLI
$ exit # To exit bash docker
$ docker-compose -v
Docker-composer version 1.10.0, build 4bd6f1a
```

> You must use the docker-compose version 1.10 minimum.
A makefile allows you to manipulate the container simply and easily.
You have to be able to run `make -v`, which you are ready to choose:

```
$ make -v
GNU Make 4.1
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2014 Free Software Foundation, Inc.
GPLv3 + license: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are allowed to modify and redistribute.
There is NO WARRANTY, to the extent of the will of the law.
```

> ** Note **: If you are using Windows, we strongly recommend that you use the Linux console included in
> Windows 10 (https://msdn.microsoft.com/en-us/commandline/wsl/install_guide) or to use an emulator for
> Command to be able to use `make` which will greatly facilitate the work.
### Using the Container

You should then be able to run `make` which will show you using the Makefile:

```
$ make
start: Start the project
bash: Go to the bash container of the application
stop: Stop docker containers
```

Start the application with `make start`:

```
$make start
docker-compose build
Building app
Step 1/19 : FROM php:7.1-fpm-alpine
7.1-fpm-alpine: Pulling from library/php
... # pulling image
Successfully built 22ab66e58936
Successfully tagged certificationycli_app:latest
docker-compose up -d
Recreating certificationycli_app_1
docker exec -i -t 6929cb80f7a7df579910341c74208e05d6d5548900488c35b41c281da9fe940e /bin/bash
bash-4.3#
```

Once the procedure is complete you can already use the bash of the container.
Run Certificationy CLI;

```
$ php certificationy.php
```

To exit bash docker

```
$ exit
```

Stop the application with `make stop`:

```
$ make stop
docker-compose kill
Killing certificationycli_app_1 ... done
```

## More run options
Expand Down Expand Up @@ -80,3 +167,7 @@ $ php certificationy.php start --number=5 --hide-multiple-choice "Automated test
* Only get questions from category "Automated tests" and "Bundles"

> Note: if you pass --list [-l] then you will ONLY get the category list, regarding your other settings
[docker]: https://www.docker.com
[docker-compose]: https://docs.docker.com/compose/install/
[make]: https://www.gnu.org/software/make/
13 changes: 7 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
version: '2'

services:
php:
build: .
environment:
SYMFONY_ENV: dev
volumes:
- ./:/srv/certificationy
app:
build:
context: docker/7.1
environment:
SYMFONY_ENV: dev
volumes:
- ./:/app
11 changes: 0 additions & 11 deletions docker-ssh

This file was deleted.

37 changes: 37 additions & 0 deletions docker/7.1/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM php:7.1-fpm-alpine

RUN apk add --no-cache --virtual .persistent-deps \
bash \
git \
icu-libs \
zlib \
wget \
ca-certificates \
curl

RUN set -xe \
&& apk add --no-cache --virtual .build-deps \
$PHPIZE_DEPS \
icu-dev \
zlib-dev \
&& docker-php-ext-install \
intl \
zip \
&& apk del .build-deps

# https://getcomposer.org/doc/03-cli.md#composer-allow-superuser
ENV COMPOSER_ALLOW_SUPERUSER 1

WORKDIR /app

COPY php.ini /usr/local/etc/php/php.ini

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && \
composer global require "hirak/prestissimo:^0.3" --prefer-dist --no-progress --no-suggest --optimize-autoloader --classmap-authoritative \
&& composer clear-cache

COPY start.sh /usr/local/bin/docker-app-start

RUN chmod +x /usr/local/bin/docker-app-start

CMD ["docker-app-start"]
File renamed without changes.
File renamed without changes.
17 changes: 0 additions & 17 deletions docker/php/install-composer.sh

This file was deleted.

0 comments on commit 44a6575

Please sign in to comment.