From ecb552479faa6bf4fbee5161d0dd7e9962326b58 Mon Sep 17 00:00:00 2001 From: Adam Rutkowski Date: Wed, 22 Feb 2023 09:49:43 +0100 Subject: [PATCH] Upgrade erlang/elixir/alpine stack (#2695) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Dockerfile: pin elixir-1.14.3, erlang-25.2.3, alpine-3.17.0 * asdf: pin erlang 25.2.3, elixir 1.14.3-otp-25 * Remove nonsense * Remove erlang dupe * Remove erlang, it's in the base image already * Remove empty file * Truncate seconds in NaiveDateTime instances * Bump cache key * Mitigate Error:error:0308010C:digital envelope routines::unsupported See: https://www.newline.co/@kchan/how-to-fix-the-error-errorerror0308010cdigital-envelope-routinesunsupported--0f8d3f17 * Upgrade to latest alpine image and pin to an exact digest * Revert "Upgrade to latest alpine image and pin to an exact digest" This reverts commit cdf6624efabce0a630a00c60aba2c6b975ca399f. * Pin alpine image to an exact digest --------- Co-authored-by: Cenk Kücük --- .github/workflows/elixir.yml | 4 ++-- .tool-versions | 4 ++-- Dockerfile | 9 +++++---- lib/plausible/ingestion/request.ex | 2 +- lib/plausible/site/schema.ex | 1 - .../controllers/stats_controller_test.exs | 18 ++++++++++++------ 6 files changed, 22 insertions(+), 16 deletions(-) delete mode 100644 lib/plausible/site/schema.ex diff --git a/.github/workflows/elixir.yml b/.github/workflows/elixir.yml index 1b2e7e811..934dff1c8 100644 --- a/.github/workflows/elixir.yml +++ b/.github/workflows/elixir.yml @@ -58,8 +58,8 @@ jobs: deps _build priv/plts - key: ${{ runner.os }}-mix-v2-${{ hashFiles('**/mix.lock') }} - restore-keys: ${{ runner.os }}-mix-v2- + key: ${{ runner.os }}-mix-v3-${{ hashFiles('**/mix.lock') }} + restore-keys: ${{ runner.os }}-mix-v3- - name: Install dependencies run: mix deps.get && npm install --prefix ./tracker - name: Check Formatting diff --git a/.tool-versions b/.tool-versions index 01339e781..0850981c4 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,4 +1,4 @@ -elixir 1.13.4-otp-24 -erlang 24.3.3 +erlang 25.2.3 +elixir 1.14.3-otp-25 nodejs 16.3.0 python 3.9.12 diff --git a/Dockerfile b/Dockerfile index d117c558a..b8eda2de6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,17 +2,18 @@ # platform specific, it makes sense to build it in the docker #### Builder -FROM hexpm/elixir:1.13.4-erlang-24.3.3-alpine-3.15.3 as buildcontainer +FROM hexpm/elixir:1.14.3-erlang-25.2.3-alpine-3.17.0 as buildcontainer # preparation ENV MIX_ENV=prod ENV NODE_ENV=production +ENV NODE_OPTIONS=--openssl-legacy-provider RUN mkdir /app WORKDIR /app # install build dependencies -RUN apk add --no-cache git nodejs yarn python3 npm ca-certificates wget gnupg make erlang gcc libc-dev && \ +RUN apk add --no-cache git nodejs yarn python3 npm ca-certificates wget gnupg make gcc libc-dev && \ npm install npm@latest -g && \ npm install -g webpack @@ -47,8 +48,8 @@ COPY rel rel RUN mix release plausible # Main Docker Image -FROM alpine:3.15.3 -LABEL maintainer="tckb " +FROM alpine:3.17.0@sha256:c0d488a800e4127c334ad20d61d7bc21b4097540327217dfab52262adc02380c +LABEL maintainer="plausible.io " ARG BUILD_METADATA={} ENV BUILD_METADATA=$BUILD_METADATA diff --git a/lib/plausible/ingestion/request.ex b/lib/plausible/ingestion/request.ex index f557cdde4..a23352527 100644 --- a/lib/plausible/ingestion/request.ex +++ b/lib/plausible/ingestion/request.ex @@ -37,7 +37,7 @@ defmodule Plausible.Ingestion.Request do |> Changeset.change() |> Changeset.put_change( :timestamp, - NaiveDateTime.utc_now() + NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second) ) case parse_body(conn) do diff --git a/lib/plausible/site/schema.ex b/lib/plausible/site/schema.ex deleted file mode 100644 index 8b1378917..000000000 --- a/lib/plausible/site/schema.ex +++ /dev/null @@ -1 +0,0 @@ - diff --git a/test/plausible_web/controllers/stats_controller_test.exs b/test/plausible_web/controllers/stats_controller_test.exs index 71156ef1a..23b9a4c0e 100644 --- a/test/plausible_web/controllers/stats_controller_test.exs +++ b/test/plausible_web/controllers/stats_controller_test.exs @@ -191,7 +191,8 @@ defmodule PlausibleWeb.StatsControllerTest do subdivision1_code: "EE-37", city_geoname_id: 588_409, pathname: "/", - timestamp: Timex.shift(~N[2021-10-20 12:00:00], minutes: -1), + timestamp: + Timex.shift(~N[2021-10-20 12:00:00], minutes: -1) |> NaiveDateTime.truncate(:second), referrer_source: "Google", user_id: 123 ), @@ -200,7 +201,8 @@ defmodule PlausibleWeb.StatsControllerTest do subdivision1_code: "EE-37", city_geoname_id: 588_409, pathname: "/some-other-page", - timestamp: Timex.shift(~N[2021-10-20 12:00:00], minutes: -2), + timestamp: + Timex.shift(~N[2021-10-20 12:00:00], minutes: -2) |> NaiveDateTime.truncate(:second), referrer_source: "Google", user_id: 123 ), @@ -211,23 +213,27 @@ defmodule PlausibleWeb.StatsControllerTest do utm_source: "google", utm_content: "content", utm_term: "term", - timestamp: Timex.shift(~N[2021-10-20 12:00:00], days: -1), + timestamp: + Timex.shift(~N[2021-10-20 12:00:00], days: -1) |> NaiveDateTime.truncate(:second), browser: "ABrowserName" ), build(:pageview, - timestamp: Timex.shift(~N[2021-10-20 12:00:00], months: -1), + timestamp: + Timex.shift(~N[2021-10-20 12:00:00], months: -1) |> NaiveDateTime.truncate(:second), country_code: "EE", browser: "ABrowserName" ), build(:pageview, - timestamp: Timex.shift(~N[2021-10-20 12:00:00], months: -5), + timestamp: + Timex.shift(~N[2021-10-20 12:00:00], months: -5) |> NaiveDateTime.truncate(:second), utm_campaign: "ads", country_code: "EE", referrer_source: "Google", browser: "ABrowserName" ), build(:event, - timestamp: Timex.shift(~N[2021-10-20 12:00:00], days: -1), + timestamp: + Timex.shift(~N[2021-10-20 12:00:00], days: -1) |> NaiveDateTime.truncate(:second), name: "Signup", "meta.key": ["variant"], "meta.value": ["A"]