Skip to content

Commit 9a6826f

Browse files
committed
Add a mix task to download the docker image.
1 parent 22d8887 commit 9a6826f

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ On OS X, `brew install postgresql`
2121
To start your new Phoenix application:
2222

2323
1. Install dependencies with `mix deps.get`
24-
2. Create and migration the database with `mix db.reset`
25-
3. Start Phoenix with `mix phoenix.server`
24+
2. Download docker image with `mix docker.pull`
25+
3. Create and migrate the database with `mix db.reset`
26+
4. Start Phoenix with `mix phoenix.server`
2627

2728
Now you can visit `localhost:4000` from your browser.
2829

lib/mix/tasks/docker.ex

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
defmodule Mix.Tasks.Docker do
2+
defmodule Pull do
3+
use Mix.Task
4+
5+
@shortdoc "Pulls the docker image"
6+
@moduledoc "Pulls the docker image"
7+
8+
def run(_args) do
9+
ElixirExperience.Docker.pull_image
10+
end
11+
end
12+
end

web/models/docker.ex

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule ElixirExperience.Docker do
22
require Logger
33

4-
@image_name "trenpixster/elixir"
4+
@image_name "trenpixster/elixir:1.0.4"
55
@test_template "code_templates/test.txt.eex"
66
@test_name "ElixirExperienceTest"
77

@@ -16,7 +16,9 @@ defmodule ElixirExperience.Docker do
1616

1717
defp image_exists? do
1818
{output, 0} = System.cmd("docker", ["images"], stderr_to_stdout: true)
19-
String.contains?(output, @image_name)
19+
output
20+
|> String.replace(~r" +", ":")
21+
|> String.contains?(@image_name)
2022
end
2123

2224
def run(code, timeout \\ 5000) do

0 commit comments

Comments
 (0)