Skip to content

Commit

Permalink
(mostly) update docs example code
Browse files Browse the repository at this point in the history
The demos for running `hostname` should probably be removed, as regular
containers no longer have a hostname.

Signed-off-by: Alex Suraci <suraci.alex@gmail.com>
  • Loading branch information
vito committed Jul 18, 2023
1 parent ce542c1 commit 5f14ae2
Show file tree
Hide file tree
Showing 27 changed files with 57 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ connect(
.withWorkdir("/srv")
.withExec(["python", "-m", "http.server", "8080"])
.withExposedPort(8080)
.service()

// create client container with service binding
// access HTTP service and print result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ func main() {
From("python").
WithDirectory("/srv", client.Directory().WithNewFile("index.html", "Hello, world!")).
WithWorkdir("/srv").
WithExec([]string{"python", "-m", "http.server", "8080"}).
WithExposedPort(8080)
WithExposedPort(8080).
Service([]string{"python", "-m", "http.server", "8080"})

// create client container with service binding
// access HTTP service and print result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ async def main():
client.directory().with_new_file("index.html", "Hello, world!"),
)
.with_workdir("/srv")
.with_exec(["python", "-m", "http.server", "8080"])
.with_exposed_port(8080)
.service(["python", "-m", "http.server", "8080"])
)

# create client container with service binding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ connect(
.withWorkdir("/srv")
.withExec(["python", "-m", "http.server", "8080"])
.withExposedPort(8080)
.service()

// create client container with service binding
// access HTTP service, write to file and retrieve contents
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ func main() {
From("python").
WithDirectory("/srv", client.Directory().WithNewFile("index.html", "Hello, world!")).
WithWorkdir("/srv").
WithExec([]string{"python", "-m", "http.server", "8080"}).
WithExposedPort(8080)
WithExposedPort(8080).
Service([]string{"python", "-m", "http.server", "8080"})

// create client container with service binding
// access HTTP service, write to file and retrieve contents
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ async def main():
client.directory().with_new_file("index.html", "Hello, world!"),
)
.with_workdir("/srv")
.with_exec(["python", "-m", "http.server", "8080"])
.with_exposed_port(8080)
.service(["python", "-m", "http.server", "8080"])
)

# create client container with service binding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ connect(
.withWorkdir("/srv")
.withExec(["python", "-m", "http.server", "8080"])
.withExposedPort(8080)
.service()

