Current section
Files
Jump to
Current section
Files
src/examples@env_vars.erl
-module(examples@env_vars).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/examples/env_vars.gleam").
-export([main/0]).
-file("src/examples/env_vars.gleam", 14).
-spec main() -> nil.
main() ->
dagger:connect(
fun(Client) ->
Pipeline = begin
_pipe@1 = dagger@dsl@container:container(fun(O) -> _pipe = O,
dagger@dsl@container:opt_platform(
_pipe,
<<"linux/amd64"/utf8>>
) end),
_pipe@2 = dagger@dsl@container:from(
_pipe@1,
<<"alpine:3.21"/utf8>>
),
_pipe@3 = dagger@dsl@container:with_env_variable(
_pipe@2,
<<"APP_ENV"/utf8>>,
<<"production"/utf8>>,
fun dagger@dsl@container:none/1
),
_pipe@4 = dagger@dsl@container:with_env_variable(
_pipe@3,
<<"APP_VERSION"/utf8>>,
<<"1.0.0"/utf8>>,
fun dagger@dsl@container:none/1
),
_pipe@5 = dagger@dsl@container:with_env_variable(
_pipe@4,
<<"APP_NAME"/utf8>>,
<<"my-gleam-app"/utf8>>,
fun dagger@dsl@container:none/1
),
dagger@dsl@container:with_exec(
_pipe@5,
[<<"sh"/utf8>>,
<<"-c"/utf8>>,
<<"echo APP_ENV=$APP_ENV APP_VERSION=$APP_VERSION APP_NAME=$APP_NAME"/utf8>>],
fun dagger@dsl@container:none/1
)
end,
dagger@dsl@container:stdout(
Pipeline,
Client,
fun(Result) -> case Result of
{ok, Out} ->
gleam_stdlib:println(gleam@string:trim(Out));
{error, E} ->
gleam_stdlib:println_error(
<<"Pipeline failed: "/utf8,
(gleam@string:inspect(E))/binary>>
)
end end
)
end
).