This commit is contained in:
Mayel de Borniol 2023-10-14 14:11:19 +01:00
parent 9548d60b74
commit f03ee51e48
10 changed files with 125 additions and 13 deletions

View file

@ -1,5 +1,6 @@
erlang 26.1.1
elixir 1.15.6-otp-26
# NOTE: see instructions in .tool-versions.env
erlang 26.1.2
elixir 1.15.7-otp-26
just 1.14.0
yarn 1.22.19
nodejs 20.8.0

View file

@ -7,6 +7,4 @@
# The version of Alpine to use for the final image - should match a version used in the Elixir docker image, which can be checked on Docker Hub: https://hub.docker.com/r/hexpm/elixir/tags?name=alpine
ALPINE_VERSION="3.18.2"
ERLANG_VERSION="26.1.1"
ELIXIR_VERSION="1.15.6"
ELIXIR_VERSION="1.15.7"

View file

@ -92,6 +92,10 @@ config :bonfire, Bonfire.Common.TestInstanceRepo, database: "bonfire_test_instan
# ecto query filtering
# config :query_elf, :id_types, [:id, :binary_id, Pointers.ULID]
# disable Tzdata and replace with Tz library
config :tzdata, :autoupdate, :disabled
config :elixir, :time_zone_database, Tz.TimeZoneDatabase
config :logger, :console,
format: "$time $metadata[$level] $message\n",
metadata: [:request_id]

View file

@ -69,8 +69,6 @@ mogrify = "https://github.com/chaskiq/mogrify.git#identify-option"
# bonfire_livebook = "https://github.com/bonfire-networks/bonfire_livebook#main"
# livebook = "https://github.com/mayel/livebook#fork"
# ex_doc = "https://github.com/elixir-lang/ex_doc#main"
paper_trail = "https://github.com/bonfire-networks/paper_trail#with-pointers"
# source_inspector = "https://github.com/tmbb/source_inspector"

View file

@ -40,6 +40,7 @@ finch = "~> 0.16"
httpoison = "~> 2.1"
jason = "~> 1.4.0"
poison = "~> 5.0" # not our preferred one, but some libs use it
tz = "~> 0.26.2"
timex = "~> 3.7.8"
solid = "~> 0.13"
mime = "~> 2.0.3"

View file

