implements Huggable
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");
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'));
const platformsh = require('platformsh-config');
let config = platformsh.config();
const credentials = config.credentials('database');
const connection = await mysql.createConnection({
host: credentials.host,
port: credentials.port,
user: credentials.username,
password: credentials.password,
database: credentials.path,
});
var app = express();
// ...
app.listen(config.port);
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())
}
Use DotEnv (.env
files)
(Many to pick from in every language)
(App-specific configuration)
Constants?
Dependency inject your environment
Cloud
Always be able to
take your business elsewhere.
Use Free Software
Use replaceable services
Source: WordStream (2015)
Remember what they say when you assume
Director of Developer Experience Platform.sh
Idea to Cloud Hosting
Stalk us at @PlatformSH