Add more documentation on deployment in production

This commit is contained in:
Alex
2022-11-30 23:03:57 +01:00
parent e6a7d92718
commit 6e016962c4
6 changed files with 161 additions and 9 deletions

View File

@@ -19,4 +19,5 @@ _Security updates_
## v1.2.0
- Added password change form in settings
- Added password change form in settings
- Added more documentation on deployment in production

View File

@@ -58,7 +58,7 @@ To get a local copy up and running follow these simple example steps.
To run Claper on your local environment you need to have:
* Postgres >= 9
* Elixir >= 1.13.2
* Erland >= 24
* Erlang >= 24
* NPM >= 6.14.17
* NodeJS >= 14.19.2
* Ghostscript >= 9.5.0 (for PDF support)

View File

@@ -0,0 +1,150 @@
# Deployment
## Prerequisites
To run Claper on your production environment you need to have:
* Postgres >= 9
* Elixir >= 1.13.2
* Erlang >= 24
* NPM >= 6.14.17
* NodeJS >= 14.19.2
* Ghostscript >= 9.5.0 (for PDF support)
* Libreoffice >= 6.4 (for PPT/PPTX support)
## Steps (without docker)
1. Clone the repo
```sh
git clone https://github.com/ClaperCo/Claper.git
```
2. Install dependencies
```sh
mix deps.get --only prod
```
3. Migrate your database
```sh
mix ecto.migrate
```
4. Compile assets
```sh
MIX_ENV=prod mix compile
```
5. Deploy assets
```sh
MIX_ENV=prod mix assets.deploy
```
6. Start Phoenix endpoint with
```sh
MIX_ENV=prod mix phx.server
```
You can follow the steps from the official Phoenix guide for further details and release management: [Introduction to Deployement](https://hexdocs.pm/phoenix/deployment.html) and [Deploying with Releases](https://hexdocs.pm/phoenix/releases.html).
## Steps (with docker)
You can follow the same steps as in the [installation guide](/installation.html#using-docker) to run Claper with Docker.
## Behind Nginx
This an example of Nginx configuration file to run Claper behind Nginx.
```nginx
server {
listen 80;
server_name app.claper.co; # Your own domain
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_pass http://localhost:4000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
```
## Behind Traefik
Here is a docker-compose example to run Claper behind Traefik.
```yaml
version: "3.0"
services:
db:
image: postgres:9
environment:
POSTGRES_PASSWORD: claper
POSTGRES_USER: claper
POSTGRES_DB: claper
app:
build: .
environment:
DATABASE_URL: postgres://claper:claper@db:5432/claper
SECRET_KEY_BASE: 0LZiQBLw4WvqPlz4cz8RsHJlxNiSqM9B48y4ChyJ5v1oA0L/TPIqRjQNdPZN3iEG
MAIL_TRANSPORT: local
ENDPOINT_HOST: claper.local
ENDPOINT_PORT: 4000
labels:
- "traefik.enable=true"
- "traefik.http.routers.claper.rule=Host(`claper.local`)"
- "traefik.http.routers.claper.entrypoints=web"
depends_on:
- db
- traefik
traefik:
image: traefik
command:
#- "--log.level=DEBUG"
- "--api.insecure=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
ports:
- "80:80"
- "8080:8080"
```
## Behind Kubernetes
Change the `rel/env.sh.eex` file to uncomment:
```sh
export POD_A_RECORD=$(echo $POD_IP | sed 's/\./-/g')
export RELEASE_DISTRIBUTION=name
export RELEASE_NODE=<%= @release.name %>@$(echo $POD_A_RECORD).$(echo $NAMESPACE).pod.cluster.local
```
and comment as follows:
```sh
#export RELEASE_DISTRIBUTION=sname
#export RELEASE_NODE=<%= @release.name %>
```
In Kubernetes, you have to use `libcluster` to make the nodes discoverable. You can use the following configuration in your `config/prod.exs`:
```elixir
config :libcluster,
topologies: [
default: [
strategy: Cluster.Strategy.Kubernetes,
config: [
mode: :dns,
kubernetes_node_basename: "claper",
kubernetes_selector: "app=claper",
kubernetes_namespace: "default",
polling_interval: 10_000
]
]
]
```
### Helm chart
You can check the [Claper Helm chart](https://github.com/ClaperCo/Claper/tree/main/charts/claper) to deploy Claper on Kubernetes.

View File

@@ -1,11 +1,11 @@
# Installation
# Local installation
## Prerequisites
To run Claper on your local environment you need to have:
* Postgres >= 9
* Elixir >= 1.13.2
* Erland >= 24
* Erlang >= 24
* NPM >= 6.14.17
* NodeJS >= 14.19.2
* Ghostscript >= 9.5.0 (for PDF support)

View File

@@ -27,6 +27,7 @@ defmodule Claper.MixProject do
"guides/introduction/overview.md",
"guides/introduction/configuration.md",
"guides/introduction/installation.md",
"guides/introduction/deployment.md",
"guides/introduction/storage.md",
"guides/usage/features.md",
"guides/usage/howto.md"

View File

@@ -13,9 +13,9 @@
# Set the release to work across nodes.
# RELEASE_DISTRIBUTION must be "sname" (local), "name" (distributed) or "none".
#export RELEASE_DISTRIBUTION=sname
#export RELEASE_NODE=<%= @release.name %>
export RELEASE_DISTRIBUTION=sname
export RELEASE_NODE=<%= @release.name %>
export POD_A_RECORD=$(echo $POD_IP | sed 's/\./-/g')
export RELEASE_DISTRIBUTION=name
export RELEASE_NODE=<%= @release.name %>@$(echo $POD_A_RECORD).$(echo $NAMESPACE).pod.cluster.local
#export POD_A_RECORD=$(echo $POD_IP | sed 's/\./-/g')
#export RELEASE_DISTRIBUTION=name
#export RELEASE_NODE=<%= @release.name %>@$(echo $POD_A_RECORD).$(echo $NAMESPACE).pod.cluster.local