Fix Mix.env use in prod app & MR threads

This commit is contained in:
prichier 2020-10-27 16:40:14 +01:00
parent 1acff2dd8a
commit 751b72a434
7 changed files with 22 additions and 24 deletions

View File

@ -17,6 +17,7 @@ You will need to :
cp env.example .env cp env.example .env
Edit the `.env` content with your own settings. Edit the `.env` content with your own settings.
More settings can be added in .env, see all in docker-compose.yml file.
You can generate `MOBILIZON_INSTANCE_SECRET_KEY_BASE` and `MOBILIZON_INSTANCE_SECRET_KEY` with: You can generate `MOBILIZON_INSTANCE_SECRET_KEY_BASE` and `MOBILIZON_INSTANCE_SECRET_KEY` with:
@ -37,7 +38,7 @@ Instanciate required Postgres extensions:
Then run migrations: Then run migrations:
docker-compose run --rm mobilizon eval Mobilizon.Cli.migrate docker-compose run --rm mobilizon eval Mobilizon.CLI.migrate
Finally, run the application: Finally, run the application:
@ -48,7 +49,7 @@ Finally, run the application:
Pull the latest image, then run the migrations: Pull the latest image, then run the migrations:
docker-compose pull mobilizon docker-compose pull mobilizon
docker-compose run --rm mobilizon eval Mobilizon.Cli.migrate docker-compose run --rm mobilizon eval Mobilizon.CLI.migrate
Finally, update the service: Finally, update the service:

View File

@ -8,19 +8,22 @@ services:
- MOBILIZON_INSTANCE_HOST - MOBILIZON_INSTANCE_HOST
- MOBILIZON_INSTANCE_EMAIL - MOBILIZON_INSTANCE_EMAIL
- MOBILIZON_REPLY_EMAIL - MOBILIZON_REPLY_EMAIL
- MOBILIZON_INSTANCE_REGISTRATIONS_OPEN=true - MOBILIZON_ADMIN_EMAIL
- MOBILIZON_INSTANCE_REGISTRATIONS_OPEN
- MOBILIZON_DATABASE_USERNAME=${POSTGRES_USER} - MOBILIZON_DATABASE_USERNAME=${POSTGRES_USER}
- MOBILIZON_DATABASE_PASSWORD=${POSTGRES_PASSWORD} - MOBILIZON_DATABASE_PASSWORD=${POSTGRES_PASSWORD}
- MOBILIZON_DATABASE_DBNAME=${POSTGRES_DB} - MOBILIZON_DATABASE_DBNAME=${POSTGRES_DB}
- MOBILIZON_DATABASE_HOST=db - MOBILIZON_DATABASE_HOST=db
- MOBILIZON_INSTANCE_SECRET_KEY_BASE - MOBILIZON_INSTANCE_SECRET_KEY_BASE
- MOBILIZON_INSTANCE_SECRET_KEY - MOBILIZON_INSTANCE_SECRET_KEY
- MOBILIZON_SMTP_SERVER=yoursmtpserver - MOBILIZON_SMTP_SERVER
- MOBILIZON_SMTP_HOSTNAME=your.smtp.domain - MOBILIZON_SMTP_HOSTNAME
- MOBILIZON_SMTP_PORT
- MOBILIZON_SMTP_SSL
- MOBILIZON_SMTP_USERNAME - MOBILIZON_SMTP_USERNAME
- MOBILIZON_SMTP_PASSWORD - MOBILIZON_SMTP_PASSWORD
volumes: volumes:
- ./public/upload:/app/upload - ./public/uploads:/app/uploads
ports: ports:
- "4000:4000" - "4000:4000"

View File

