Dagger
Search

postgres

This module is aimed at providing a simple way to launch a Postgres database server for development and testing purposes.

Check out the official Postgres image on Docker Hub for further customization options: https://hub.docker.com/_/postgres

Installation

dagger install github.com/sagikazarmark/daggerverse/postgres@v0.4.0

Entrypoint

Return Type
Postgres !
Arguments
NameTypeDescription
versionString Version (image tag) to use from the official image repository as a base container.
containerContainer Custom container to use as a base container. Takes precedence over version.
userSecret Superuser name. (default "postgres")
passwordSecret Superuser password. (defaults "postgres")
databaseString The database name. (defaults to the user name)
dataVolumeCacheVolume Mount a volume to persist data between runs.
initScriptsDirectory Initialization scripts (*.sql and *.sh) to run when the service first starts.
initdbArgs[String ! ] Additional arguments to pass to initdb.
nameString Instance name (allowing to spawn multiple services with the same parameters).
Example
dagger -m github.com/sagikazarmark/daggerverse/postgres@89a5a332f2ad1a182e6e8172f6872c4ab3ada507 call \
func (m *myModule) example() *Postgres  {
	return dag.
			Postgres()
}
@function
def example() -> dag.Postgres:
	return (
		dag.postgres()
	)
@func()
example(): Postgres {
	return dag
		.postgres()
}

Types

Postgres 🔗

user() 🔗

Superuser name.

Return Type
Secret !
Example
dagger -m github.com/sagikazarmark/daggerverse/postgres@89a5a332f2ad1a182e6e8172f6872c4ab3ada507 call \
 user
func (m *myModule) example() *Secret  {
	return dag.
			Postgres().
			User()
}
@function
def example() -> dagger.Secret:
	return (
		dag.postgres()
		.user()
	)
@func()
example(): Secret {
	return dag
		.postgres()
		.user()
}

password() 🔗

Superuser password.

Return Type
Secret !
Example
dagger -m github.com/sagikazarmark/daggerverse/postgres@89a5a332f2ad1a182e6e8172f6872c4ab3ada507 call \
 password
func (m *myModule) example() *Secret  {
	return dag.
			Postgres().
			Password()
}
@function
def example() -> dagger.Secret:
	return (
		dag.postgres()
		.password()
	)
@func()
example(): Secret {
	return dag
		.postgres()
		.password()
}

database() 🔗

The database name.

Return Type
String !
Example
dagger -m github.com/sagikazarmark/daggerverse/postgres@89a5a332f2ad1a182e6e8172f6872c4ab3ada507 call \
 database
func (m *myModule) example(ctx context.Context) string  {
	return dag.
			Postgres().
			Database(ctx)
}
@function
async def example() -> str:
	return await (
		dag.postgres()
		.database()
	)
@func()
async example(): Promise<string> {
	return dag
		.postgres()
		.database()
}

withInitScript() 🔗

Add an additional initialization script to run when the service first starts.

Return Type
Postgres !
Arguments
NameTypeDefault ValueDescription
fileFile !-No description provided
Example
dagger -m github.com/sagikazarmark/daggerverse/postgres@89a5a332f2ad1a182e6e8172f6872c4ab3ada507 call \
 with-init-script --file file:path
func (m *myModule) example(file *File) *Postgres  {
	return dag.
			Postgres().
			WithInitScript(file)
}
@function
def example(file: dagger.File) -> dag.Postgres:
	return (
		dag.postgres()
		.with_init_script(file)
	)
@func()
example(file: File): Postgres {
	return dag
		.postgres()
		.withInitScript(file)
}

withDatabase() 🔗

Creates an additional database with the given name (with the default user as the owner) when the service first starts.

Under the hood, this method adds a SQL script to the init scripts that creates the database.

Return Type
Postgres !
Arguments
NameTypeDefault ValueDescription
nameString !-Database to create.
Example
dagger -m github.com/sagikazarmark/daggerverse/postgres@89a5a332f2ad1a182e6e8172f6872c4ab3ada507 call \
 with-database --name string
func (m *myModule) example(name string) *Postgres  {
	return dag.
			Postgres().
			WithDatabase(name)
}
@function
def example(name: str) -> dag.Postgres:
	return (
		dag.postgres()
		.with_database(name)
	)
@func()
example(name: string): Postgres {
	return dag
		.postgres()
		.withDatabase(name)
}

service() 🔗

The Postgres service.

Return Type
Service !
Example
dagger -m github.com/sagikazarmark/daggerverse/postgres@89a5a332f2ad1a182e6e8172f6872c4ab3ada507 call \
 service
func (m *myModule) example() *Service  {
	return dag.
			Postgres().
			Service()
}
@function
def example() -> dagger.Service:
	return (
		dag.postgres()
		.service()
	)
@func()
example(): Service {
	return dag
		.postgres()
		.service()
}