Skip to content

Commit 44a6575

Browse files
Merge pull request #46 from 20uf/feat/improve-docker
Refactoring docker
2 parents 33f51ed + dffbd6d commit 44a6575

9 files changed

Lines changed: 174 additions & 98 deletions

File tree

Dockerfile

Lines changed: 0 additions & 55 deletions
This file was deleted.

Makefile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
DC=docker-compose
2+
RUN=$(DC) run --rm app
3+
4+
.DEFAULT_GOAL := help
5+
.PHONY: help start bash stop
6+
7+
help:
8+
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
9+
10+
start: ## Start the project
11+
start: build up vendor go_bash
12+
13+
bash: ## Go to the bash container of the application
14+
bash: go_bash
15+
16+
stop: ## Stop docker containers
17+
$(DC) kill
18+
19+
# Internal rules
20+
build:
21+
$(DC) build
22+
23+
up:
24+
$(DC) up -d
25+
26+
go_bash:
27+
@$(RUN) bash
28+
29+
vendor: composer.lock
30+
@$(RUN) composer install

README.md

Lines changed: 100 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
Certificationy CLI
2-
==================
1+
<p align="center">
2+
<img src="https://avatars0.githubusercontent.com/u/8029934?v=3&s=200">
3+
</p>
4+
5+
# Certificationy CLI
6+
> This is the CLI tool to train on certifications.
37
48
[![Build Status](https://secure.travis-ci.org/certificationy/certificationy-cli.png?branch=master)](http://travis-ci.org/certificationy/certificationy-cli)
59
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/cd3b6bc1-632e-491a-abfc-43edc390e1cc/mini.png)](https://insight.sensiolabs.com/projects/cd3b6bc1-632e-491a-abfc-43edc390e1cc)
610

7-
This is the CLI tool to train on certifications.
8-
911
# How it looks?
1012

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

2123
## With Docker and Docker compose
2224

23-
To install it, run the following commands (Docker must be installed on your system):
25+
### Install the project prerequisites
26+
The project has prerequisites:
27+
28+
- [Docker][docker] (1.12+)
29+
- [Docker-composer][docker-compose] (1.10+)
30+
- [GNU make][make]
31+
32+
To install Docker, refer to the official documentation for your operating system: https://docs.docker.com/engine/installation/.
33+
34+
Once Docker installed, to check its smooth running, run docker -v, you should get something like suit:
35+
36+
```
37+
$ docker -v
38+
Docker version 1.12.4, build 1564f02
39+
```
40+
> You must use the minimum version 1.12 of Docker.
41+
42+
To install the docker-composer, please also refer to the official documentation: https://docs.docker.com/compose/install/.
43+
44+
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:
2445

2546
```
26-
$ docker-compose up -d # Download, build and run Docker images
27-
$ sh docker-ssh # ssh into local docker instance"
28-
$ php certificationy.php # Run Certificationy CLI
29-
$ exit # To exit bash docker
47+
$ docker-compose -v
48+
Docker-composer version 1.10.0, build 4bd6f1a
49+
```
50+
51+
> You must use the docker-compose version 1.10 minimum.
52+
53+
A makefile allows you to manipulate the container simply and easily.
54+
You have to be able to run `make -v`, which you are ready to choose:
55+
56+
```
57+
$ make -v
58+
GNU Make 4.1
59+
Built for x86_64-pc-linux-gnu
60+
Copyright (C) 1988-2014 Free Software Foundation, Inc.
61+
GPLv3 + license: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
62+
This is free software: you are allowed to modify and redistribute.
63+
There is NO WARRANTY, to the extent of the will of the law.
64+
```
65+
66+
> ** Note **: If you are using Windows, we strongly recommend that you use the Linux console included in
67+
> Windows 10 (https://msdn.microsoft.com/en-us/commandline/wsl/install_guide) or to use an emulator for
68+
> Command to be able to use `make` which will greatly facilitate the work.
69+
70+
### Using the Container
71+
72+
You should then be able to run `make` which will show you using the Makefile:
73+
74+
```
75+
$ make
76+
start: Start the project
77+
bash: Go to the bash container of the application
78+
stop: Stop docker containers
79+
```
80+
81+
Start the application with `make start`:
82+
83+
```
84+
$make start
85+
docker-compose build
86+
Building app
87+
Step 1/19 : FROM php:7.1-fpm-alpine
88+
7.1-fpm-alpine: Pulling from library/php
89+
... # pulling image
90+
Successfully built 22ab66e58936
91+
Successfully tagged certificationycli_app:latest
92+
docker-compose up -d
93+
Recreating certificationycli_app_1
94+
docker exec -i -t 6929cb80f7a7df579910341c74208e05d6d5548900488c35b41c281da9fe940e /bin/bash
95+
bash-4.3#
96+
```
97+
98+
Once the procedure is complete you can already use the bash of the container.
99+
Run Certificationy CLI;
100+
101+
```
102+
$ php certificationy.php
103+
```
104+
105+
To exit bash docker
106+
107+
```
108+
$ exit
109+
```
110+
111+
Stop the application with `make stop`:
112+
113+
```
114+
$ make stop
115+
docker-compose kill
116+
Killing certificationycli_app_1 ... done
30117
```
31118

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

82169
> Note: if you pass --list [-l] then you will ONLY get the category list, regarding your other settings
170+
171+
[docker]: https://www.docker.com
172+
[docker-compose]: https://docs.docker.com/compose/install/
173+
[make]: https://www.gnu.org/software/make/

docker-compose.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
version: '2'
22

33
services:
4-
php:
5-
build: .
6-
environment:
7-
SYMFONY_ENV: dev
8-
volumes:
9-
- ./:/srv/certificationy
4+
app:
5+
build:
6+
context: docker/7.1
7+
environment:
8+
SYMFONY_ENV: dev
9+
volumes:
10+
- ./:/app

docker-ssh

Lines changed: 0 additions & 11 deletions
This file was deleted.

docker/7.1/Dockerfile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
FROM php:7.1-fpm-alpine
2+
3+
RUN apk add --no-cache --virtual .persistent-deps \
4+
bash \
5+
git \
6+
icu-libs \
7+
zlib \
8+
wget \
9+
ca-certificates \
10+
curl
11+
12+
RUN set -xe \
13+
&& apk add --no-cache --virtual .build-deps \
14+
$PHPIZE_DEPS \
15+
icu-dev \
16+
zlib-dev \
17+
&& docker-php-ext-install \
18+
intl \
19+
zip \
20+
&& apk del .build-deps
21+
22+
# https://getcomposer.org/doc/03-cli.md#composer-allow-superuser
23+
ENV COMPOSER_ALLOW_SUPERUSER 1
24+
25+
WORKDIR /app
26+
27+
COPY php.ini /usr/local/etc/php/php.ini
28+
29+
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && \
30+
composer global require "hirak/prestissimo:^0.3" --prefer-dist --no-progress --no-suggest --optimize-autoloader --classmap-authoritative \
31+
&& composer clear-cache
32+
33+
COPY start.sh /usr/local/bin/docker-app-start
34+
35+
RUN chmod +x /usr/local/bin/docker-app-start
36+
37+
CMD ["docker-app-start"]
File renamed without changes.
File renamed without changes.

docker/php/install-composer.sh

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)