Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(backend): Remove distillery for releases #813

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
9 changes: 3 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,8 @@ RUN mix do deps.get, compile

RUN \
mkdir -p /opt/built && \
mix distillery.release --name ${APP_NAME} && \
cp _build/${MIX_ENV}/rel/${APP_NAME}/releases/*/${APP_NAME}.tar.gz /opt/built && \
cd /opt/built && \
tar -xzf ${APP_NAME}.tar.gz && \
rm ${APP_NAME}.tar.gz
mix release ${APP_NAME} && \
mv _build/${MIX_ENV}/rel/${APP_NAME}/* /opt/built

FROM alpine:3.17.0 as tools

Expand Down Expand Up @@ -117,4 +114,4 @@ COPY --from=tools /usr/local/bin/terrascan /usr/local/bin/terrascan
COPY --from=tools /usr/local/bin/trivy /usr/local/bin/trivy
COPY --from=builder /opt/built .

CMD trap 'exit' INT; /opt/app/bin/${APP_NAME} foreground
CMD trap 'exit' INT; /opt/app/bin/${APP_NAME} start
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
84 changes: 82 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,93 @@ defmodule Plural.MixProject do
"coveralls.detail": :test,
"coveralls.post": :test,
"coveralls.html": :test
]
],
releases: releases()
]
end

defp releases() do
[
plural: [
include_executables_for: [:unix],
include_erts: true,
strip_beams: true,
quiet: false,
config_providers: [
{Config.Reader, {:system, "RELEASE_ROOT", "/apps/core/config/releases.exs"}},
],
steps: [:assemble, &copy_configs/1],
applications: [
api: :permanent,
core: :permanent,
email: :permanent,
graphql: :permanent
]
],
rtc: [
include_executables_for: [:unix],
include_erts: true,
strip_beams: true,
quiet: false,
config_providers: [
{Config.Reader, {:system, "RELEASE_ROOT", "/apps/rtc/config/releases.exs"}},
],
steps: [:assemble, &copy_configs/1],
applications: [
rtc: :permanent,
core: :permanent,
graphql: :permanent
]
],
worker: [
include_executables_for: [:unix],
include_erts: true,
strip_beams: true,
quiet: false,
config_providers: [
{Config.Reader, {:system, "RELEASE_ROOT", "/apps/worker/config/releases.exs"}},
],
steps: [:assemble, &copy_configs/1],
applications: [
worker: :permanent,
core: :permanent
]
],
cron: [
include_executables_for: [:unix],
include_erts: true,
strip_beams: true,
quiet: false,
config_providers: [
{Config.Reader, {:system, "RELEASE_ROOT", "/apps/cron/config/releases.exs"}},
],
steps: [:assemble, &copy_configs/1],
applications: [
cron: :permanent,
core: :permanent,
email: :permanent
]
],
]
end

defp copy_configs(%{path: path, config_providers: config_providers} = release) do
for {_module, {_context, _root, file_path}} <- config_providers do
# Creating new path
new_path = path <> Path.dirname(file_path)
# Removing possible leftover files from previous builds
File.rm_rf!(new_path)
# Creating directory if it doesn't exist
File.mkdir_p!(new_path)
# Copying files to the directory with the same name
File.cp!(Path.expand(Path.relative(file_path)), new_path <> "/" <> Path.basename(file_path))
end

release
end

defp deps do
[
{:distillery, "~> 2.1"},
{:x509, "~> 0.8.5"},
{:shards, "~> 1.0"},
{:ecto, "~> 3.9.0", override: true},
Expand Down
1 change: 0 additions & 1 deletion mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"decimal": {:hex, :decimal, "2.0.0", "a78296e617b0f5dd4c6caf57c714431347912ffb1d0842e998e9792b5642d697", [:mix], [], "hexpm", "34666e9c55dea81013e77d9d87370fe6cb6291d1ef32f46a1600230b1d44f577"},
"decorator": {:hex, :decorator, "1.4.0", "a57ac32c823ea7e4e67f5af56412d12b33274661bb7640ec7fc882f8d23ac419", [:mix], [], "hexpm", "0a07cedd9083da875c7418dea95b78361197cf2bf3211d743f6f7ce39656597f"},
"dictionary": {:hex, :dictionary, "0.1.1", "fb333a3ee04c514231f0a5e166dd1c27429620b0dabb12fd42e5d28b11657a0a", [:mix], [], "hexpm", "17bae452ab5ecf7bdd75315c6adb44622242de9cf700ab107865ab5557443c2b"},
"distillery": {:hex, :distillery, "2.1.1", "f9332afc2eec8a1a2b86f22429e068ef35f84a93ea1718265e740d90dd367814", [:mix], [{:artificery, "~> 0.2", [hex: :artificery, repo: "hexpm", optional: false]}], "hexpm", "bbc7008b0161a6f130d8d903b5b3232351fccc9c31a991f8fcbf2a12ace22995"},
"dns": {:hex, :dns, "2.4.0", "44790a0375b28bdc7b59fc894460bfcb03ffeec4c5984e2c3e8b0797b1518327", [:mix], [], "hexpm", "e178e353c469820d02ba889d6a80d01c8c27b47dfcda4016a9cbc6218e3eed64"},
"earmark": {:hex, :earmark, "1.4.2", "3aa0bd23bc4c61cf2f1e5d752d1bb470560a6f8539974f767a38923bb20e1d7f", [:mix], [], "hexpm", "5e8806285d8a3a8999bd38e4a73c58d28534c856bc38c44818e5ba85bbda16fb"},
"ecto": {:hex, :ecto, "3.9.1", "67173b1687afeb68ce805ee7420b4261649d5e2deed8fe5550df23bab0bc4396", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "c80bb3d736648df790f7f92f81b36c922d9dd3203ca65be4ff01d067f54eb304"},
Expand Down
76 changes: 0 additions & 76 deletions rel/config.exs

This file was deleted.

6 changes: 6 additions & 0 deletions rel/env.bat.eex
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@echo off
rem Set the release to work across nodes. If using the long name format like
rem the one below ([email protected]), you need to also uncomment the
rem RELEASE_DISTRIBUTION variable below. Must be "sname", "name" or "none".
rem set RELEASE_DISTRIBUTION=name
set RELEASE_NODE=<%= @release.name %>@${POD_IP}
18 changes: 18 additions & 0 deletions rel/env.sh.eex
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

# Sets and enables heart (recommended only in daemon mode)
# case $RELEASE_COMMAND in
# daemon*)
# HEART_COMMAND="$RELEASE_ROOT/bin/$RELEASE_NAME $RELEASE_COMMAND"
# export HEART_COMMAND
# export ELIXIR_ERL_OPTIONS="-heart"
# ;;
# *)
# ;;
# esac

# Set the release to work across nodes. If using the long name format like
# the one below ([email protected]), you need to also uncomment the
# RELEASE_DISTRIBUTION variable below. Must be "sname", "name" or "none".
# export RELEASE_DISTRIBUTION=name
export RELEASE_NODE=<%= @release.name %>@${POD_IP}
3 changes: 0 additions & 3 deletions rel/plugins/.gitignore

This file was deleted.

11 changes: 11 additions & 0 deletions rel/remote.vm.args.eex
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## Customize flags given to the VM: https://erlang.org/doc/man/erl.html
## -mode/-name/-sname/-setcookie are configured via env vars, do not set them here

## Number of dirty schedulers doing IO work (file, sockets, and others)
##+SDio 5

## Increase number of concurrent ports/sockets
##+Q 65536

## Tweak GC to run more often
##-env ERL_FULLSWEEP_AFTER 10
30 changes: 0 additions & 30 deletions rel/vm.args

This file was deleted.

11 changes: 11 additions & 0 deletions rel/vm.args.eex
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## Customize flags given to the VM: https://erlang.org/doc/man/erl.html
## -mode/-name/-sname/-setcookie are configured via env vars, do not set them here

## Number of dirty schedulers doing IO work (file, sockets, and others)
##+SDio 5

## Increase number of concurrent ports/sockets
##+Q 65536

## Tweak GC to run more often
##-env ERL_FULLSWEEP_AFTER 10