Base docker image to run a PostgreSQL database server in azk
Image content use https://github.com/docker-library/postgres
Example of using this image with azk:
/**
* Documentation: http://docs.azk.io/Azkfile.js
*/
// Adds the systems that shape your system
systems({
postgres: {
// More info about postgres image: http://images.azk.io/#/postgres?from=images-azkfile-postgres
image: {"docker": "azukiapp/postgres:9.4"},
shell: "/bin/bash",
wait: {"retry": 25, "timeout": 1000},
mounts: {
'/var/lib/postgresql/data': persistent("#{system.name}-data"),
// to clean postgres data, run:
// $ azk shell postgres -c "rm -rf /var/lib/postgresql/data/*"
},
ports: {
// exports global variables: "#{net.port.data}"
data: "5432/tcp",
},
envs: {
// set instances variables
POSTGRES_USER: "azk",
POSTGRES_PASS: "azk",
POSTGRES_DB : "#{manifest.dir}",
},
export_envs: {
// check this gist to configure your database
// Ruby eg in: https://gist.github.com/gullitmiranda/62082f2e47c364ef9617
DATABASE_URL: "postgres://#{envs.POSTGRES_USER}:#{envs.POSTGRES_PASS}@#{net.host}:#{net.port.data}/#{envs.POSTGRES_DB}",
// Exlir eg in: https://github.com/azukiapp/hello_phoenix/blob/master/config/database.uri.exs
// DATABASE_URL: "ecto+postgres://#{envs.POSTGRES_USER}:#{envs.POSTGRES_PASS}@#{net.host}:#{net.port.data}/#{envs.POSTGRES_DB}",
// or use splited envs:
// POSTGRES_USER: "#{envs.POSTGRES_USER}",
// POSTGRES_PASS: "#{envs.POSTGRES_PASS}",
// POSTGRES_HOST: "#{net.host}",
// POSTGRES_PORT: "#{net.port.data}",
// POSTGRES_DB : "#{envs.POSTGRES_DB}",
},
},
});
Do not forget to add postgres
as a dependency of your application:
e.g.:
systems({
'my-app': {
// Dependent systems
depends: ["postgres"],
/* ... */
},
'postgres': { /* ... */ }
})
To create the image azukiapp/postgres
, execute the following command on the docker-postgres folder:
$ docker build -t azukiapp/postgres:9.4 ./9.4
To run the image and bind to port 5432:
$ docker run -d -p 5432:5432 azukiapp/postgres
Obs: Very slow process
$ make test
# with azk
$ azk logs postgres
# with docker
$ docker logs <CONTAINER_ID>
POSTGRES_USER
: Set a specific username for the admin account. (default 'azk')
POSTGRES_PASS
: Set a specific password for the admin account. (default 'azk')
POSTGRES_DB
: Set a specific database name
Azuki Dockerfiles distributed under the Apache License.