Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Commit

Permalink
Merge pull request #26 from ipunkt/justb81-dockerfile-12
Browse files Browse the repository at this point in the history
Add docker container functionality
  • Loading branch information
justb81 authored Aug 4, 2017
2 parents 2f72d0e + 3a6a88c commit 2c4f05e
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Dockerfile
.gitignore
.git
51 changes: 51 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
ARG PHP_VERSION=7.2-rc
FROM php:${PHP_VERSION}-alpine

ARG PHP_VERSION
ARG DOCKER_COMPOSE_VERSION=1.15.0
ARG RANCHER_COMPOSE_VERSION=0.12.5
ARG RANCHERIZE_HOME=/home/rancherize
ARG DEFAULT_EDITOR=vi

LABEL maintainer="b.rang@ipunkt.biz" \
version.php=$PHP_VERSION \
version.docker-compose=$DOCKER_COMPOSE_VERSION \
version.rancher-compose=$RANCHER_COMPOSE_VERSION

# prepare pseudo project directory for npm_modules install
RUN ["mkdir", "$RANCHERIZE_HOME"]
RUN ["chmod", "777", "$RANCHERIZE_HOME"]

# there lies the home
ENV HOME=$RANCHERIZE_HOME

# default editor
ENV EDITOR=DEFAULT_EDITOR

# install packages
RUN apk update \
&& apk add --no-cache \
git \
docker \
py-pip

COPY [".", "/opt/rancherize"]
WORKDIR /opt/rancherize

# load rancher-compose
RUN curl -SL "https://github.com/rancher/rancher-compose/releases/download/v$RANCHER_COMPOSE_VERSION/rancher-compose-linux-amd64-v$RANCHER_COMPOSE_VERSION.tar.gz" \
| tar xz \
&& mv rancher-compose-*/rancher-compose /usr/local/bin/ && cp /usr/local/bin/rancher-compose /usr/local/bin/rancher-compose-$RANCHER_COMPOSE_VERSION

# install composer packages
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
&& php -r "if (hash_file('SHA384', 'composer-setup.php') === '669656bab3166a7aff8a7506b8cb2d1c292f042046c5a994c43155c0be6190fa0355160742ab2e1c88d40d5be660b410') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" \
&& php composer-setup.php \
&& php -r "unlink('composer-setup.php');" \
&& ./composer.phar install && rm composer.phar

# install docker-compose
RUN pip install docker-compose==$DOCKER_COMPOSE_VERSION

ENTRYPOINT ["/opt/rancherize/rancherize"]
#ENTRYPOINT ["/bin/sh"]
31 changes: 24 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,32 @@ of of adding and connecting services.

For a concrete example on how the configuration becomes easier through this see the example at the bottom of this page.

# Requirements
# Usage as docker container (preferred)
Rancherize comes bundled as Docker Container `ipunktbs/rancherize`.
## Requirements
Rancherize creates configuration to be used with external docker tools. Thus it is necessary to have the following tools
installed to use Rancherize:

- `docker` https://docs.docker.com/engine/installation/
## Install on linux
No need to separately install it. To use it, just make a shell alias:
```
alias rancherize='docker run -it -v $HOME/.rancherize:/home/rancherize/.rancherize -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd):$(pwd) -w $(pwd) -e "USER_ID=$(id -u)" -e "GROUP_ID=$(id -g)" ipunktbs/rancherize'
```
or use the provided script `script/rancherize.sh`.

From now on use rancherize without other dependencies for your local environment than docker.

# Usage in project
## Requirements
Rancherize creates configuration to be used with external docker tools. Thus it is necessary to have the following tools
installed to use Rancherize:

- `docker` https://docs.docker.com/engine/installation/
- `docker-compose` https://docs.docker.com/compose/install/
- `rancher-compose` https://docs.rancher.com/rancher/v1.2/en/cattle/rancher-compose/#installation

# Installation
## Installation
Rancherize is installed using composer

composer require 'ipunkt/rancherize:^2.5.0'
Expand Down Expand Up @@ -205,7 +222,7 @@ in a single place.
"DB_HOST":"database",
"DB_USER":"example_user",
"DB_PASSWORD":"example_password",
"DB_DATABASE":"example_db",
"DB_DATABASE":"example_db"
}
},
"environments":{
Expand All @@ -216,7 +233,7 @@ in a single place.
},
"staging":{
"environment":{
"APP_ENV":"staging",
"APP_ENV":"staging"
}
}
}
Expand All @@ -232,11 +249,11 @@ in a single place.
"database":"DB/MySql"
},
"environment":{
"APP_ENV":"production"
"APP_ENV":"production",
"DB_HOST":"database",
"DB_USER":"example_user",
"DB_PASSWORD":"example_password",
"DB_DATABASE":"example_db",
"DB_DATABASE":"example_db"
}
},
"staging":{
Expand All @@ -248,7 +265,7 @@ in a single place.
"DB_HOST":"database",
"DB_USER":"example_user",
"DB_PASSWORD":"example_password",
"DB_DATABASE":"example_db",
"DB_DATABASE":"example_db"
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/Blueprint/Webserver/WebserverBlueprint.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,8 @@ protected function makeServerService(Configuration $config, Configuration $defau
$serverService->setImage($config->get('docker.image', 'ipunktbs/nginx-debug:debug-1.3.0'));

if( $config->get('sync-user-into-container', false) ) {
$serverService->setEnvironmentVariable('USER_ID', getmyuid());
$serverService->setEnvironmentVariable('GROUP_ID', getmygid());
$serverService->setEnvironmentVariable('USER_ID',empty($_ENV['USER_ID']) ? getmyuid() : $_ENV['USER_ID'] );
$serverService->setEnvironmentVariable('GROUP_ID', empty($_ENV['GROUP_ID']) ? getmygid() : $_ENV['GROUP_ID'] );
}

if ($config->has('expose-port'))
Expand Down
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
"require-dev": {
"phpunit/phpunit": "^5.6",
"mockery/mockery": "^0.9.9",
"ipunkt/rancherize-backup-storagebox": "dev-master"
"ipunkt/rancherize-backup-storagebox": "^1.0.3",
"ipunkt/rancherize-ecr": "^1.0.0",
"ipunkt/rancherize-publish-traefik-rancher": "^1.0.2",
"ipunkt/rancherize-blueprint-php-cli": "dev-master"
}
}
3 changes: 3 additions & 0 deletions scripts/rancherize.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

docker run -it -v $HOME/.rancherize:/home/rancherize/.rancherize -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd):$(pwd) -w $(pwd) -e "USER_ID=$(id -u)" -e "GROUP_ID=$(id -g)" ipunktbs/rancherize $*

0 comments on commit 2c4f05e

Please sign in to comment.