Skip to content

Commit

Permalink
fix(cleanup): Remove script and add it as an option in documentation (#…
Browse files Browse the repository at this point in the history
…58)

* fix(cleanup): Remove script

* fix(cleanup): Fix dialyzer
  • Loading branch information
juancgalvis authored Aug 15, 2024
1 parent 2737e24 commit eac8475
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 21 deletions.
32 changes: 31 additions & 1 deletion docs/docs/getting-started/1-create-a-project.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ app
│   └── cloud
│   ├── Dockerfile
│   └── Dockerfile-build
├── sh_build.sh
└── test
├── infrastructure
│   └── entry_points
Expand Down Expand Up @@ -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
```
1 change: 0 additions & 1 deletion lib/core/structure/root.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 8 additions & 4 deletions lib/mix/tasks/ca.base.task.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
15 changes: 0 additions & 15 deletions priv/templates/structure/sh_build.sh

This file was deleted.

0 comments on commit eac8475

Please sign in to comment.