Skip to content

Commit

Permalink
chore: upgrade elixir, otp and dependencies (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
nwittstruck authored Jan 4, 2024
1 parent de97e55 commit d7c5c26
Show file tree
Hide file tree
Showing 24 changed files with 118 additions and 83 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/on_push_branch__execute_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
# Currently, this need to be synced manually with the Dockerfile. In the future, the workflow should be changed,
# so that a development container is built from the Dockerfile, pushed, and then re-used in the following steps.
# This would also remove the need to install cmake manually in each step:
container: hexpm/elixir:1.13.4-erlang-25.3.2.8-debian-bullseye-20231009-slim
container: hexpm/elixir:1.15.2-erlang-26.0.2-debian-bullseye-20230612-slim

steps:
# See https://github.com/actions/checkout
Expand All @@ -37,7 +37,7 @@ jobs:
# Containers must run in Linux based operating systems
runs-on: ubuntu-latest
# Docker Hub image that `container-job` executes in
container: hexpm/elixir:1.13.4-erlang-25.3.2.8-debian-bullseye-20231009-slim
container: hexpm/elixir:1.15.2-erlang-26.0.2-debian-bullseye-20230612-slim

needs: build_deps

Expand Down Expand Up @@ -92,7 +92,7 @@ jobs:

check_mix_format:
runs-on: ubuntu-latest
container: hexpm/elixir:1.13.4-erlang-25.3.2.8-debian-bullseye-20231009-slim
container: hexpm/elixir:1.15.2-erlang-26.0.2-debian-bullseye-20230612-slim

needs: build_deps

Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.DS_Store

# The directory Mix will write compiled artifacts to.
/_build/

Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
# - https://pkgs.org/ - resource for finding needed packages
# - Ex: hexpm/elixir:1.13.3-erlang-24.3.4.2-debian-bullseye-20210902-slim
#
ARG ELIXIR_VERSION=1.13.4
ARG OTP_VERSION=25.3.2.8
ARG DEBIAN_VERSION=bullseye-20231009-slim
ARG ELIXIR_VERSION=1.15.2
ARG OTP_VERSION=26.0.2
ARG DEBIAN_VERSION=bullseye-20230612-slim

ARG BUILDER_IMAGE="hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-debian-${DEBIAN_VERSION}"
ARG RUNNER_IMAGE="debian:${DEBIAN_VERSION}"
Expand Down Expand Up @@ -108,7 +108,7 @@ RUN mix release
# the compiled release and other runtime necessities
FROM ${RUNNER_IMAGE} as production

RUN apt-get update -y && apt-get install -y postgresql-client libstdc++6 openssl libncurses5 locales \
RUN apt-get update -y && apt-get install -y ca-certificates postgresql-client libstdc++6 openssl libncurses5 locales \
&& apt-get clean && rm -f /var/lib/apt/lists/*_*

# Set the locale
Expand Down
19 changes: 17 additions & 2 deletions assets/js/qr_code_form/colorpicker.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
const createColor = (color) => {
return '<div class="color col colorpicker-background-color-'+color+'" data-color="'+color+'">&nbsp;</div>';
const div = document.createElement('div');
div.classList.add('color', 'col', `colorpicker-background-color-${color}`);
div.dataset.color = color;
div.textContent = '\u00A0';
return div;
}

const escapedColor = (color) => {
// this will be filtered server side anyway, but just to be sure that no one injects something client side:
const validColors = ['black', 'gold', 'darkgreen', 'darkslateblue', 'midnightblue', 'crimson'];

if (validColors.includes(color)) {
return color;
}

return 'black'
}

const formIdSelector = (colorPicker) => {
Expand Down Expand Up @@ -50,7 +65,7 @@ if (colorPickers.length > 0) {

for (let colorPicker of colorPickers) {
for (let color of colors) {
colorPicker.innerHTML += createColor(color.value);
colorPicker.appendChild(createColor(escapedColor(color.value)));
}

// select default color:
Expand Down
14 changes: 11 additions & 3 deletions config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,16 @@ config :qrstorage, Qrstorage.Repo,
hostname: System.get_env("DATABASE_HOST"),
port: String.to_integer(System.get_env("DATABASE_PORT", "5432")),
pool_size: String.to_integer(System.get_env("POOL_SIZE", "15")),
socket_options: maybe_ipv6,
ssl: System.get_env("DATABASE_SSL", "true") == "true",
socket_options: maybe_ipv6
ssl_opts: [
verify: :verify_peer,
cacerts: :public_key.cacerts_get(),
server_name_indication: String.to_charlist(System.get_env("DATABASE_HOST")),
customize_hostname_check: [
match_fun: :public_key.pkix_verify_hostname_match_fun(:https)
]
]

# Set possible translations
default_locale =
Expand All @@ -53,7 +61,7 @@ cond do
true ->
config :goth, disabled: true

Logger.warn("""
Logger.warning("""
Environment variables GCP_CONFIG_PATH or GCP_CONFIG_BASE64 are missing or empty.
Either set a path to a GCP Config file with GCP_CONFIG_PATH or base64 encode the credentials and put them in GCP_CONFIG_BASE64
""")
Expand All @@ -74,7 +82,7 @@ if config_env() == :prod || config_env() == :dev do
{"@midnight", Qrstorage.Worker.RemoveCodesWorker}
]}
],
queues: [default: 5]
queues: [default: 1]
end

# from mix phx.gen.release
Expand Down
2 changes: 1 addition & 1 deletion config/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ config :qrstorage, QrstorageWeb.Endpoint,
server: false

# Print only warnings and errors during test
config :logger, level: :warn
config :logger, level: :warning

config :goth,
disabled: true
Expand Down
30 changes: 15 additions & 15 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ services:
DATABASE_HOST: postgres
DATABASE_SSL: "false"
QR_CODE_DEFAULT_LOCALE: "de"
GCP_CONFIG_PATH: ".gcp-config.json"
# GCP_CONFIG_PATH: ".gcp-config.json"
# Please create a new secret for production runs:
# - Use `mix phx.gen.secret` if you have elixir and phoenix installed
# - Use `openssl rand -base64 64 | head -c 64` on a normal unix system
Expand Down Expand Up @@ -63,22 +63,22 @@ services:
depends_on:
- postgres
# volumes:
# Ensure that the file `gcp-config.json` is available in the container/
#
# How to get the fiel `docker-compose-kits.yml`?
# - Go to Coogle Cloud Platform dashboard
# - On the lefthand side, go to `APIs und Dienste` -> `Anmeldedaten`
# - In the upper section, click on `+ Anmeldedaten erstellen`
# - If not already existing, create a service account (Dienstkonto)
# - Afterwards, click on the newly created service account
# - In the details sectino of the service account, click on keys (Schlüssel)
# - In the key section of the service account click on `Schlüssel hinzufügen` -> `Neuen Schlüssel erstellen`
# - In the creatino dialog choose as key type `json` and finish creation of the .gcp-config.json
# - Please .gcp-config.json in the root of this project and let the following line inject this file into the docker container
# - ./.gcp-config.json:/app/.gcp-config.json
# Ensure that the file `gcp-config.json` is available in the container/
#
# How to get the fiel `docker-compose-kits.yml`?
# - Go to Coogle Cloud Platform dashboard
# - On the lefthand side, go to `APIs und Dienste` -> `Anmeldedaten`
# - In the upper section, click on `+ Anmeldedaten erstellen`
# - If not already existing, create a service account (Dienstkonto)
# - Afterwards, click on the newly created service account
# - In the details sectino of the service account, click on keys (Schlüssel)
# - In the key section of the service account click on `Schlüssel hinzufügen` -> `Neuen Schlüssel erstellen`
# - In the creatino dialog choose as key type `json` and finish creation of the .gcp-config.json
# - Please .gcp-config.json in the root of this project and let the following line inject this file into the docker container
# - ./.gcp-config.json:/app/.gcp-config.json

postgres:
image: postgres:12-alpine
image: postgres:15
environment:
POSTGRES_USER: ${POSTGRES_USER:-postgres}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
Expand Down
4 changes: 2 additions & 2 deletions elixir_buildpack.config
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
elixir_version=1.13.3
erlang_version=24.3.4.2
elixir_version=1.15.2
erlang_version=26.0.2
release=false
4 changes: 2 additions & 2 deletions lib/qrstorage/services/gcp/google_tts_voices.ex
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ defmodule Qrstorage.Services.Gcp.GoogleTtsVoices do

_ ->
# nothing found:
Logger.warn("Language / Gender combination not found! #{language} #{gender}")
Logger.warning("Language / Gender combination not found! #{language} #{gender}")
"de-DE-Wavenet-A"
end
end

def voice(language, gender) do
Logger.warn("Language is not an atom! #{language} #{gender}")
Logger.warning("Language is not an atom! #{language} #{gender}")
# default to german female:
"de-DE-Wavenet-A"
end
Expand Down
2 changes: 1 addition & 1 deletion lib/qrstorage/services/translation_service.ex
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ defmodule Qrstorage.Services.TranslationService do
save_translated_text(qr_code, translated_text)

{:error} ->
Logger.warn("Text not translated for qr_code id: #{qr_code.id}")
Logger.warning("Text not translated for qr_code id: #{qr_code.id}")
{:error, qr_code}
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/qrstorage/services/tts_service.ex
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ defmodule Qrstorage.Services.TtsService do
store_audio_file(qr_code, audio_file)

{:error} ->
Logger.warn("Text not transcribed for qr_code id: #{qr_code.id}")
Logger.warning("Text not transcribed for qr_code id: #{qr_code.id}")
{:error, qr_code}
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/qrstorage_web/endpoint.ex
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ defmodule QrstorageWeb.Endpoint do
parsers: [:urlencoded, :multipart, :json],
pass: ["*/*"],
json_decoder: Phoenix.json_library(),
length: max_upload_length * upload_length_buffer
length: ceil(max_upload_length * upload_length_buffer)

plug Plug.MethodOverride
plug Plug.Head
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="row m-2">
<h6 class="text-center"><%= label @f, :dots_type, gettext("color") %></h6>
<h6 class="text-center"><%= label @f, :color, gettext("color") %></h6>
<div class="colorpicker d-flex align-items-center" data-form-id={@f.id}></div>
</div>
22 changes: 11 additions & 11 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ defmodule Qrstorage.MixProject do
version: "0.1.0",
elixir: "~> 1.7",
elixirc_paths: elixirc_paths(Mix.env()),
compilers: [:phoenix, :gettext] ++ Mix.compilers(),
compilers: [:phoenix] ++ Mix.compilers(),
start_permanent: Mix.env() == :prod,
aliases: aliases(),
deps: deps()
Expand All @@ -33,25 +33,25 @@ defmodule Qrstorage.MixProject do
# Type `mix help deps` for examples and options.
defp deps do
[
{:phoenix, "1.6.10"},
{:phoenix_ecto, "4.4.0"},
{:ecto_sql, "3.8.3"},
{:postgrex, "0.16.3"},
{:phoenix, "1.6.16"},
{:phoenix_ecto, "4.4.3"},
{:ecto_sql, "3.11.1"},
{:postgrex, "0.17.4"},
{:phoenix_html, "3.2.0"},
{:phoenix_live_reload, "1.3.3", only: :dev},
{:phoenix_live_dashboard, "0.6.5"},
{:esbuild, "0.5.0", runtime: Mix.env() == :dev},
{:dart_sass, "0.5.0", runtime: Mix.env() == :dev},
{:telemetry_metrics, "0.6.1"},
{:telemetry_poller, "1.0.0"},
{:gettext, "0.19.1"},
{:timex, "3.7.8"},
{:jason, "1.3.0"},
{:plug_cowboy, "2.5.2"},
{:gettext, "0.24.0"},
{:timex, "3.7.11"},
{:jason, "1.4.1"},
{:plug_cowboy, "2.6.1"},
{:google_api_text_to_speech, "0.15.0"},
{:google_api_translate, "0.15.0"},
{:goth, "1.3.1"},
{:oban, "2.12.1"},
{:goth, "1.4.2"},
{:oban, "2.17.1"},
{:json, "1.4.1"},
{:fast_sanitize, "0.2.3"},
{:mox, "1.0.2", only: :test}
Expand Down
Loading

0 comments on commit d7c5c26

Please sign in to comment.