@ -27,7 +27,7 @@ hosts =
# |> IO.inspect()
if (config_env() == :prod or System.get_env("OTEL_ENABLED") == "1") and
(System.get_env("OTEL_EXPORTER_OTLP_ENDPOINT") || System.get_env("OTEL_LIGHTSEP_API_KEY") ||
(System.get_env("OTEL_EXPORTER_OTLP_ENDPOINT") || System.get_env("OTEL_LIGHTSTEP_API_KEY") ||
System.get_env("OTEL_HONEYCOMB_API_KEY")) do
config :opentelemetry,
disabled: false
@ -44,7 +44,7 @@ if (config_env() == :prod or System.get_env("OTEL_ENABLED") == "1") and
otlp_endpoint: otel_endpoint
end
if System.get_env("OTEL_LIGHTSEP_API_KEY") do
if System.get_env("OTEL_LIGHTSTEP_API_KEY") do
IO.puts("NOTE: OTLP (open telemetry) data will be sent to lightstep.com")
# Example configuration for Lightstep.com, for more refers to:
# https://github.com/open-telemetry/opentelemetry-erlang/tree/main/apps/opentelemetry_exporter#application-environment
@ -54,7 +54,7 @@ if (config_env() == :prod or System.get_env("OTEL_ENABLED") == "1") and
oltp_traces_compression: :gzip,
otlp_traces_endpoint: "https://ingest.lightstep.com:443/traces/otlp/v0.9",
otlp_headers: [
{"lightstep-access-token", System.get_env("OTEL_LIGHTSEP_API_KEY")}
{"lightstep-access-token", System.get_env("OTEL_LIGHTSTEP_API_KEY")}
]
end

View file

@ -27,7 +27,7 @@ MAIL_FROM=bonfire@example.com
# SENTRY_DSN=
OTEL_ENABLED=0
# OTEL_HONEYCOMB_API_KEY=
# OTEL_LIGHTSEP_API_KEY=
# OTEL_LIGHTSTEP_API_KEY=
# default admin user if you generate seed data
SEEDS_USER=root

View file

@ -591,7 +591,7 @@ rel-mix USE_EXT="local" ARGS="":
# Build the Docker image
@rel-build-docker USE_EXT="local" ARGS="": rel-init rel-prepare assets-prepare
export $(grep -v '^#' .tool-versions.env | xargs) && export ELIXIR_DOCKER_IMAGE="${ELIXIR_VERSION}-erlang-${ERLANG_VERSION}-alpine-${ALPINE_VERSION}" && echo ELIXIR_DOCKER_IMAGE && just rel-build-path {{ if USE_EXT=="remote" {"data/null"} else {EXT_PATH} }} {{ ARGS }}
export $(./tool-versions-to-env.sh 3 | xargs) && export $(grep -v '^#' .tool-versions.env | xargs) && export ELIXIR_DOCKER_IMAGE="${ELIXIR_VERSION}-erlang-${ERLANG_VERSION}-alpine-${ALPINE_VERSION}" && echo $ELIXIR_DOCKER_IMAGE && just rel-build-path {{ if USE_EXT=="remote" {"data/null"} else {EXT_PATH} }} {{ ARGS }}
rel-build-path FORKS_TO_COPY_PATH ARGS="":
@echo "Building $APP_NAME with flavour $FLAVOUR for arch {{arch()}} with image $ELIXIR_DOCKER_IMAGE."

View file

@ -20,7 +20,7 @@ defmodule Bonfire.Umbrella.MixProject do
## password hashing - builtin vs nif
{:pbkdf2_elixir, "~> 2.0", only: [:dev, :test]},
{:argon2_elixir, "~> 3.0", only: [:prod]},
{:argon2_elixir, "~> 4.0", only: [:prod]},
## dev conveniences
#
@ -69,6 +69,9 @@ defmodule Bonfire.Umbrella.MixProject do
# for Telemetry store
{:circular_buffer, "~> 0.4", only: :dev},
# logging
{:sentry, "~> 9.0", only: :prod, override: true},
# list dependencies & licenses
# {
# :licensir,

107
tool-versions-to-env.sh Normal file
View file

@ -0,0 +1,107 @@
#!/usr/bin/env bash
set -e
# Script to read .tool-versions library versions into environment variables
# in the form of <library_name>_version=<version_number>
# credit to https://github.com/smartcontractkit/tool-versions-to-env-action
# Create the functions
print_help() {
echo "Requires at least 1 argument"
echo "Argument #1: Action options"
echo " 1 = print to .env file"
echo " Argument #2: Optional. The path to the .tool-versions file"
echo " Argument #3: Optional. The path to the .env file to create"
echo " 2 = sent to github action output"
echo " Argument #2: Optional. The path to the .tool-versions file"
echo " 3 = only print given variable to stdout"
echo " Argument #2: Required. The tool version to output to stdout"
echo " Argument #3: Optional. The path to the .tool-versions file"
echo ""
echo "Example for 1 or 2: tool-versions-to-env.sh 1"
echo "Example for 3: tool-versions-to-env.sh 3 golang"
}
# First argument is a boolean of 0 = false or 1 = true to echo the variable.
# Second argument is the string to echo to std out.
to_echo() {
if [ "$1" -eq 1 ]; then
echo "$2"
fi
}
# First argument is the output option,
# 1 to .env
# 2 to github action output
# 3 none
# Second arument is the .tool-versions location
# Third argument is the .env location
# Fourth argument is whether it is safe to echo to stdout
read_tool_versions_write_to_env() {
local -r how_to_echo="$1"
local -r tool_versions_file="$2"
local -r env_file="$3"
local -r safe_to_echo="$4"
# clear the env file before writing to it later
if [ "$how_to_echo" -eq 1 ]; then
echo "" >"${env_file}"
fi
# loop over each line of the .tool-versions file
while read -r line; do
to_echo "$safe_to_echo" "Original line: $line"
# split the line into a bash array using the default space delimeter
IFS=" " read -r -a lineArray <<<"$line"
# get the key and value from the array, set the key to all uppercase
key="${lineArray[0],,}"
value="${lineArray[1]}"
# ignore comments, comments always start with #
if [[ ${key:0:1} != "#" ]]; then
full_key="${key}_version"
to_echo "${safe_to_echo}" "Parsed line: ${full_key}=${value}"
# echo the variable to the .env file
if [ "$how_to_echo" -eq 1 ]; then
echo "${full_key^^}=${value}" >>"${env_file}"
elif [ "$how_to_echo" -eq 2 ]; then
echo "${full_key}=$value" >>"$GITHUB_OUTPUT"
elif [ "$how_to_echo" -eq 3 ]; then
# echo "$value"
# break
echo " ${full_key^^}=${value}"
fi
fi
done <"$tool_versions_file"
}
# Run the code
if [ $# -eq 0 ]; then
print_help
exit 1
fi
# Action option
ACTION_OPTION=${1}
# path to the .tool-versions file
TOOL_VERSIONS_FILE=${2:-"./.tool-versions"}
# path to the .env file
ENV_FILE=${3:-"./.env"}
if [ "$ACTION_OPTION" -eq 1 ]; then
# print to .env
read_tool_versions_write_to_env 1 "$TOOL_VERSIONS_FILE" "$ENV_FILE" 1
elif [ "$ACTION_OPTION" -eq 2 ]; then
# print to github action
read_tool_versions_write_to_env 2 "$TOOL_VERSIONS_FILE" "$ENV_FILE" 1
elif [ "$ACTION_OPTION" -eq 3 ]; then
TOOL_VERSIONS_FILE=${3:-"./.tool-versions"}
# print single to variable to stdout
read_tool_versions_write_to_env 3 "$TOOL_VERSIONS_FILE" "" 0
else
echo "First argument was not of option 1, 2, or 3"
fi