diff --git a/docs/docs/getting-started/1-create-a-project.md b/docs/docs/getting-started/1-create-a-project.md index 7cf77ce..ea1d179 100644 --- a/docs/docs/getting-started/1-create-a-project.md +++ b/docs/docs/getting-started/1-create-a-project.md @@ -70,7 +70,6 @@ app │   └── cloud │   ├── Dockerfile │   └── Dockerfile-build -├── sh_build.sh └── test ├── infrastructure │   └── entry_points @@ -100,4 +99,35 @@ Enter to [http://localohst:8083/api/health](http://localohst:8083/api/health) an "time": 1 } ] +``` +# Testing and Code Analysis at local + +Basically you can run `mix ca.release --skiprelease` all outputs will be generated at `_build/release` folder + +Or you can run it with the file `app_name/resources/cloud/Dockerfile-build` and the next script + +At local you can use the next script to build and analize your project inside docker using deps caching + +sh_build.sh +```shell +set -e +BASE_IMAGE=$1 +# Change it +APP_NAME=name_project +mkdir -p _build +rm -rf _build/release +docker build --build-arg IMAGE=$BASE_IMAGE -t $APP_NAME -f resources/cloud/Dockerfile-build . +docker stop $APP_NAME || true +docker rm $APP_NAME || true +docker run -d --name $APP_NAME $APP_NAME +docker cp $APP_NAME:/app/_build/release _build/release +docker stop $APP_NAME || true +docker rm $APP_NAME || true +docker rmi $APP_NAME --force +cp -r deployment _build/release/artifact +ls -lR _build/release +``` + +```shell +./sh_build.sh elixir:alpine ``` \ No newline at end of file diff --git a/lib/core/structure/root.ex b/lib/core/structure/root.ex index 72295d0..f882490 100644 --- a/lib/core/structure/root.ex +++ b/lib/core/structure/root.ex @@ -22,7 +22,6 @@ defmodule Structure.Root do "{app_snake}/.dockerignore" => @base <> "dockerignore.txt", "{app_snake}/resources/cloud/Dockerfile" => @base <> "dockerfile.txt", "{app_snake}/resources/cloud/Dockerfile-build" => @base <> "Dockerfile-build.txt", - "{app_snake}/sh_build.sh" => @base <> "sh_build.sh", "{app_snake}/test/infrastructure/entry_points/api_rest_test.exs" => @base <> "api_rest_test.exs", "{app_snake}/test/{app_snake}_application_test.exs" => @base <> "test_application.exs", diff --git a/lib/mix/tasks/ca.base.task.ex b/lib/mix/tasks/ca.base.task.ex index fdf9aab..a53c4e2 100644 --- a/lib/mix/tasks/ca.base.task.ex +++ b/lib/mix/tasks/ca.base.task.ex @@ -3,6 +3,7 @@ defmodule Mix.Tasks.Ca.BaseTask do @moduledoc """ Generic base task for all tasks in this project. """ + require Logger defmacro __using__(opts) do quote do @@ -15,7 +16,6 @@ defmodule Mix.Tasks.Ca.BaseTask do @switches unquote(opts[:switches] || []) @aliases unquote(opts[:aliases] || []) @name unquote(opts[:name]) - @format unquote(if opts[:format] == false, do: false, else: true) @impl Mix.Task def run([help]) when help in ~w(-h --help) do @@ -34,9 +34,13 @@ defmodule Mix.Tasks.Ca.BaseTask do DataTypeUtils.parse_opts(argv, @switches, @aliases) |> execute() - if @format do - CommonCommands.format() - end + unquote( + if opts[:format] != false do + quote do + CommonCommands.format() + end + end + ) res end diff --git a/priv/templates/structure/sh_build.sh b/priv/templates/structure/sh_build.sh deleted file mode 100755 index a51f669..0000000 --- a/priv/templates/structure/sh_build.sh +++ /dev/null @@ -1,15 +0,0 @@ -set -e -BASE_IMAGE=$1 -APP_NAME={app_snake} -mkdir -p _build -rm -rf _build/release -docker build --build-arg IMAGE=$BASE_IMAGE -t $APP_NAME -f resources/cloud/Dockerfile-build . -docker stop $APP_NAME || true -docker rm $APP_NAME || true -docker run -d --name $APP_NAME $APP_NAME -docker cp $APP_NAME:/app/_build/release _build/release -docker stop $APP_NAME || true -docker rm $APP_NAME || true -docker rmi $APP_NAME --force -cp -r deployment _build/release/artifact -ls -lR _build/release \ No newline at end of file