fix
This commit is contained in:
parent
6b73c1c0b7
commit
75613c2476
104
apps/efka/src/tests/docker_commands_tests.erl
Normal file
104
apps/efka/src/tests/docker_commands_tests.erl
Normal file
@ -0,0 +1,104 @@
|
||||
%%%-------------------------------------------------------------------
|
||||
%%% @author anlicheng
|
||||
%%% @copyright (C) 2025, <COMPANY>
|
||||
%%% @doc
|
||||
%%%
|
||||
%%% @end
|
||||
%%% Created : 23. 9月 2025 17:23
|
||||
%%%-------------------------------------------------------------------
|
||||
-module(docker_commands_tests).
|
||||
-author("anlicheng").
|
||||
|
||||
%% API
|
||||
-export([test_pull/0, test_commands/0, test_create_container/0]).
|
||||
|
||||
test_pull() ->
|
||||
Image = <<"docker.1ms.run/library/nginx:latest">>,
|
||||
docker_commands:pull_image(Image, fun(Msg) -> lager:debug("msg is: ~p", [Msg]) end).
|
||||
|
||||
test_commands() ->
|
||||
Id = <<"redpanda-console">>,
|
||||
StopRes = docker_commands:stop_container(Id),
|
||||
lager:debug("stop res: ~p", [StopRes]),
|
||||
StartRes = docker_commands:start_container(Id),
|
||||
lager:debug("start res: ~p", [StartRes]).
|
||||
|
||||
test_create_container() ->
|
||||
M = #{
|
||||
<<"image">> => <<"docker.1ms.run/library/nginx:latest">>,
|
||||
<<"container_name">> => <<"my_nginx_new1">>,
|
||||
<<"command">> => [
|
||||
<<"nginx">>,
|
||||
<<"-g">>,
|
||||
<<"daemon off;">>
|
||||
],
|
||||
<<"entrypoint">> => [
|
||||
<<"/docker-entrypoint.sh">>
|
||||
],
|
||||
<<"envs">> => [
|
||||
<<"ENV1=val1">>,
|
||||
<<"ENV2=val2">>
|
||||
],
|
||||
<<"env_file">> => [
|
||||
<<"./env.list">>
|
||||
],
|
||||
<<"ports">> => [
|
||||
<<"8080:80">>,
|
||||
<<"443:443">>
|
||||
],
|
||||
<<"expose">> => [
|
||||
<<"80">>,
|
||||
<<"443">>
|
||||
],
|
||||
<<"volumes">> => [
|
||||
<<"/host/data:/data">>,
|
||||
<<"/host/log:/var/log">>
|
||||
],
|
||||
<<"networks">> => [
|
||||
<<"mynet">>
|
||||
],
|
||||
<<"labels">> => #{
|
||||
<<"role">> => <<"web">>,
|
||||
<<"env">> => <<"prod">>
|
||||
},
|
||||
<<"restart">> => <<"always">>,
|
||||
<<"user">> => <<"www-data">>,
|
||||
<<"working_dir">> => <<"/app">>,
|
||||
<<"hostname">> => <<"myhost">>,
|
||||
<<"privileged">> => true,
|
||||
<<"cap_add">> => [
|
||||
<<"NET_ADMIN">>
|
||||
],
|
||||
<<"cap_drop">> => [
|
||||
<<"MKNOD">>
|
||||
],
|
||||
<<"devices">> => [
|
||||
<<"/dev/snd:/dev/snd">>
|
||||
],
|
||||
<<"mem_limit">> => <<"512m">>,
|
||||
<<"mem_reservation">> => <<"256m">>,
|
||||
<<"cpu_shares">> => 512,
|
||||
<<"cpus">> => 1.5,
|
||||
<<"ulimits">> => #{
|
||||
<<"nofile">> => <<"1024:2048">>
|
||||
},
|
||||
<<"sysctls">> => #{
|
||||
<<"net.ipv4.ip_forward">> => <<"1">>
|
||||
},
|
||||
<<"tmpfs">> => [
|
||||
<<"/tmp">>
|
||||
],
|
||||
<<"extra_hosts">> => [
|
||||
<<"host1:192.168.0.1">>
|
||||
],
|
||||
<<"healthcheck">> => #{
|
||||
<<"test">> => [
|
||||
<<"CMD-SHELL">>,
|
||||
<<"curl -f http://localhost || exit 1">>
|
||||
],
|
||||
<<"interval">> => <<"30s">>,
|
||||
<<"timeout">> => <<"10s">>,
|
||||
<<"retries">> => 3
|
||||
}
|
||||
},
|
||||
docker_commands:create_container(<<"my_nginx_xx3">>, "/usr/local/code/efka/", M).
|
||||
Loading…
x
Reference in New Issue
Block a user