// get HTTP endpoint
let val = await httpSrv.endpoint()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ func main() {
From("python").
WithDirectory("/srv", client.Directory().WithNewFile("index.html", "Hello, world!")).
WithWorkdir("/srv").
WithExec([]string{"python", "-m", "http.server", "8080"}).
WithExposedPort(8080)
WithExposedPort(8080).
Service([]string{"python", "-m", "http.server", "8080"})

// get endpoint
val, err := httpSrv.
Expand All @@ -38,7 +38,7 @@ func main() {
fmt.Println(val)

// get HTTP endpoint
val, err = httpSrv.Endpoint(ctx, dagger.ContainerEndpointOpts{
val, err = httpSrv.Endpoint(ctx, dagger.ServiceEndpointOpts{
Scheme: "http",
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ async def main():
client.directory().with_new_file("index.html", "Hello, world!"),
)
.with_workdir("/srv")
.with_exec(["python", "-m", "http.server", "8080"])
.with_exposed_port(8080)
.service(["python", "-m", "http.server", "8080"])
)

# get endpoint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ connect(
.withExposedPort(6379)
.withMountedCache("/data", client.cacheVolume("my-redis"))
.withWorkdir("/data")
.service();

// create Redis client container
const redisCLI = client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ func main() {
From("redis").
WithExposedPort(6379).
WithMountedCache("/data", client.CacheVolume("my-redis")).
WithWorkdir("/data")
WithWorkdir("/data").
Service(nil)

// create Redis client container
redisCLI := client.Container().
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ async def main():
.with_exposed_port(6379)
.with_mounted_cache("/data", client.cache_volume("my-redis"))
.with_workdir("/data")
.service([])
)

# create Redis client container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import Client, { connect } from "@dagger.io/dagger"
connect(
async (client: Client) => {
// create Redis service container
const redisSrv = client.container().from("redis").withExposedPort(6379)
const redisSrv = client
.container()
.from("redis")
.withExposedPort(6379)
.service()

// create Redis client container
const redisCLI = client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ func main() {
// create Redis service container
redisSrv := client.Container().
From("redis").
WithExposedPort(6379)
WithExposedPort(6379).
Service(nil)

// create Redis client container
redisCLI := client.Container().
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ async def main():
# create Dagger client
async with dagger.Connection(dagger.Config(log_output=sys.stderr)) as client:
# create Redis service container
redis_srv = client.container().from_("redis").with_exposed_port(6379)
redis_srv = client.container()
.from_("redis")
.with_exposed_port(6379)
.service([])

# create Redis client container
redis_cli = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import Client, { connect } from "@dagger.io/dagger"
connect(
async (client: Client) => {
// create Redis service container
const redisSrv = client.container().from("redis").withExposedPort(6379)
const redisSrv = client
.container()
.from("redis")
.withExposedPort(6379)
.service()

// create Redis client container
const redisCLI = client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ func main() {
// create Redis service container
redisSrv := client.Container().
From("redis").
WithExposedPort(6379)
WithExposedPort(6379).
Service(nil)

// create Redis client container
redisCLI := client.Container().
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ async def main():
# create Dagger client
async with dagger.Connection(dagger.Config(log_output=sys.stderr)) as client:
# create Redis service container
redis_srv = client.container().from_("redis").with_exposed_port(6379)
redis_srv = client.container()
.from_("redis")
.with_exposed_port(6379)
.service([])

# create Redis client container
redis_cli = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import Client, { connect } from "@dagger.io/dagger"
connect(
async (client: Client) => {
// create Redis service container
const redisSrv = client.container().from("redis").withExposedPort(6379)
const redisSrv = client
.container()
.from("redis")
.withExposedPort(6379)
.service();

// create Redis client container
const redisCLI = client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ func main() {
// create Redis service container
redisSrv := client.Container().
From("redis").
WithExposedPort(6379)
WithExposedPort(6379).
Service(nil)

// create Redis client container
redisCLI := client.Container().
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ async def main():
# create Dagger client
async with dagger.Connection(dagger.Config(log_output=sys.stderr)) as client:
# create Redis service container
redis_srv = client.container().from_("redis").with_exposed_port(6379)
redis_srv = client.container()
.from_("redis")
.with_exposed_port(6379)
.service([])

# create Redis client container
redis_cli = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ connect(
.withEnvVariable("MARIADB_DATABASE", "drupal")
.withEnvVariable("MARIADB_ROOT_PASSWORD", "root")
.withExposedPort(3306)
.service();

// get Drupal base image
// install additional dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ func main() {
WithEnvVariable("MARIADB_PASSWORD", "password").
WithEnvVariable("MARIADB_DATABASE", "drupal").
WithEnvVariable("MARIADB_ROOT_PASSWORD", "root").
WithExposedPort(3306)
WithExposedPort(3306).
Service(nil)

// get Drupal base image
// install additional dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ async def main():
.with_env_variable("MARIADB_DATABASE", "drupal")
.with_env_variable("MARIADB_ROOT_PASSWORD", "root")
.with_exposed_port(3306)
.service([])
)

# get Drupal base image
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ connect(
const val = await client
.container()
.from("python")
.withExec(["python", "-m", "http.server"])
.service(["python", "-m", "http.server"])
.hostname()
console.log(val)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func main() {
// get hostname of service container via API
val, err := client.Container().
From("python").
WithExec([]string{"python", "-m", "http.server"}).
Service([]string{"python", "-m", "http.server"}).
Hostname(ctx)

if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ async def main():
val = await (
client.container()
.from_("python")
.with_exec(["python", "-m", "http.server"])
.service(["python", "-m", "http.server"])
.hostname()
)

Expand Down

0 comments on commit 5f14ae2

Please sign in to comment.