Skip to content

Commit

Permalink
Merge pull request #37 from james-nesbitt/cleanup
Browse files Browse the repository at this point in the history
Cleanup
  • Loading branch information
james-nesbitt committed Nov 11, 2015
2 parents 4f42d3b + 4190c5e commit 00326f1
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 31 deletions.
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ func GetClient(conf Conf, log Log) (*docker.Client, error) {

var client *docker.Client
var err error

log.DebugObject(LOG_SEVERITY_DEBUG_WOAH,"Docker client conf: ",conf.Docker)

if (strings.HasPrefix(conf.Docker.Host, "tcp://")) {
Expand All @@ -43,6 +42,7 @@ func GetClient(conf Conf, log Log) (*docker.Client, error) {

// TCP DOCKER CLIENT WITHOUT CERTS
client, err = docker.NewClient(conf.Docker.Host)

}

} else if (strings.HasPrefix(conf.Docker.Host, "unix://")) {
Expand Down
6 changes: 3 additions & 3 deletions conf_confyaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,11 @@ type Conf_Yaml struct {

Settings map[string]string `yaml:"Settings,omitempty"`

Docker DockerClientConf `yaml:"Docker,omitempty"`
Docker DockerClientConf `yaml:"Docker,omitempty"`
}

func (source *Conf_Yaml) toConf(log Log) Conf {

conf := Conf{
Paths: map[string]string{},
Tokens: map[string]string{},
Expand Down Expand Up @@ -97,7 +98,6 @@ func (source *Conf_Yaml) toConf(log Log) Conf {
conf.Docker.CertPath = source.Docker.CertPath
}

log.DebugObject(LOG_SEVERITY_DEBUG_STAAAP,"YAML CONVERT:", source.Docker, conf.Docker)

log.DebugObject(LOG_SEVERITY_DEBUG_STAAAP,"YAML CONVERT:", source.Docker, conf.Docker)
return conf
}
111 changes: 84 additions & 27 deletions operation_init_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ Docker: # Override Docker configuration

".coach/nodes.yml": `
# Files volume container
#
# - A volume container used to hold files assets for an application
# - Also has a place to put backups (separate from file assets)
# - Volatile, and not likely to handle exports well
#
# * Should be used as a ReadWrite container for Links/VolumesFrom
#
files:
Type: volume
Expand All @@ -34,6 +41,11 @@ files:
- app/backup:/app/backup # host based archive folder
# Source volume container
#
# - A volume container to hold application source
#
# * Can be used as a ReadOnly container for Links/VolumesFrom
#
source:
Type: volume
Expand All @@ -45,6 +57,11 @@ source:
- app/www:/app/www # host based webroots folder (needs /active subroot for nginx conf)
# Database service
#
# - Standalone DB server
#
# * ExposedPorts is likely not necessary, it just gives a host port for the server
#
db:
Type: service
Build: docker/db # DB has a docker build so that we can create databases and set custom passwords.
Expand All @@ -55,16 +72,21 @@ db:
ExposedPorts:
3306/tcp: {}
Host:
VolumesFrom:
- files # I am not sure if this is needed
# FPM service
#
# - Standalone php-fpm service
#
# * iIt needs source, and assets
# * ExposedPorts is likely not necessary, it just gives a host port for the server
#
# ! Alternate image: jamesnesbitt/wunder-php7fpm
# ! Alternate image: jamesnesbitt/wunder-hhvm
#
fpm:
Type: service
Config:
Image: jamesnesbitt/wunder-php5fpm # The FPM works, and should have blackfire working
Image: jamesnesbitt/wunder-php56fpm # The FPM works, and should have blackfire working
RestartPolicy: on-failure
ExposedPorts:
Expand All @@ -78,6 +100,16 @@ fpm:
- source
# WWW service
#
# - Standalone nginx service
# - Sets Hostname and DomainName using coach tokens
# - Sets DnsDock Alias ENV var using coach tokens
# - Tries to bind to the Host 8080 port
#
# * It needs source, and assets
# * ExposedPorts are likely not necessary, they just gives a host port for the server
# * If you make this scaled, you will get an error trying to reused the 8080 port
#
www:
Type: service
Expand All @@ -86,7 +118,7 @@ www:
RestartPolicy: on-failure
Hostname: "%PROJECT_%INSTANCE" # Token : project name (can be set in conf.yml)
Domainname: "%DOMAIN" # Token : can be set in conf.yml:Tokens
Domainname: "%DOMAIN" # Token : environment domain (can be set in conf.yml)
Env:
- "DNSDOCK_ALIAS=%PROJECT.%CONTAINER_DOMAIN" # If you are using DNSDOCK, this will create a DNS Entry.
Expand Down Expand Up @@ -128,6 +160,8 @@ The www folder is meant to house the htdocs parts of the apllication. This give
target for application source code, into which it can be linked or copied. This allows separation
of project custom code, from community code for frameworks and libraries.
* The typical nginx configuration expects an application Web Root at www/active
## Assets
The assets folder is meant to be a non-versioned folder that contains elements needed to
Expand All @@ -138,35 +172,58 @@ Assets folder being the writeable.
## Backups
The backups folder is meant to be a non-versioned fodler that contains backups dumps for
the application, which are kept separate from assets to that they can be managed separately.
`,
"app/assets/README.md": `
`,
"app/backup/README.md": `
The assets folder is meant to be a non-versioned folder that contains elements needed to
run the application, but which should not be a part of the project source code. This includes
file assets, and cache elements and temprorary elements.
The real goal of this folder is to separate filespace into Read-Only and Writeable, with the
Assets folder being the writeable.
`,
"app/www/active/index.php": `<?php phpinfo();`,
".coach/docker/db/Dockerfile": `
FROM jamesnesbitt/wunder-mariadb
MAINTAINER [email protected]
### ProjectDB --------------------------------------------------------------------
# Create our project DB
RUN (/usr/bin/mysqld_safe &) && sleep 5 && \
mysql -uroot -e "UPDATE mysql.user SET Password=PASSWORD('RESETME') WHERE User='root'" && \
mysql -uroot -e "DELETE FROM mysql.user WHERE User=''" && \
mysql -uroot -e "DROP DATABASE test" && \
mysql -uroot -e "UPDATE mysql.user SET Password=PASSWORD('RESETME') WHERE User='root'" && \
mysql -uroot -e "CREATE DATABASE project" && \
mysql -uroot -e "GRANT ALL ON project.* to project@'10.0.%' IDENTIFIED BY 'project'" && \
mysql -uroot -e "FLUSH PRIVILEGES"
### /ProjectDB -------------------------------------------------------------------
"app/backup/README.md": `
The backups folder is meant to be a non-versioned fodler that contains backups dumps for
the application, which are kept separate from assets to that they can be managed separately.
`,
"app/www/active/index.php": `<?php
/**
* This is your web root, where you application root should sit.
*
* This is kept as a sub-path of the www folder, so that the www folder can be mapped into
* the container, with a sub-folder that can be the target of a build process which may replacement
* or sym-link it.
* If you are using a build process to generate your web-root, have it build the active folder,
* or symlink the latest build to ./active.
**/
phpinfo();`,
".coach/docker/db/Dockerfile": `#####
# Create a custom DB build for my project
#
# - this gives a custom DB for my project
# - my custom DB will respond to credentials that I define here
# - this DB image can be used as a "docker commit" target to create DB snapshots
#
# * This image build was created by coach init
FROM jamesnesbitt/wunder-mariadb
MAINTAINER [email protected]
### ProjectDB --------------------------------------------------------------------
# Create our project DB
#
# - create a new database "app"
# - grant privileges to that database to user app@172.*, using the password "app"
# - flush privileges
#
# * this expects Docker to run it's bridge/subnet using 172.* (and limits access to that subnet)
#
RUN (/usr/bin/mysqld_safe &) && sleep 5 && \
mysql -uroot -e "GRANT ALL ON app.* to app@'172.%' IDENTIFIED BY 'app'" && \
mysql -uroot -e "FLUSH PRIVILEGES"
### /ProjectDB -------------------------------------------------------------------
`,

}
Expand Down

0 comments on commit 00326f1

Please sign in to comment.