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
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:
@ -37,7 +38,7 @@ Instanciate required Postgres extensions:
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:
@ -48,7 +49,7 @@ Finally, run the application:
Pull the latest image, then run the migrations:
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:

View File

@ -8,19 +8,22 @@ services:
- MOBILIZON_INSTANCE_HOST
- MOBILIZON_INSTANCE_EMAIL
- MOBILIZON_REPLY_EMAIL
- MOBILIZON_INSTANCE_REGISTRATIONS_OPEN=true
- MOBILIZON_ADMIN_EMAIL
- MOBILIZON_INSTANCE_REGISTRATIONS_OPEN
- MOBILIZON_DATABASE_USERNAME=${POSTGRES_USER}
- MOBILIZON_DATABASE_PASSWORD=${POSTGRES_PASSWORD}
- MOBILIZON_DATABASE_DBNAME=${POSTGRES_DB}
- MOBILIZON_DATABASE_HOST=db
- MOBILIZON_INSTANCE_SECRET_KEY_BASE
- MOBILIZON_INSTANCE_SECRET_KEY
- MOBILIZON_SMTP_SERVER=yoursmtpserver
- MOBILIZON_SMTP_HOSTNAME=your.smtp.domain
- MOBILIZON_SMTP_SERVER
- MOBILIZON_SMTP_HOSTNAME
- MOBILIZON_SMTP_PORT
- MOBILIZON_SMTP_SSL
- MOBILIZON_SMTP_USERNAME
- MOBILIZON_SMTP_PASSWORD
volumes:
- ./public/upload:/app/upload
- ./public/uploads:/app/uploads
ports:
- "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
POSTGRES_USER=mobilizon
POSTGRES_PASSWORD=changethis
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
MOBILIZON_INSTANCE_NAME=My Mobilizon Instance
MOBILIZON_INSTANCE_HOST=mobilizon.lan
MOBILIZON_INSTANCE_SECRET_KEY_BASE=changethis
MOBILIZON_INSTANCE_SECRET_KEY=changethis
MOBILIZON_INSTANCE_EMAIL=noreply@mobilizon.lan
MOBILIZON_REPLY_EMAIL=contact@mobilizon.lan
# Email settings
MOBILIZON_SMPT_SERVER=localhost
MOBILIZON_SMPT_HOSTNAME=localhost
MOBILIZON_SMPT_USERNAME=noreply@mobilizon.lan
MOBILIZON_SMPT_PASSWORD=password
MOBILIZON_SMTP_SERVER=localhost
MOBILIZON_SMTP_HOSTNAME=localhost
MOBILIZON_SMTP_USERNAME=noreply@mobilizon.lan
MOBILIZON_SMTP_PASSWORD=password

View File

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

View File

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

View File

@ -1,4 +1,4 @@
defmodule Mobilizon.Cli do
defmodule Mobilizon.CLI do
@app :mobilizon
def migrate do

View File

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