diff --git a/lib/core/structure/root.ex b/lib/core/structure/root.ex index 21437b8..fe2f5fe 100644 --- a/lib/core/structure/root.ex +++ b/lib/core/structure/root.ex @@ -7,6 +7,7 @@ defmodule Structure.Root do create: %{ "{app_snake}/mix.exs" => @base <> "mix.exs", "{app_snake}/Dockerfile-build" => @base <> "Dockerfile-build", + "{app_snake}/sh_build.sh" => @base <> "sh_build.sh", "{app_snake}/config/config.exs" => @base <> "config.exs", "{app_snake}/config/dev.exs" => @base <> "dev.exs", "{app_snake}/config/test.exs" => @base <> "test.exs", diff --git a/lib/mix/tasks/ca.release.ex b/lib/mix/tasks/ca.release.ex index 6e072fe..ef2f6a3 100644 --- a/lib/mix/tasks/ca.release.ex +++ b/lib/mix/tasks/ca.release.ex @@ -15,7 +15,7 @@ defmodule Mix.Tasks.Ca.Release do * _build/release/test-junit-report.xml * _build/release/artifact/.tar.gz - You can skip some task with --skip-test or --skip-release options: + You can skip some task with --skiptest or --skipreleasee options: $ mix ca.release --skiptest $ mix ca.release --skiprelease @@ -139,7 +139,7 @@ defmodule Mix.Tasks.Ca.Release do transformations: [ {:cmd, "rm -rf _build/release"}, {:cmd, - "#{container_tool} build --build-arg IMAGE=#{container_base_image} --build-arg SKIP_RELEASE=#{skip_release} --build-arg SKIP_TEST=#{skip_test} -t {app_snake} -f #{container_file} ."}, + "#{container_tool} build --build-arg IMAGE=#{container_base_image} -t {app_snake} -f #{container_file} ."}, {:cmd, "#{container_tool} stop {app_snake} || true"}, {:cmd, "#{container_tool} rm {app_snake} || true"}, {:cmd, "#{container_tool} run -d --name {app_snake} {app_snake}"}, diff --git a/priv/templates/structure/Dockerfile-build b/priv/templates/structure/Dockerfile-build index 8799a20..cabb733 100644 --- a/priv/templates/structure/Dockerfile-build +++ b/priv/templates/structure/Dockerfile-build @@ -1,6 +1,4 @@ ARG IMAGE=elixir:1.16.2-otp-26-alpine -ARG SKIP_RELEASE=false -ARG SKIP_TEST=false FROM $IMAGE RUN apk add build-base git @@ -16,7 +14,7 @@ RUN mix deps.get \ # Ensure use of .dockerignore file to avoid copying unnecessary files COPY . . # To generate compiled application and run static code analysis -RUN mix ca.release --skip-release=$SKIP_RELEASE --skip-test=$SKIP_TEST +RUN mix ca.release CMD while true; do \ echo "This is an infinite loop until files are copied and container destroyed."; \ diff --git a/priv/templates/structure/sh_build.sh b/priv/templates/structure/sh_build.sh new file mode 100755 index 0000000..fdac8e2 --- /dev/null +++ b/priv/templates/structure/sh_build.sh @@ -0,0 +1,15 @@ +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 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