diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index e049812..0000000 --- a/.drone.yml +++ /dev/null @@ -1,99 +0,0 @@ ---- -kind: pipeline -type: docker -name: push-latest -steps: -- name: submodules - image: alpine/git - commands: - - git submodule update --init --recursive -- name: build-and-push - image: plugins/docker - settings: - repo: ${DRONE_REPO_NAMESPACE/mu-semtech/semtech}/${DRONE_REPO_NAME} - username: - from_secret: docker_username - password: - from_secret: docker_password -trigger: - branch: - - master - event: - exclude: - - pull_request ---- -kind: pipeline -type: docker -name: push-feature-build -steps: -- name: submodules - image: alpine/git - commands: - - git submodule update --init --recursive -- name: push-feature-build - image: plugins/docker - settings: - repo: ${DRONE_REPO_NAMESPACE/mu-semtech/semtech}/${DRONE_REPO_NAME} - tags: ${DRONE_BRANCH/\//-} - username: - from_secret: docker_username - password: - from_secret: docker_password - purge: true -trigger: - branch: - - "*/*" - event: - exclude: - - pull_request ---- -kind: pipeline -type: docker -name: push-release -steps: -- name: submodules - image: alpine/git - commands: - - git submodule update --init --recursive -- name: build-and-push-tag - image: plugins/docker - settings: - repo: ${DRONE_REPO_NAMESPACE/mu-semtech/semtech}/${DRONE_REPO_NAME} - tags: ${DRONE_TAG##v} # strips v from the tag - username: - from_secret: docker_username - password: - from_secret: docker_password -trigger: - event: - - tag ---- -kind: pipeline -type: docker -name: dry-run -steps: -- name: submodules - image: alpine/git - commands: - - git submodule update --init --recursive -- name: dry-run - image: plugins/docker - settings: - repo: ${DRONE_REPO_NAMESPACE/mu-semtech/semtech}/${DRONE_REPO_NAME} - dry_run: true -trigger: - event: - - pull_request ---- -kind: secret -name: docker_username -data: 1/NnpJVaAj6pOTlePwqHygkheVsEXE6f1ZynUkCD3O852ubUqoxH ---- -kind: secret -name: docker_password -data: Iq2X6WmmnD3KSn4Rko/JxgiuGbFLYLhU82dW3PO4plpE4I4dk/zzxjSlf6Im8XLZ3t/2heY56fXqKSoQg0L0kg== ---- -kind: signature -hmac: 4ca929e87b549858dcbcee656676260f3c8ebaf452c1723f10336f79be0860c1 - -... diff --git a/.woodpecker/.feature.yml b/.woodpecker/.feature.yml new file mode 100644 index 0000000..7d12c09 --- /dev/null +++ b/.woodpecker/.feature.yml @@ -0,0 +1,11 @@ +pipeline: + build-and-push: + image: redpencil/plugin-docker-buildx + settings: + platforms: linux/amd64,linux/arm64 + repo: "${CI_REPO_OWNER##mu-}/${CI_REPO_NAME%%-service}" + tags: "feature-${CI_COMMIT_BRANCH##feature/}" + secrets: [ docker_username, docker_password, ssh_key, remote_builders ] + when: + event: push + branch: feature/* diff --git a/.woodpecker/.latest.yml b/.woodpecker/.latest.yml new file mode 100644 index 0000000..728d83c --- /dev/null +++ b/.woodpecker/.latest.yml @@ -0,0 +1,11 @@ +pipeline: + build-and-push: + image: redpencil/plugin-docker-buildx + settings: + platforms: linux/amd64,linux/arm64 + repo: "${CI_REPO_OWNER##mu-}/${CI_REPO_NAME%%-service}" + tags: latest + secrets: [ docker_username, docker_password, ssh_key, remote_builders ] + when: + event: push + branch: master diff --git a/.woodpecker/.tag.yml b/.woodpecker/.tag.yml new file mode 100644 index 0000000..f386cdc --- /dev/null +++ b/.woodpecker/.tag.yml @@ -0,0 +1,12 @@ +pipeline: + release: + image: redpencil/plugin-docker-buildx + settings: + platforms: linux/amd64,linux/arm64 + repo: "${CI_REPO_OWNER##mu-}/${CI_REPO_NAME%%-service}" + tags: "${CI_COMMIT_TAG##v}" + secrets: [ docker_username, docker_password, ssh_key, remote_builders ] + when: + event: tag + ref: refs/tags/v* + diff --git a/Dockerfile b/Dockerfile index faf37a3..2bc1abc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM madnificent/elixir-server:1.11.0 +FROM madnificent/elixir-server:1.12.0 ENV MU_SPARQL_ENDPOINT 'http://database:8890/sparql' ENV LOG_ELIXIR_STARTUP_COMMAND 'true' diff --git a/config/config.exs b/config/config.exs index 77dd232..b1df132 100644 --- a/config/config.exs +++ b/config/config.exs @@ -1,44 +1,42 @@ # This file is responsible for configuring your application # and its dependencies with the aid of the Mix.Config module. -use Mix.Config +import Config -defmodule CH do - def system_boolean(name, default \\ false) do - case String.downcase(System.get_env(name) || "") do - "true" -> true - "yes" -> true - "1" -> true - "on" -> true - "" -> default - _ -> false - end +system_boolean = fn (name, default) -> + case String.downcase(System.get_env(name) || "") do + "true" -> true + "yes" -> true + "1" -> true + "on" -> true + "" -> default + _ -> false end +end - def database_compatibility(name) do - (System.get_env(name) || "") - |> String.downcase() - |> case do - "virtuoso" -> Compat.Implementations.Virtuoso - _ -> Compat.Implementations.Raw - end - end +database_compatibility = fn (name) -> + (System.get_env(name) || "") + |> String.downcase() + |> case do + "virtuoso" -> Compat.Implementations.Virtuoso + _ -> Compat.Implementations.Raw + end +end - def system_number(name, default) do - try do - (System.get_env(name) || "") - |> String.to_integer() - rescue - ArgumentError -> default - end +system_number = fn (name, default) -> + try do + (System.get_env(name) || "") + |> String.to_integer() + rescue + ArgumentError -> default end +end - def system_float(name, default \\ false) do - try do - (System.get_env(name) || "") - |> String.to_float() - rescue - ArgumentError -> default - end +system_float = fn (name, default) -> + try do + (System.get_env(name) || "") + |> String.to_float() + rescue + ArgumentError -> default end end @@ -53,30 +51,29 @@ end # config :sparqlex, key: :value config :"mu-authorization", author: :"mu-semtech", - log_server_configuration: CH.system_boolean("LOG_SERVER_CONFIGURATION"), - log_outgoing_sparql_queries: CH.system_boolean("LOG_OUTGOING_SPARQL_QUERIES"), - log_incoming_sparql_queries: CH.system_boolean("LOG_INCOMING_SPARQL_QUERIES"), - inspect_outgoing_sparql_queries: CH.system_boolean("INSPECT_OUTGOING_SPARQL_QUERIES"), - inspect_incoming_sparql_queries: CH.system_boolean("INSPECT_INCOMING_SPARQL_QUERIES"), - log_delta_messages: CH.system_boolean("LOG_DELTA_MESSAGES"), - log_template_matcher_performance: CH.system_boolean("LOG_TEMPLATE_MATCHER_PERFORMANCE"), - log_delta_client_communication: CH.system_boolean("LOG_DELTA_CLIENT_COMMUNICATION"), - log_access_rights: CH.system_boolean("LOG_ACCESS_RIGHTS"), - inspect_access_rights_processing: CH.system_boolean("INSPECT_ACCESS_RIGHTS_PROCESSING"), - database_compatibility: CH.database_compatibility("DATABASE_COMPATIBILITY"), - log_outgoing_sparql_query_responses: CH.system_boolean("LOG_OUTGOING_SPARQL_QUERY_RESPONSES"), - inspect_outgoing_sparql_query_responses: - CH.system_boolean("INSPECT_OUTGOING_SPARQL_QUERY_RESPONSES"), - log_outgoing_sparql_query_roundtrip: CH.system_boolean("LOG_OUTGOING_SPARQL_QUERY_ROUNDTRIP"), + log_server_configuration: system_boolean.("LOG_SERVER_CONFIGURATION", false), + log_outgoing_sparql_queries: system_boolean.("LOG_OUTGOING_SPARQL_QUERIES", false), + log_incoming_sparql_queries: system_boolean.("LOG_INCOMING_SPARQL_QUERIES", false), + inspect_outgoing_sparql_queries: system_boolean.("INSPECT_OUTGOING_SPARQL_QUERIES", false), + inspect_incoming_sparql_queries: system_boolean.("INSPECT_INCOMING_SPARQL_QUERIES", false), + log_delta_messages: system_boolean.("LOG_DELTA_MESSAGES", false), + log_template_matcher_performance: system_boolean.("LOG_TEMPLATE_MATCHER_PERFORMANCE", false), + log_delta_client_communication: system_boolean.("LOG_DELTA_CLIENT_COMMUNICATION", false), + log_access_rights: system_boolean.("LOG_ACCESS_RIGHTS", false), + inspect_access_rights_processing: system_boolean.("INSPECT_ACCESS_RIGHTS_PROCESSING", false), + database_compatibility: database_compatibility.("DATABASE_COMPATIBILITY"), + log_outgoing_sparql_query_responses: system_boolean.("LOG_OUTGOING_SPARQL_QUERY_RESPONSES", false), + inspect_outgoing_sparql_query_responses: system_boolean.("INSPECT_OUTGOING_SPARQL_QUERY_RESPONSES", false), + log_outgoing_sparql_query_roundtrip: system_boolean.("LOG_OUTGOING_SPARQL_QUERY_ROUNDTRIP", false), default_sparql_endpoint: System.get_env("MU_SPARQL_ENDPOINT") || "http://localhost:8890/sparql", - query_max_processing_time: CH.system_number("QUERY_MAX_PROCESSING_TIME", 120_000), - query_max_execution_time: CH.system_number("QUERY_MAX_EXECUTION_TIME", 60_000), - database_recovery_mode_enabled: CH.system_boolean("DATABASE_OVERLOAD_RECOVERY"), - log_database_recovery_mode_tick: CH.system_boolean("LOG_DATABASE_OVERLOAD_TICK"), - log_workload_info_requests: CH.system_boolean("LOG_WORKLOAD_INFO_REQUESTS"), - testing_auth_query_error_rate: CH.system_float("TESTING_AUTH_QUERY_ERROR_RATE"), - error_on_unwritten_data: CH.system_boolean("ERROR_ON_UNWRITTEN_DATA"), - errors: CH.system_boolean("LOG_ERRORS", true) + query_max_processing_time: system_number.("QUERY_MAX_PROCESSING_TIME", 120_000), + query_max_execution_time: system_number.("QUERY_MAX_EXECUTION_TIME", 60_000), + database_recovery_mode_enabled: system_boolean.("DATABASE_OVERLOAD_RECOVERY", false), + log_database_recovery_mode_tick: system_boolean.("LOG_DATABASE_OVERLOAD_TICK", false), + log_workload_info_requests: system_boolean.("LOG_WORKLOAD_INFO_REQUESTS", false), + testing_auth_query_error_rate: system_float.("TESTING_AUTH_QUERY_ERROR_RATE", false), + error_on_unwritten_data: system_boolean.("ERROR_ON_UNWRITTEN_DATA", false), + errors: system_boolean.("LOG_ERRORS", true) # and access this configuration in your application as: # @@ -95,7 +92,7 @@ config :logger, compile_time_purge_level: :debug, level: :warn -if Mix.env() == :test do +if config_env() == :test do config :junit_formatter, report_dir: "/tmp/repo-example-test-results/exunit" end @@ -106,6 +103,6 @@ end # Configuration from the imported file will override the ones defined # here (which is why it is important to import them last). # -# import_config "#{Mix.env}.exs" +# import_config "#{config_env()}.exs" -import_config "#{Mix.env()}.exs" +import_config "#{config_env()}.exs" diff --git a/config/dev.exs b/config/dev.exs index ccbeaf9..937b710 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -1,4 +1,4 @@ -use Mix.Config +import Config config :"mu-authorization", sparql_port: 9980 diff --git a/config/prod.exs b/config/prod.exs index bfbaddb..dfecb13 100644 --- a/config/prod.exs +++ b/config/prod.exs @@ -1,4 +1,4 @@ -use Mix.Config +import Config config :"mu-authorization", sparql_port: 8890 diff --git a/config/test.exs b/config/test.exs index d2d855e..becde76 100644 --- a/config/test.exs +++ b/config/test.exs @@ -1 +1 @@ -use Mix.Config +import Config