Commit 214747d4 authored by Thomas Citharel's avatar Thomas Citharel 🏃🏻
Browse files

Merge branch 'docker-dev' into 'master'

Improve the development contributing docs

See merge request !61
parents 9317aa85 616394f4
Pipeline #437479 passed with stage
in 26 seconds
FROM alpine:latest
LABEL maintainer="Thomas Citharel <tcit@tcit.fr>"
ENV MKDOCS_VERSION=1.1.2 \
REFRESHED_AT=2020-10-22
ENV MKDOCS_VERSION=1.2.2 \
REFRESHED_AT=2021-08-04
RUN \
......@@ -15,6 +15,6 @@ RUN \
py3-pip \
build-base && \
pip install --upgrade pip && \
pip install mkdocs==${MKDOCS_VERSION} mkdocs-material pymdown-extensions pygments mkdocs-git-revision-date-localized-plugin mkdocs-minify-plugin mkdocs-exclude && \
pip install mkdocs==${MKDOCS_VERSION} mkdocs[i18n] mkdocs-material pymdown-extensions pygments mkdocs-git-revision-date-localized-plugin mkdocs-minify-plugin mkdocs-exclude && \
rm -rf /tmp/* /var/tmp/* /var/cache/apk/* /var/cache/distfiles/*
# CLI Tasks
Mobilizon provides commands to perform some tasks.
Mobilizon provides commands to perform some tasks. Explore the tasks in the menu.
=== "Releases"
......
......@@ -8,6 +8,9 @@ Clone the repository:
```
=== "SSH"
!!! danger
This requires to have an account on [Framagit](https://framagit.org), our self-hosted Gitlab code forge. You may use the following URI instead of anonymous access: `git://framagit.org/framasoft/mobilizon`, but you won't be able to push any changes that way.
``` bash
git clone git@framagit.org:framasoft/mobilizon.git && cd mobilizon
```
......@@ -19,65 +22,110 @@ Run Mobilizon:
## With Docker
+ Install [Docker](https://docs.docker.com/install/#supported-platforms) and [Docker-Compose](https://docs.docker.com/compose/install/) for your system.
+ Run `make start` to build, then launch a database container and an API container.
+ Follow the progress of the build with `docker-compose logs -f` .
+ Access `localhost:4000` in your browser once the containers are fully built and launched.
+ Install `Make`
+ Install [Docker](https://docs.docker.com/install/#supported-platforms) and [Docker-Compose](https://docs.docker.com/compose/install/) for your system. [Podman](https://podman.io) versions ≥ 3 work as well with `docker-compose`.
+ Run `make setup` to build, then `make` to launch a database container and an API container.
+ Follow the progress of the build with `make logs`.
+ Access [`localhost:4000`](http://localhost:4000) in your browser once the containers are fully built and launched.
+ Stop everything with `make stop`
### Mix tasks
For instance creating an admin user
```bash
docker-compose exec api mix mobilizon.users.new "your@email.com" --admin --password "mypassword"
```
All other Mix commands ([from Mobilizon](../administration/CLI tasks/index.md) and dependencies) are available in the same way. For instance to generate a new migration:
```bash
docker-compose exec api mix ecto.gen.migration MyMigrationModuleName
```
Then once it's written
```bash
docker-compose exec api mix ecto.migrate
```
(or the shortcut version `make migrate`)
## Without Docker
+ Install dependencies:
- [Elixir (and Erlang)](https://elixir-lang.org/install.html)
- PostgreSQL >= 9.6 with PostGIS
- [Install NodeJS](https://nodejs.org/en/download/) (we guarantee support for the latest LTS and later) ![](https://img.shields.io/badge/node-%3E%3D%2012.0+-brightgreen.svg)
+ Start services:
- Start postgres
+ Setup services:
- Make sure the postgis extension is installed on your system.
- Create a postgres user with database creation capabilities, using the
following: `createuser -d -P mobilizon` and set `mobilizon` as the password.
+ Install packages
- Fetch backend Elixir dependencies with `mix deps.get` .
- Go into the `cd js` directory, `yarn install` and then back `cd ../`
+ Setup
- Create your database with `mix ecto.create` .
- Create the postgis extension on the database with a postgres user that has
superuser capabilities: `psql mobilizon_dev`
```psql
create extension if not exists postgis;
```
* Run migrations: `mix ecto.migrate`.
* Generate a Guardian secret with `mix guardian.gen.secret`:
```bash
$ mix guardian.gen.secret
$ TTRcgYH/Y0rk8ph5fqExVWRWjK03cqymfTa70leljmLMsBChtm+6MM+pRrL76Io3
```
* Create a `config/dev.secret.exs` file and add the Guardian config:
```elixir
import Config
config :mobilizon, Mobilizon.Web.Auth.Guardian,
secret_key: "TTRcgYH/Y0rk8ph5fqExVWRWjK03cqymfTa70leljmLMsBChtm+6MM+pRrL76Io3"
```
* Generate your first user with the `mix mobilizon.users.new` task
```bash
$ mix mobilizon.users.new john.doe@localhost.com --admin
A user has been created with the following information:
- email: john.doe@localhost.com
- password: r/EKpKr5o7ngQY+r
- Role: user
The user will be prompted to create a new profile after login for the first time.
```
* Start Phoenix endpoint with `mix phx.server`. The client development server will also automatically be launched and will reload on file change.
### Setup
#### Install system dependencies
You may follow the same guide as for [installing dependencies in source mode](../administration/install/source.md#dependencies).
- [Elixir (and Erlang)](https://elixir-lang.org/install.html)
- PostgreSQL ≥ 11 with PostGIS
- [Install NodeJS](https://nodejs.org/en/download/) (we guarantee support for the latest LTS) ![](https://img.shields.io/badge/node-%3E%3D%2014+-brightgreen.svg)
- `cmake`, `inotify-tools`, ImageMagick, webp and basic build tools
#### Configure the database
Make sure the service is running.
Create a postgres user with database creation capabilities. For instance:
```sh
sudo -i -u postgres
createuser -d -P mobilizon
```
Set `mobilizon` as the password, then `exit`.
#### Install Mobilizon dependencies
- Fetch backend Elixir dependencies with `mix deps.get` (you may need to accept prompts)
- Compile Mobilizon dependencies with `mix deps.compile` (this can take a while and you may need to accept prompts)
- Fetch front-end dependencies with `yarn --cwd "js"`
- Compile front-end with `yarn --cwd "js" run build` (this can take a while)
#### Configure
- Create your database with `mix ecto.create`
- Creating extensions on the database requires a PostgreSQL user with superuser capacities. For instance:
```
sudo -i -u postgres
psql mobilizon_dev
```
Then
```psql
create extension if not exists postgis;
create extension if not exists unaccent;
create extension if not exists pg_trgm;
```
And finally exit both `psql` and the `postgres` system user.
- Run database migrations: `mix ecto.migrate`
- Generate configuration `mix mobilizon.instance gen`. Answer the following for these questions:
* domain: `localhost`
* database host: `localhost` (default)
* database name: `mobilizon_dev`
* database username: `mobilizon` (default)
* database password: `mobilizon` (or whatever you've chosen before)
The rest can be left to default is possible or be set to whatever you prefer.
!!! tip
To make sure URLs are generated properly, edit `config/runtime.exs` and add `, port: 4000` behind `url: [host: "localhost"`.
#### Generate first user
Generate your first user with the `mix mobilizon.users.new` task
```bash
mix mobilizon.users.new john.doe@localhost.com --admin
```
You should have a similar output:
```
A user has been created with the following information:
- email: john.doe@localhost.com
- password: r/EKpKr5o7ngQY+r
- Role: user
The user will be prompted to create a new profile after login for the first time.
```
#### Start the server
Start Phoenix endpoint with `mix phx.server`. The client development server will also automatically be launched and will reload on file change.
Now you can visit [ `localhost:4000` ](http://localhost:4000) in your browser
and see the website (server *and* client) in action.
......
......@@ -10,6 +10,8 @@ Nothing here yet.
* [mobilizon-poster](https://github.com/vecna/mobilizon-poster)
A simple nodejs script(s) to interact with mobilizon via command line
* [mobilizon-bots](https://github.com/Tech-Workers-Coalition-Italia/mobilizon-bots)
Set of tools to publish Mobilizon events to external plaforms (Telegram currently supported)
## CMS
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment