From 8310ae46cd694b973ae90ffaff0466405ac80af4 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Fri, 2 Jul 2021 15:48:40 +0200 Subject: [PATCH] Restore Docker development Signed-off-by: Thomas Citharel --- .env.template | 25 +++++++++++++++++++++++++ Dockerfile | 4 ++-- config/dev.exs | 11 ++--------- docker-compose.yml | 27 ++++++++++++++++----------- 4 files changed, 45 insertions(+), 22 deletions(-) create mode 100644 .env.template diff --git a/.env.template b/.env.template new file mode 100644 index 000000000..e49bfb2b3 --- /dev/null +++ b/.env.template @@ -0,0 +1,25 @@ +# Database settings +POSTGRES_USER=mobilizon +POSTGRES_PASSWORD=changethis +POSTGRES_DB=mobilizon +POSTGRES_PORT=5432 + +# Instance configuration +MOBILIZON_INSTANCE_REGISTRATIONS_OPEN=false +MOBILIZON_INSTANCE_NAME=My Mobilizon Instance +MOBILIZON_INSTANCE_HOST=mobilizon.lan +MOBILIZON_INSTANCE_PORT=4000 + +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_SMTP_SERVER=localhost +MOBILIZON_SMTP_PORT=25 +MOBILIZON_SMTP_HOSTNAME=localhost +MOBILIZON_SMTP_USERNAME=noreply@mobilizon.lan +MOBILIZON_SMTP_PASSWORD=password +MOBILIZON_SMTP_SSL=false diff --git a/Dockerfile b/Dockerfile index 01cde6868..0c80b83da 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ -FROM bitwalker/alpine-elixir:latest +FROM elixir:alpine -RUN apk add --no-cache inotify-tools postgresql-client yarn file make gcc libc-dev argon2 imagemagick cmake build-base libwebp-tools bash ncurses +RUN apk add --no-cache inotify-tools postgresql-client yarn file make gcc libc-dev argon2 imagemagick cmake build-base libwebp-tools bash ncurses git RUN mix local.hex --force && mix local.rebar --force diff --git a/config/dev.exs b/config/dev.exs index 23e63beb0..eaa1eff7d 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -1,19 +1,12 @@ import Config -# For development, we disable any cache and enable -# debugging and code reloading. -# -# The watchers configuration can be used to run external -# watchers to your application. For example, we use it -# with brunch.io to recompile .js and .css sources. config :mobilizon, Mobilizon.Web.Endpoint, http: [ - ip: {127, 0, 0, 1}, - port: 4000 + port: String.to_integer(System.get_env("MOBILIZON_INSTANCE_HOST_PORT", "4000")) ], url: [ host: System.get_env("MOBILIZON_INSTANCE_HOST", "mobilizon.local"), - port: 80, + port: String.to_integer(System.get_env("MOBILIZON_INSTANCE_HOST_PORT", "80")), scheme: "http" ], debug_errors: true, diff --git a/docker-compose.yml b/docker-compose.yml index 8726415ba..58bb0986a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,13 +1,14 @@ -version: "3" - +version: "3.2" services: postgres: container_name: mobilizon_db restart: unless-stopped - image: postgis/postgis:13-3.0 + image: postgis/postgis environment: - POSTGRES_PASSWORD: postgres - POSTGRES_DB: mobilizon_dev + - POSTGRES_USER + - POSTGRES_PASSWORD + - POSTGRES_DB + - POSTGRES_PORT volumes: - pgdata:/var/lib/postgresql/data api: @@ -17,23 +18,27 @@ services: volumes: - ".:/app" ports: - - "4000:4000" + - 4000:4000 depends_on: - postgres environment: MIX_ENV: "dev" DOCKER: "true" MOBILIZON_INSTANCE_NAME: My Mobilizon Instance - MOBILIZON_INSTANCE_HOST: mobilizon.me + MOBILIZON_INSTANCE_HOST: localhost + MOBILIZON_INSTANCE_HOST_PORT: 4000 + MOBILIZON_INSTANCE_PORT: 4000 MOBILIZON_INSTANCE_EMAIL: noreply@mobilizon.me MOBILIZON_INSTANCE_REGISTRATIONS_OPEN: "true" - MOBILIZON_DATABASE_PASSWORD: postgres - MOBILIZON_DATABASE_USERNAME: postgres - MOBILIZON_DATABASE_DBNAME: mobilizon_dev + MOBILIZON_DATABASE_PASSWORD: ${POSTGRES_PASSWORD} + MOBILIZON_DATABASE_USERNAME: ${POSTGRES_USER} + MOBILIZON_DATABASE_DBNAME: ${POSTGRES_DB} MOBILIZON_DATABASE_HOST: postgres + MOBILIZON_DATABASE_PORT: ${POSTGRES_PORT} command: > sh -c "cd js && - yarn install && + yarn --cwd "js" install && + yarn --cwd "js" run build:pictures && cd ../ && mix deps.get && mix compile &&