From 0e8f6d24b87812664d3bb021d17f120686cf2401 Mon Sep 17 00:00:00 2001
From: kPherox <admin@mail.kr-kp.com>
Date: Fri, 10 Apr 2020 00:19:09 +0900
Subject: [PATCH] Create OTP_VERSION file by `mix release`

---
 Dockerfile |  2 --
 mix.exs    | 11 ++++++++++-
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index c2f3ad98c..29931a5e3 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -12,8 +12,6 @@ RUN apk add git gcc g++ musl-dev make &&\
 	mkdir release &&\
 	mix release --path release
 
-RUN echo "${OTP_VERSION}" > release/OTP_VERSION
-
 FROM alpine:3.11
 
 ARG BUILD_DATE
diff --git a/mix.exs b/mix.exs
index 3e4c7cbd8..ad2029518 100644
--- a/mix.exs
+++ b/mix.exs
@@ -37,12 +37,21 @@ defmodule Pleroma.Mixfile do
         pleroma: [
           include_executables_for: [:unix],
           applications: [ex_syslogger: :load, syslog: :load],
-          steps: [:assemble, &copy_files/1, &copy_nginx_config/1]
+          steps: [:assemble, &put_files/1, &copy_files/1, &copy_nginx_config/1]
         ]
       ]
     ]
   end
 
+  def put_files(%{path: target_path} = release) do
+    File.write!(
+      Path.join([target_path, "OTP_VERSION"]),
+      Pleroma.OTPVersion.version()
+    )
+
+    release
+  end
+
   def copy_files(%{path: target_path} = release) do
     File.cp_r!("./rel/files", target_path)
     release