Packages
graphqexl
0.1.0-alpha-rc.25
0.1.0
0.1.0-alpha-rc.docs-test-6
0.1.0-alpha-rc.docs-test-5
0.1.0-alpha-rc.docs-test-4
0.1.0-alpha-rc.docs-test-3
0.1.0-alpha-rc.docs-test-2
0.1.0-alpha-rc.docs-test
0.1.0-alpha-rc.25
0.1.0-alpha-rc.24
0.1.0-alpha-rc.23
0.1.0-alpha-rc.22
0.1.0-alpha-rc.21
0.1.0-alpha-rc.20
0.1.0-alpha-rc.19
0.1.0-alpha-rc.18
0.1.0-alpha-rc.17
0.1.0-alpha-rc.16
0.1.0-alpha-rc.15
0.1.0-alpha-rc.14
0.1.0-alpha-rc.13
0.1.0-alpha-rc.12
0.1.0-alpha-rc.11
0.1.0-alpha-rc.10
0.1.0-alpha-rc.9
0.1.0-alpha-rc.8
0.1.0-alpha-rc.7
0.1.0-alpha-rc.6
0.1.0-alpha-rc.5
0.1.0-alpha-rc.4
0.1.0-alpha-rc.3
0.1.0-alpha-rc.2
0.1.0-alpha-rc.1
0.1.0-alpha.rc-4
0.1.0-alpha.rc.4
Fully-loaded, pure-Elixir GraphQL server implementation with developer tools
Current section
Files
Jump to
Current section
Files
lib/mix/tasks/docker/build.ex
defmodule Mix.Tasks.Docker.Build do
@moduledoc """
Build the application's Docker Image
"""
@moduledoc since: "0.1.0"
@type exit_status:: non_neg_integer
@type command_result:: {Collectable.t, exit_status}
@type command_tuple:: {String.t, list(String.t)}
@docker_buildkit {"DOCKER_BUILDKIT", "1"}
@doc """
Build the application's Docker image
ARGS
- image_name, string, e.g.: "graphqexl"
- image_repo, string, e.g.: "gcr.io/absynthe"
- release_name, string, e.g.: "stable"
"""
@doc since: "0.1.0"
@spec run([String.t]) :: :ok
def run([image_name, image_repo, release_name]) do
"[STARTING] Building #{image_repo}/#{image_name}:#{release_name} Docker image..." |> IO.puts
image_name
|> docker_build(image_repo, release_name)
|> run_with_buildkit
"[DONE] Building #{image_repo}/#{image_name}:#{release_name} Docker image..." |> IO.puts
end
@doc false
@spec build_params(String.t, String.t, String.t):: list(String.t)
defp build_params(image_name, image_repo, release_name) do
[
"build",
".",
"-t",
"#{image_repo}/#{image_name}",
"--build-arg",
"release_name=#{release_name}"
]
end
@doc false
@spec docker_build(String.t, String.t, String.t):: command_tuple
defp docker_build(image_name, image_repo, release_name),
do: {"docker", image_name |> build_params(image_repo, release_name)}
@doc false
@spec run_with_buildkit(command_tuple):: command_result
defp run_with_buildkit({cmd, args}),
do: cmd |> System.cmd(args, env: [@docker_buildkit], into: :stdio |> IO.stream(:line))
end