From 21ab7369cad6504be2f815aec888b38023d7a17a Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Fri, 2 Sep 2022 22:35:08 +0200 Subject: [PATCH 1/2] Bump minimum Elixir version to 1.10 With the release of Elixir 1.14, Elixir 1.9 is now end-of-life. Elixir 1.10 Release Notes: https://github.com/elixir-lang/elixir/releases/tag/v1.10.0 --- .gitlab-ci.yml | 4 ++-- CHANGELOG.md | 1 + Dockerfile | 4 ++-- ci/Dockerfile | 2 +- config/config.exs | 2 +- docs/configuration/howto_database_config.md | 2 +- docs/installation/generic_dependencies.include | 2 +- elixir_buildpack.config | 2 +- lib/mix/tasks/pleroma/config.ex | 9 ++------- lib/pleroma/config/loader.ex | 15 ++------------- lib/pleroma/web/activity_pub/object_validator.ex | 3 +-- mix.exs | 2 +- priv/templates/sample_config.eex | 6 +----- restarter/mix.exs | 2 +- 14 files changed, 18 insertions(+), 38 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0e7f4926a..37ec48353 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -271,7 +271,7 @@ amd64: MIX_ENV: prod before_script: &before-release - apt-get update && apt-get install -y cmake libmagic-dev - - echo "import Mix.Config" > config/prod.secret.exs + - echo "import Config" > config/prod.secret.exs - mix local.hex --force - mix local.rebar --force script: &release @@ -290,7 +290,7 @@ amd64-musl: variables: *release-variables before_script: &before-release-musl - apk add git build-base cmake file-dev openssl - - echo "import Mix.Config" > config/prod.secret.exs + - echo "import Config" > config/prod.secret.exs - mix local.hex --force - mix local.rebar --force script: *release diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d0ef4e11..caa5d0cd2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - MastoFE ### Changed +- **Breaking:** Elixir >=1.10 is now required (was >= 1.9) - Allow users to remove their emails if instance does not need email to register - Uploadfilter `Pleroma.Upload.Filter.Exiftool` has been renamed to `Pleroma.Upload.Filter.Exiftool.StripLocation` - Updated the recommended pleroma.vcl configuration for Varnish to target Varnish 7.0+ diff --git a/Dockerfile b/Dockerfile index e68b7ea7c..334d954f7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,11 @@ -FROM elixir:1.9-alpine as build +FROM elixir:1.10-alpine as build COPY . . ENV MIX_ENV=prod RUN apk add git gcc g++ musl-dev make cmake file-dev &&\ - echo "import Mix.Config" > config/prod.secret.exs &&\ + echo "import Config" > config/prod.secret.exs &&\ mix local.hex --force &&\ mix local.rebar --force &&\ mix deps.get --only prod &&\ diff --git a/ci/Dockerfile b/ci/Dockerfile index e6a8b438c..5929f832d 100644 --- a/ci/Dockerfile +++ b/ci/Dockerfile @@ -1,4 +1,4 @@ -FROM elixir:1.9.4 +FROM elixir:1.10.4 RUN apt-get update &&\ apt-get install -y libmagic-dev cmake libimage-exiftool-perl ffmpeg &&\ diff --git a/config/config.exs b/config/config.exs index 1653358a0..6adb63e5f 100644 --- a/config/config.exs +++ b/config/config.exs @@ -37,7 +37,7 @@ # FIGURATION! EDIT YOUR SECRET FILE (either prod.secret.exs, dev.secret.exs). # # This file is responsible for configuring your application -# and its dependencies with the aid of the Mix.Config module. +# and its dependencies with the aid of the Config module. # # This configuration file is loaded before any dependency and # is restricted to this project. diff --git a/docs/configuration/howto_database_config.md b/docs/configuration/howto_database_config.md index ae1462f9b..e5af9097a 100644 --- a/docs/configuration/howto_database_config.md +++ b/docs/configuration/howto_database_config.md @@ -59,7 +59,7 @@ The configuration of Pleroma has traditionally been managed with a config file, Here is an example of a server config stripped down after migration: ``` - use Mix.Config + import Config config :pleroma, Pleroma.Web.Endpoint, url: [host: "cool.pleroma.site", scheme: "https", port: 443] diff --git a/docs/installation/generic_dependencies.include b/docs/installation/generic_dependencies.include index 2dbd93e42..dcaacfdfd 100644 --- a/docs/installation/generic_dependencies.include +++ b/docs/installation/generic_dependencies.include @@ -1,7 +1,7 @@ ## Required dependencies * PostgreSQL 9.6+ -* Elixir 1.9+ +* Elixir 1.10+ * Erlang OTP 22.2+ * git * file / libmagic diff --git a/elixir_buildpack.config b/elixir_buildpack.config index 946408c12..1102e7145 100644 --- a/elixir_buildpack.config +++ b/elixir_buildpack.config @@ -1,2 +1,2 @@ -elixir_version=1.9.4 +elixir_version=1.10.4 erlang_version=22.3.4.1 diff --git a/lib/mix/tasks/pleroma/config.ex b/lib/mix/tasks/pleroma/config.ex index 33d147d36..3a2ea44f8 100644 --- a/lib/mix/tasks/pleroma/config.ex +++ b/lib/mix/tasks/pleroma/config.ex @@ -304,13 +304,8 @@ defp write_config(file, path, opts) do System.cmd("mix", ["format", path]) end - if Code.ensure_loaded?(Config.Reader) do - defp config_header, do: "import Config\r\n\r\n" - defp read_file(config_file), do: Config.Reader.read_imports!(config_file) - else - defp config_header, do: "use Mix.Config\r\n\r\n" - defp read_file(config_file), do: Mix.Config.eval!(config_file) - end + defp config_header, do: "import Config\r\n\r\n" + defp read_file(config_file), do: Config.Reader.read_imports!(config_file) defp write_and_delete(config, file, delete?) do config diff --git a/lib/pleroma/config/loader.ex b/lib/pleroma/config/loader.ex index 015be3d8e..bd85eccab 100644 --- a/lib/pleroma/config/loader.ex +++ b/lib/pleroma/config/loader.ex @@ -19,21 +19,10 @@ defmodule Pleroma.Config.Loader do :tesla ] - if Code.ensure_loaded?(Config.Reader) do - @reader Config.Reader - - def read(path), do: @reader.read!(path) - else - # support for Elixir less than 1.9 - @reader Mix.Config - def read(path) do - path - |> @reader.eval!() - |> elem(0) - end - end + @reader Config.Reader @spec read(Path.t()) :: keyword() + def read(path), do: @reader.read!(path) @spec merge(keyword(), keyword()) :: keyword() def merge(c1, c2), do: @reader.merge(c1, c2) diff --git a/lib/pleroma/web/activity_pub/object_validator.ex b/lib/pleroma/web/activity_pub/object_validator.ex index f3e31c931..21442687c 100644 --- a/lib/pleroma/web/activity_pub/object_validator.ex +++ b/lib/pleroma/web/activity_pub/object_validator.ex @@ -204,8 +204,7 @@ def cast_and_apply(%{"type" => type} = object) when type in ~w[Article Note Page def cast_and_apply(o), do: {:error, {:validator_not_set, o}} - # is_struct/1 appears in Elixir 1.11 - def stringify_keys(%{__struct__: _} = object) do + def stringify_keys(object) when is_struct(object) do object |> Map.from_struct() |> stringify_keys diff --git a/mix.exs b/mix.exs index 81c4cf9ae..a075cf05a 100644 --- a/mix.exs +++ b/mix.exs @@ -5,7 +5,7 @@ def project do [ app: :pleroma, version: version("2.4.52"), - elixir: "~> 1.9", + elixir: "~> 1.10", elixirc_paths: elixirc_paths(Mix.env()), compilers: [:phoenix, :gettext] ++ Mix.compilers(), elixirc_options: [warnings_as_errors: warnings_as_errors()], diff --git a/priv/templates/sample_config.eex b/priv/templates/sample_config.eex index 0068969ac..d44c324ca 100644 --- a/priv/templates/sample_config.eex +++ b/priv/templates/sample_config.eex @@ -3,11 +3,7 @@ # NOTE: This file should not be committed to a repo or otherwise made public # without removing sensitive information. -<%= if Code.ensure_loaded?(Config) or not Code.ensure_loaded?(Mix.Config) do - "import Config" -else - "use Mix.Config" -end %> +import Config config :pleroma, Pleroma.Web.Endpoint, url: [host: "<%= domain %>", scheme: "https", port: <%= port %>], diff --git a/restarter/mix.exs b/restarter/mix.exs index 9f26f5f64..4bb9b76e2 100644 --- a/restarter/mix.exs +++ b/restarter/mix.exs @@ -5,7 +5,7 @@ def project do [ app: :restarter, version: "0.1.0", - elixir: "~> 1.8", + elixir: "~> 1.10", start_permanent: Mix.env() == :prod, deps: deps() ] From 80a2528fd10ca2d07b8d96258a19bd9a8ea747ec Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sat, 3 Sep 2022 00:05:29 +0200 Subject: [PATCH 2/2] ci-base: Document building and pushing a new image --- ci/Dockerfile | 5 +++-- ci/README | 12 ++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 ci/README diff --git a/ci/Dockerfile b/ci/Dockerfile index 5929f832d..d39fd8d7b 100644 --- a/ci/Dockerfile +++ b/ci/Dockerfile @@ -1,7 +1,8 @@ FROM elixir:1.10.4 +# Single RUN statement, otherwise intermediate images are created +# https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#run RUN apt-get update &&\ - apt-get install -y libmagic-dev cmake libimage-exiftool-perl ffmpeg &&\ + apt-get install -y libmagic-dev cmake libimage-exiftool-perl ffmpeg &&\ mix local.hex --force &&\ mix local.rebar --force - diff --git a/ci/README b/ci/README new file mode 100644 index 000000000..3785adef1 --- /dev/null +++ b/ci/README @@ -0,0 +1,12 @@ +## Dependencies + +Assuming an AMD64 Alpine system, you're going to need the following packages +- `qemu qemu-openrc qemu-arm qemu-aarch64` for binfmt +- `docker-cli-buildx` for building the images + +## Setting up + +``` +docker login git.pleroma.social:5050 +doas rc-service qemu-binfmt start +```