What is cloud
computing?
What is
The Cloud?
These are separate questions...
Someone else's hard drive
Abstracting away physical infrastructure
Disposable application design
Your application is disposable.
Your data is not.
You don't get an in-between option
Cleanly separate "Dev provided" and "user provided" files
Does config come from the developer or the user?
Git or Database?
Decide
// PHP
getenv('foo');
// Node.js
process.env["foo"];
// Go
os.Getenv("foo");
// Java
System.getEnv("foo");
Etc.
Need glue code
// platform_parameters.php
if (getenv('PLATFORM_RELATIONSHIPS')) {
$relationships = json_decode(base64_decode(getenv('PLATFORM_RELATIONSHIPS')), true);
foreach ($relationships['database'] as $endpoint) {
if (!empty($endpoint['query']['is_master'])) {
$container->setParameter('database_driver', 'pdo_'.$endpoint['scheme']);
$container->setParameter('database_host', $endpoint['host']);
$container->setParameter('database_port', $endpoint['port']);
$container->setParameter('database_name', $endpoint['path']);
$container->setParameter('database_user', $endpoint['username']);
$container->setParameter('database_password', $endpoint['password']);
break;
}
}
}
$container->setParameter('kernel.secret', getenv('PLATFORM_PROJECT_ENTROPY'));
package conf
import (
psh "github.com/platformsh/config-reader-go/v2"
)
var PshConfig = createPshConfigObj()
func createPshConfigObj() *psh.RuntimeConfig {
config, _ := psh.NewRuntimeConfig()
return config
}
package main
func main() {
engine := gin.Default()
// ...
err := ginInstance.Run(":" + conf.PshConfig.Port())
}
package sh.platform.template;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import sh.platform.config.Config;
import sh.platform.config.MySQL;
import javax.sql.DataSource;
@Configuration
public class DataSourceConfig {
@Bean(name = "dataSource")
public DataSource getDataSource() {
Config config = new Config();
MySQL database = config.getCredential("database", MySQL::new);
return database.get();
}
}
package sh.platform.template.spring.kotlin
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import sh.platform.config.Config
import sh.platform.config.MySQL
import javax.sql.DataSource
@Configuration
class DataSourceConfig {
@Bean(name = ["dataSource"])
fun getDataSource(): DataSource {
val config = Config()
val database = config.getCredential("database") { MySQL(it) }
return database.get()
}
}
Use DotEnv (.env
files)
(Many to pick from in every language)
(App-specific configuration)
Constants? Static config files?
Dependency inject your environment
Cloud
Always be able to
take your business elsewhere.
Source: WordStream (2015)
Use Free Software
Use replaceable services
Remember what they say when you assume
Director of Developer Experience Platform.sh
The end-to-end web platform for agile teams
Stalk us at @PlatformSH