@ -1,27 +1,21 @@
# Copy this file to env, then update it with your own settings # Copy this file to .env, then update it with your own settings
hostname=mobilizon.lan
# Database settings # Database settings
POSTGRES_USER=mobilizon POSTGRES_USER=mobilizon
POSTGRES_PASSWORD=changethis POSTGRES_PASSWORD=changethis
POSTGRES_DB=mobilizon POSTGRES_DB=mobilizon
# Application config
MOBILIZON_INSTANCE_SECRET_KEY_BASE=changethis
MOBILIZON_INSTANCE_SECRET_KEY=changethis
MOBILIZON_SMTP_USERNAME=username
MOBILIZON_SMPT_PASSWORD=password
POSTGRES_PASSWORD=postgres
# Instance configuration # Instance configuration
MOBILIZON_INSTANCE_NAME=My Mobilizon Instance MOBILIZON_INSTANCE_NAME=My Mobilizon Instance
MOBILIZON_INSTANCE_HOST=mobilizon.lan
MOBILIZON_INSTANCE_SECRET_KEY_BASE=changethis MOBILIZON_INSTANCE_SECRET_KEY_BASE=changethis
MOBILIZON_INSTANCE_SECRET_KEY=changethis MOBILIZON_INSTANCE_SECRET_KEY=changethis
MOBILIZON_INSTANCE_EMAIL=noreply@mobilizon.lan MOBILIZON_INSTANCE_EMAIL=noreply@mobilizon.lan
MOBILIZON_REPLY_EMAIL=contact@mobilizon.lan MOBILIZON_REPLY_EMAIL=contact@mobilizon.lan
# Email settings # Email settings
MOBILIZON_SMPT_SERVER=localhost MOBILIZON_SMTP_SERVER=localhost
MOBILIZON_SMPT_HOSTNAME=localhost MOBILIZON_SMTP_HOSTNAME=localhost
MOBILIZON_SMPT_USERNAME=noreply@mobilizon.lan MOBILIZON_SMTP_USERNAME=noreply@mobilizon.lan
MOBILIZON_SMPT_PASSWORD=password MOBILIZON_SMTP_PASSWORD=password

View File

@ -79,7 +79,7 @@ defmodule Mobilizon.Federation.ActivityPub.Federator do
def enqueue(type, payload, priority \\ 1) do def enqueue(type, payload, priority \\ 1) do
Logger.debug("enqueue something with type #{inspect(type)}") Logger.debug("enqueue something with type #{inspect(type)}")
if Mix.env() == :test do if Application.fetch_env!(:mobilizon, :env) == :test do
handle(type, payload) handle(type, payload)
else else
GenServer.cast(__MODULE__, {:enqueue, type, payload, priority}) GenServer.cast(__MODULE__, {:enqueue, type, payload, priority})

View File

@ -21,7 +21,7 @@ defmodule Mobilizon do
@name Mix.Project.config()[:name] @name Mix.Project.config()[:name]
@version Mix.Project.config()[:version] @version Mix.Project.config()[:version]
@env Mix.env() @env Application.fetch_env!(:mobilizon, :env)
@spec named_version :: String.t() @spec named_version :: String.t()
def named_version, do: "#{@name} #{@version}" def named_version, do: "#{@name} #{@version}"

View File

@ -1,4 +1,4 @@
defmodule Mobilizon.Cli do defmodule Mobilizon.CLI do
@app :mobilizon @app :mobilizon
def migrate do def migrate do
@ -8,4 +8,4 @@ defmodule Mobilizon.Cli do
{:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :up, all: true)) {:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :up, all: true))
end end
end end
end end

View File

@ -169,7 +169,7 @@ defmodule Mobilizon.Web.Router do
get("/:sig/:url/:filename", MediaProxyController, :remote) get("/:sig/:url/:filename", MediaProxyController, :remote)
end end
if Mix.env() in [:dev, :e2e] do if Application.fetch_env!(:mobilizon, :env) in [:dev, :e2e] do
# If using Phoenix # If using Phoenix
forward("/sent_emails", Bamboo.SentEmailViewerPlug) forward("/sent_emails", Bamboo.SentEmailViewerPlug)
end end