-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a604327
Showing
96 changed files
with
4,298 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php | ||
|
||
$runner->addTestsFromDirectory(__DIR__.'/tests/'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
command=phpcs | ||
standard=vendor/m6web/symfony2-coding-standard/Symfony2 | ||
standard=Symfony2 | ||
verbose=true | ||
# only-git-changed=true | ||
|
||
src/ | ||
!test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"services": [ | ||
{ | ||
"type": "php", | ||
"localPath": "./", | ||
"dockerSync": false, | ||
"options": { | ||
"version": "7.1", | ||
"cliOnly": true, | ||
"config": { | ||
"phar.readonly": "0" | ||
} | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.docker-arch/ | ||
vendor/ | ||
bin/atoum | ||
bin/coke | ||
bin/php* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
language: php | ||
|
||
php: | ||
- 7.0 | ||
- 7.1 | ||
|
||
before_script: | ||
- phpenv config-rm xdebug.ini # disable xdebug | ||
- wget http://getcomposer.org/composer.phar | ||
- php composer.phar install --prefer-dist --no-interaction | ||
|
||
script: | ||
- make lint test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.PHONY: test lint | ||
|
||
lint: | ||
vendor/bin/coke | ||
|
||
test: | ||
vendor/bin/atoum |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Docker Arch | ||
|
||
## Local installation | ||
|
||
``` | ||
curl -O -sL https://github.com/Ph3nol/Docker-Arch/raw/master/dist/docker-arch.phar | ||
chmod +x docker-arch.phar | ||
mv docker-arch.phar /usr/local/bin/docker-arch | ||
``` | ||
|
||
Note: for information, there is no stable release for instant, work is in progress. | ||
|
||
## Docker installation | ||
|
||
From dedicated [Docker image](https://hub.docker.com/r/ph3nol/docker-arch/). | ||
|
||
``` | ||
docker pull ph3nol/docker-arch | ||
docker run -it -v $(pwd):/destination ph3nol/docker-arch build /destination | ||
``` | ||
|
||
Build from local library Dockerfile: | ||
|
||
``` | ||
docker build --force-rm --no-cache -t ph3nol/docker-arch ./docker/phar/ | ||
``` | ||
|
||
## Docker Arch JSON file configuration | ||
|
||
[See some projects configurations examples](examples/). | ||
|
||
## Development | ||
|
||
``` | ||
docker build --force-rm --no-cache -t ph3nol/docker-arch-local ./docker/local/ | ||
docker run -it -v /path/to/the/docker-arch/library:/app -v $(pwd):/destination ph3nol/docker-arch-local php | ||
docker run -it -v /path/to/the/docker-arch/library:/app -v $(pwd):/destination ph3nol/docker-arch-local composer | ||
docker run -it -v /path/to/the/docker-arch/library:/app -v $(pwd):/destination ph3nol/docker-arch-local bin/docker-arch build /destination | ||
docker run -it -v /path/to/the/docker-arch/library:/app -v $(pwd):/destination ph3nol/docker-arch-local composer build-phar | ||
``` | ||
|
||
## To do | ||
|
||
* Improve README and documentation | ||
* Implement a UI to generate JSON configuration, with all possible options | ||
* Add `.docker-arch.json` generation (from `docker-arch init`) | ||
* Publish official Docker ph3nol/docker-arch image | ||
* Add some services (ElasticSearch, RabbitMQ, MongoDB, etc.) | ||
* Write fucking unit Tests (Atoum powered) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
.SILENT: | ||
|
||
OS := $(shell uname) | ||
|
||
create-volumes: | ||
{% if generator.project.dockerSynchedServices|length %} | ||
{% for serviceGenerator in generator.servicesGenerators if serviceGenerator.service.isDockerSynched == true %} | ||
docker volume create --name=docker-arch-{{ serviceGenerator.service.identifier }}-sync | ||
{% endfor %} | ||
{% endif %} | ||
|
||
init-sync: | ||
{% if generator.project.dockerSynchedServices|length %} | ||
make create-volumes | ||
docker-sync start | ||
{% endif %} | ||
|
||
init: | ||
ifeq ($(OS),Darwin) | ||
make init-sync | ||
docker-compose up --build -d | ||
else | ||
docker-compose up --build -d | ||
endif | ||
|
||
start: | ||
ifeq ($(OS),Darwin) | ||
make create-volumes | ||
make init-sync | ||
docker-compose up -d | ||
else | ||
docker-compose up -d | ||
endif | ||
|
||
start-all: | ||
ifeq ($(OS),Darwin) | ||
make create-volumes | ||
make init-sync | ||
docker-compose up -d | ||
else | ||
docker-compose up -d | ||
endif | ||
|
||
stop: | ||
{% if generator.project.dockerSynchedServices|length %} | ||
ifeq ($(OS),Darwin) | ||
docker-compose stop | ||
docker-sync stop | ||
else | ||
docker-compose stop | ||
endif | ||
{% else %} | ||
docker-compose stop | ||
{% endif %} | ||
|
||
clean: | ||
docker-compose rm --stop --force | ||
# docker stop $(docker ps -a -q) | ||
# docker rm --force $(docker ps -a -q) | ||
{% if generator.project.dockerSynchedServices|length %} | ||
ifeq ($(OS),Darwin) | ||
docker-sync clean | ||
endif | ||
{% endif %} | ||
docker volume prune |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
{% set dockerContainer = service.dockerContainer %} | ||
# This Dockerfile has been generated by {{ constant('\\Ph3\\DockerArch\\Application\\Architect::TYPE_PROJECT_NAME') }} open source project. | ||
|
||
# -------------------------- !!! DO NOT UPDATE THIS FILE !!! -------------------------- | ||
# -------------------------- !!! DO NOT UPDATE THIS FILE !!! -------------------------- | ||
# -------------------------- !!! DO NOT UPDATE THIS FILE !!! -------------------------- | ||
|
||
# To make changes, update your project .{{ constant('\\Ph3\\DockerArch\\Application\\Architect::TYPE_PROJECT_CONFIG_FILENAME') }} file, | ||
# and generate your new Docker configuration. | ||
|
||
####################################################################################### | ||
|
||
# {{ service.identifier }} Dockerfile... | ||
|
||
{% if dockerContainer.from %} | ||
FROM {{ dockerContainer.from }} | ||
{% endif %} | ||
LABEL maintainer="{{ dockerContainer.maintainer|raw }}" | ||
# MAINTAINER {{ dockerContainer.maintainer|raw }} # Deprecated | ||
{# ----------------------------------------------------- To-copy entries (COPY part) #} | ||
{% if dockerContainer.copyEntries|length %} | ||
|
||
# Copy some entries. | ||
{% endif %} | ||
{% for entryFrom, entryTo in dockerContainer.copyEntries %} | ||
COPY {{ entryFrom }} {{ entryTo }} | ||
{% endfor %} | ||
{# ----------------------------------------------------- Packages (RUN apt-get part) #} | ||
{% if dockerContainer.updatePackagesSources %} | ||
|
||
# Update APT sources. | ||
RUN set -xe && \ | ||
apt-get update | ||
{% endif %} | ||
{% if dockerContainer.packages|length %} | ||
|
||
# Install package from APT. | ||
RUN apt-get install -y {{ dockerContainer.packages|join(" \\\n ") }} | ||
{% endif %} | ||
{# ----------------------------------------------------- Commands (RUN part) #} | ||
{% if dockerContainer.commands|length %} | ||
|
||
# Let's run some commands, in order to install, configure and customize the container. | ||
{% endif %} | ||
{% for command in dockerContainer.commands %} | ||
RUN {{ command|raw }} | ||
{% endfor %} | ||
{# ----------------------------------------------------- Environment globals (ENV part) #} | ||
{% if dockerContainer.envs|length %} | ||
|
||
# Let's run some env globals. | ||
{% endif %} | ||
{% for env, value in dockerContainer.envs %} | ||
ENV {{ env }} {{ value }} | ||
{% endfor %} | ||
{# ----------------------------------------------------- Working directory (WORKDIR) #} | ||
{% if dockerContainer.workingDir %} | ||
|
||
# Working directory. | ||
WORKDIR {{ dockerContainer.workingDir }} | ||
{% endif %} | ||
{# ----------------------------------------------------- Entry point (ENTRYPOINT) #} | ||
{% if dockerContainer.entryPoint %} | ||
|
||
# Entry point. | ||
ENTRYPOINT {{ dockerContainer.entryPoint }} | ||
{% endif %} | ||
{# ----------------------------------------------------- Done #} | ||
|
||
# ... done for {{ service.identifier }}! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
{% set dockerSyncRequired = (generator.project.dockerSynchedServices|length > 0) %} | ||
|
||
#!/bin/bash | ||
|
||
INITIAL_DIR=$PWD | ||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
DOCKER_COMPOSE_COMMAND="docker-compose" | ||
DOCKER_SYNC_COMMAND="docker-sync" | ||
|
||
cd "$DIR" | ||
|
||
usage () { | ||
echo "Usage : $0 (build|start|shell|dc|stop|clean)" | ||
} | ||
|
||
terminate () { | ||
cd $INITIAL_DIR | ||
} | ||
|
||
{% if dockerSyncRequired %} | ||
create_volumes () { | ||
{% for serviceGenerator in generator.servicesGenerators if serviceGenerator.service.isDockerSynched == true %} | ||
docker volume create --name=docker-arch-{{ serviceGenerator.service.identifier }}-sync | ||
{% endfor %} | ||
} | ||
{% endif %} | ||
|
||
build () { | ||
{% if dockerSyncRequired %} | ||
create_volumes | ||
$DOCKER_SYNC_COMMAND start | ||
{% endif %} | ||
$DOCKER_COMPOSE_COMMAND up --build -d | ||
terminate | ||
} | ||
|
||
start () { | ||
{% if dockerSyncRequired %} | ||
create_volumes | ||
$DOCKER_SYNC_COMMAND start | ||
{% endif %} | ||
$DOCKER_COMPOSE_COMMAND up -d | ||
terminate | ||
} | ||
|
||
compose () { | ||
$DOCKER_COMPOSE_COMMAND ${@:2} | ||
terminate | ||
} | ||
|
||
shell () { | ||
if [ $# -lt 2 ]; then | ||
echo "You must given an instance name, from available (UP) ones:" | ||
echo "" | ||
$DOCKER_COMPOSE_COMMAND ps | ||
echo "" | ||
echo "Example: $0 $1 <name>" | ||
terminate | ||
fi | ||
|
||
$DOCKER_COMPOSE_COMMAND exec $2 bash | ||
terminate | ||
} | ||
|
||
stop () { | ||
{% if dockerSyncRequired %} | ||
$DOCKER_SYNC_COMMAND stop | ||
$DOCKER_COMPOSE_COMMAND stop | ||
{% endif %} | ||
$DOCKER_COMPOSE_COMMAND stop | ||
terminate | ||
} | ||
|
||
clean () { | ||
$DOCKER_COMPOSE_COMMAND rm --stop --force | ||
# docker stop $(docker ps -a -q) | ||
# docker rm --force $(docker ps -a -q) | ||
{% if dockerSyncRequired %} | ||
$DOCKER_SYNC_COMMAND clean | ||
{% endif %} | ||
docker volume prune | ||
terminate | ||
} | ||
|
||
case "$1" in | ||
|
||
build) build | ||
;; | ||
start) start | ||
;; | ||
dc) compose $* | ||
;; | ||
shell) shell $* | ||
;; | ||
stop) stop | ||
;; | ||
clean) clean | ||
;; | ||
*) usage | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
version: "3" | ||
{# ----------------------------------------------------- Volumes #} | ||
{% if project.dockerSynchedServices|length %} | ||
|
||
volumes: | ||
{% endif %} | ||
{% for service in project.dockerSynchedServices %} | ||
docker-arch-{{ service.identifier }}-sync: | ||
external: true | ||
{% endfor %} | ||
{# ----------------------------------------------------- Services #} | ||
|
||
services: | ||
{% for service in project.services %} | ||
{{ service.identifier }}: | ||
{# ----------------------------------------------------- Instance specific build and name #} | ||
container_name: {{ service.identifier }} | ||
build: ./{{ service.identifier }} | ||
{% set links = project.getLinksForService(service) %} | ||
{% if links|length %} | ||
{# ----------------------------------------------------- Links #} | ||
links: | ||
{% for link in links %} | ||
- {{ link }} | ||
{% endfor %} | ||
{% endif %} | ||
{% set volumes = project.getVolumesForService(service) %} | ||
{% if volumes|length %} | ||
{# ----------------------------------------------------- Volumes #} | ||
volumes: | ||
{% for volume in volumes %} | ||
- {{ volume.local }}:{{ volume.remote }}{% if volume.type|default(null) %}:{{ volume.type }}{% endif %} | ||
|
||
{% endfor %} | ||
{% endif %} | ||
{% if service.ports|length %} | ||
{# ----------------------------------------------------- Ports #} | ||
ports: | ||
{% for publicPort, internalPort in service.ports %} | ||
- {{ publicPort }}:{{ internalPort }} | ||
{% endfor %} | ||
{% endif %} | ||
{% if true == service.isCli or true == service.options.cliOnly|default(false) %} | ||
stdin_open: true | ||
tty: true | ||
{% endif %} | ||
|
||
{% endfor %} |
Oops, something went wrong.