aboutsummaryrefslogtreecommitdiff
path: root/cluster/prod/app/plume
diff options
context:
space:
mode:
Diffstat (limited to 'cluster/prod/app/plume')
-rw-r--r--cluster/prod/app/plume/build/docker-compose.yml8
-rw-r--r--cluster/prod/app/plume/build/plume/Dockerfile54
-rw-r--r--cluster/prod/app/plume/build/plume/README.md3
-rw-r--r--cluster/prod/app/plume/config/app.env32
-rw-r--r--cluster/prod/app/plume/deploy/plume.hcl82
-rw-r--r--cluster/prod/app/plume/integration/bottin.json31
-rw-r--r--cluster/prod/app/plume/integration/docker-compose.yml28
-rw-r--r--cluster/prod/app/plume/integration/plume.env31
-rw-r--r--cluster/prod/app/plume/secrets/plume/backup_aws_access_key_id1
-rw-r--r--cluster/prod/app/plume/secrets/plume/backup_aws_secret_access_key1
-rw-r--r--cluster/prod/app/plume/secrets/plume/backup_restic_password1
-rw-r--r--cluster/prod/app/plume/secrets/plume/backup_restic_repository1
-rw-r--r--cluster/prod/app/plume/secrets/plume/pgsql_pw1
-rw-r--r--cluster/prod/app/plume/secrets/plume/secret_key1
14 files changed, 275 insertions, 0 deletions
diff --git a/cluster/prod/app/plume/build/docker-compose.yml b/cluster/prod/app/plume/build/docker-compose.yml
new file mode 100644
index 0000000..560f539
--- /dev/null
+++ b/cluster/prod/app/plume/build/docker-compose.yml
@@ -0,0 +1,8 @@
+version: '3.4'
+services:
+ plume:
+ build:
+ context: ./plume
+ args:
+ VERSION: 8709f6cf9f8ff7e3c5ee7ea699ee7c778e92fefc
+ image: superboum/plume:v8
diff --git a/cluster/prod/app/plume/build/plume/Dockerfile b/cluster/prod/app/plume/build/plume/Dockerfile
new file mode 100644
index 0000000..1f57a52
--- /dev/null
+++ b/cluster/prod/app/plume/build/plume/Dockerfile
@@ -0,0 +1,54 @@
+FROM rust:1.58.1-slim-bullseye as builder
+
+RUN apt-get update && \
+ apt-get install -y \
+ pkg-config \
+ git \
+ curl \
+ postgresql \
+ postgresql-contrib \
+ libpq-dev \
+ gettext \
+ git \
+ python \
+ curl \
+ gcc \
+ make \
+ openssl \
+ libssl-dev \
+ libclang-dev
+
+ARG VERSION
+WORKDIR /opt
+RUN git clone -n https://git.joinplu.me/Plume/Plume.git plume
+
+WORKDIR /opt/plume
+RUN git checkout ${VERSION}
+
+WORKDIR /opt/plume/script
+RUN chmod a+x ./wasm-deps.sh && ./wasm-deps.sh
+
+WORKDIR /opt/plume
+RUN cargo install wasm-pack
+RUN chmod a+x ./script/plume-front.sh && ./script/plume-front.sh
+RUN cargo install --path ./ --force --no-default-features --features postgres
+RUN cargo install --path plume-cli --force --no-default-features --features postgres
+RUN cargo clean
+
+#-----------------------------
+FROM debian:bullseye-slim
+
+RUN apt-get update && apt-get install -y --no-install-recommends \
+ ca-certificates \
+ libpq5 \
+ libssl1.1 \
+ rclone \
+ fuse
+
+WORKDIR /app
+
+COPY --from=builder /opt/plume /app
+COPY --from=builder /usr/local/cargo/bin/plm /usr/local/bin/
+COPY --from=builder /usr/local/cargo/bin/plume /usr/local/bin/
+
+CMD ["plume"]
diff --git a/cluster/prod/app/plume/build/plume/README.md b/cluster/prod/app/plume/build/plume/README.md
new file mode 100644
index 0000000..6d86d81
--- /dev/null
+++ b/cluster/prod/app/plume/build/plume/README.md
@@ -0,0 +1,3 @@
+Try build:
+
+sudo docker build -t superboum/plume:v1 --build-arg VERSION=003dcf861a9f55720b03d52f2f95f5f59e338809 .
diff --git a/cluster/prod/app/plume/config/app.env b/cluster/prod/app/plume/config/app.env
new file mode 100644
index 0000000..4b389b5
--- /dev/null
+++ b/cluster/prod/app/plume/config/app.env
@@ -0,0 +1,32 @@
+BASE_URL=plume.deuxfleurs.fr
+# generate one with openssl rand -base64 32
+ROCKET_SECRET_KEY={{ key "secrets/plume/secret_key" | trimSpace }}
+
+# Mail settings
+#MAIL_SERVER=smtp.example.org
+#MAIL_USER=example
+#MAIL_PASSWORD=123456
+#MAIL_HELO_NAME=example.org
+
+# DATABASE SETUP
+POSTGRES_PASSWORD={{ key "secrets/plume/pgsql_pw" | trimSpace }}
+POSTGRES_USER=plume
+POSTGRES_DB=plume
+DATABASE_URL=postgres://plume:{{ key "secrets/plume/pgsql_pw" | trimSpace }}@psql-proxy.service.prod.consul:5432/plume
+MIGRATION_DIRECTORY=migrations/postgres
+
+USE_HTTPS=0
+ROCKET_ADDRESS=::
+ROCKET_PORT={{ env "NOMAD_PORT_web_port" }}
+
+MEDIA_UPLOAD_DIRECTORY=/app/static/media
+SEARCH_INDEX=/app/search_index
+
+LDAP_ADDR=ldap://bottin.service.prod.consul:389
+LDAP_BASE_DN=ou=users,dc=deuxfleurs,dc=fr
+LDAP_USER_NAME_ATTR=cn
+LDAP_USER_MAIL_ATTR=mail
+LDAP_TLS=false
+
+RUST_BACKTRACE=1
+RUST_LOG=info
diff --git a/cluster/prod/app/plume/deploy/plume.hcl b/cluster/prod/app/plume/deploy/plume.hcl
new file mode 100644
index 0000000..266a665
--- /dev/null
+++ b/cluster/prod/app/plume/deploy/plume.hcl
@@ -0,0 +1,82 @@
+job "plume-blog" {
+ datacenters = ["dc1"]
+ type = "service"
+
+ constraint {
+ attribute = "${attr.cpu.arch}"
+ value = "amd64"
+ }
+
+ group "plume" {
+ count = 1
+
+ network {
+ port "web_port" { }
+ }
+
+ task "plume" {
+ constraint {
+ attribute = "${attr.unique.hostname}"
+ operator = "="
+ value = "digitale"
+ }
+
+ driver = "docker"
+ config {
+ image = "superboum/plume:v8"
+ network_mode = "host"
+ ports = [ "web_port" ]
+ #command = "cat"
+ #args = [ "/dev/stdout" ]
+ volumes = [
+ "/mnt/ssd/plume/search_index:/app/search_index",
+ "/mnt/ssd/plume/media:/app/static/media"
+ ]
+ }
+
+ template {
+ data = file("../config/app.env")
+ destination = "secrets/app.env"
+ env = true
+ }
+
+ resources {
+ memory = 500
+ cpu = 100
+ }
+
+ service {
+ name = "plume"
+ tags = [
+ "plume",
+ "traefik.enable=true",
+ "traefik.frontend.entryPoints=https,http",
+ "traefik.frontend.rule=Host:plume.deuxfleurs.fr",
+ "tricot plume.deuxfleurs.fr",
+ ]
+ port = "web_port"
+ address_mode = "host"
+ check {
+ type = "http"
+ protocol = "http"
+ port = "web_port"
+ path = "/"
+ interval = "60s"
+ timeout = "5s"
+ check_restart {
+ limit = 3
+ grace = "600s"
+ ignore_warnings = false
+ }
+ }
+ }
+ restart {
+ interval = "30m"
+ attempts = 20
+ delay = "15s"
+ mode = "delay"
+ }
+ }
+ }
+}
+
diff --git a/cluster/prod/app/plume/integration/bottin.json b/cluster/prod/app/plume/integration/bottin.json
new file mode 100644
index 0000000..a970762
--- /dev/null
+++ b/cluster/prod/app/plume/integration/bottin.json
@@ -0,0 +1,31 @@
+{
+ "suffix": "dc=deuxfleurs,dc=fr",
+ "bind": "0.0.0.0:389",
+ "consul_host": "http://consul:8500",
+ "log_level": "debug",
+ "acl": [
+ "*,dc=deuxfleurs,dc=fr::read:*:* !userpassword",
+ "*::read modify:SELF:*",
+ "ANONYMOUS::bind:*,ou=users,dc=deuxfleurs,dc=fr:",
+ "ANONYMOUS::bind:cn=admin,dc=deuxfleurs,dc=fr:",
+ "*,ou=services,ou=users,dc=deuxfleurs,dc=fr::bind:*,ou=users,dc=deuxfleurs,dc=fr:*",
+ "*,ou=services,ou=users,dc=deuxfleurs,dc=fr::read:*:*",
+
+ "*:cn=asso_deuxfleurs,ou=groups,dc=deuxfleurs,dc=fr:add:*,ou=invitations,dc=deuxfleurs,dc=fr:*",
+ "ANONYMOUS::bind:*,ou=invitations,dc=deuxfleurs,dc=fr:",
+ "*,ou=invitations,dc=deuxfleurs,dc=fr::delete:SELF:*",
+
+ "*:cn=asso_deuxfleurs,ou=groups,dc=deuxfleurs,dc=fr:add:*,ou=users,dc=deuxfleurs,dc=fr:*",
+ "*,ou=invitations,dc=deuxfleurs,dc=fr::add:*,ou=users,dc=deuxfleurs,dc=fr:*",
+
+ "*:cn=asso_deuxfleurs,ou=groups,dc=deuxfleurs,dc=fr:modifyAdd:cn=email,ou=groups,dc=deuxfleurs,dc=fr:*",
+ "*,ou=invitations,dc=deuxfleurs,dc=fr::modifyAdd:cn=email,ou=groups,dc=deuxfleurs,dc=fr:*",
+ "*:cn=asso_deuxfleurs,ou=groups,dc=deuxfleurs,dc=fr:modifyAdd:cn=seafile,ou=groups,dc=deuxfleurs,dc=fr:*",
+ "*,ou=invitations,dc=deuxfleurs,dc=fr::modifyAdd:cn=seafile,ou=groups,dc=deuxfleurs,dc=fr:*",
+ "*:cn=asso_deuxfleurs,ou=groups,dc=deuxfleurs,dc=fr:modifyAdd:cn=nextcloud,ou=groups,dc=deuxfleurs,dc=fr:*",
+ "*,ou=invitations,dc=deuxfleurs,dc=fr::modifyAdd:cn=seafile,ou=nextcloud,dc=deuxfleurs,dc=fr:*",
+
+ "cn=admin,dc=deuxfleurs,dc=fr::read add modify delete:*:*",
+ "*:cn=admin,ou=groups,dc=deuxfleurs,dc=fr:read add modify delete:*:*"
+ ]
+}
diff --git a/cluster/prod/app/plume/integration/docker-compose.yml b/cluster/prod/app/plume/integration/docker-compose.yml
new file mode 100644
index 0000000..b88de8a
--- /dev/null
+++ b/cluster/prod/app/plume/integration/docker-compose.yml
@@ -0,0 +1,28 @@
+version: '3.4'
+services:
+ plume:
+ image: superboum/plume:v1
+ env_file:
+ - plume.env
+ depends_on:
+ - consul
+ - postgres
+ ports:
+ - "7878:7878"
+
+ postgres:
+ image: postgres:9.6.19
+ environment:
+ - POSTGRES_DB=plume
+ - POSTGRES_USER=plume
+ - POSTGRES_PASSWORD=plume
+
+ bottin:
+ image: lxpz/bottin_amd64:14
+ depends_on:
+ - consul
+ volumes:
+ - ./bottin.json:/config.json
+
+ consul:
+ image: consul:1.8.4
diff --git a/cluster/prod/app/plume/integration/plume.env b/cluster/prod/app/plume/integration/plume.env
new file mode 100644
index 0000000..88c62dc
--- /dev/null
+++ b/cluster/prod/app/plume/integration/plume.env
@@ -0,0 +1,31 @@
+BASE_URL=integration.env
+# generate one with openssl rand -base64 32
+ROCKET_SECRET_KEY=cXZbKoxWIBo0wdaD8tbA1B3BlH2LBSUmgzdyZZr8QxI=
+
+# Mail settings
+#MAIL_SERVER=smtp.example.org
+#MAIL_USER=example
+#MAIL_PASSWORD=123456
+#MAIL_HELO_NAME=example.org
+
+# DATABASE SETUP
+POSTGRES_PASSWORD=plume
+POSTGRES_USER=plume
+POSTGRES_DB=plume
+DATABASE_URL=postgres://plume:plume@postgres:5432/plume
+MIGRATION_DIRECTORY=migrations/postgres
+
+USE_HTTPS=0
+ROCKET_ADDRESS=0.0.0.0
+ROCKET_PORT=7878
+
+MEDIA_UPLOAD_DIRECTORY=/app/static/media
+SEARCH_INDEX=/app/search_index
+DOMAIN_NAME="integration.env"
+INSTANCE_NAME="Integration Instance"
+
+LDAP_ADDR=ldap://bottin:389
+LDAP_BASE_DN=ou=users,dc=deuxfleurs,dc=fr
+LDAP_USER_NAME_ATTR=cn
+LDAP_USER_MAIL_ATTR=mail
+LDAP_TLS=false
diff --git a/cluster/prod/app/plume/secrets/plume/backup_aws_access_key_id b/cluster/prod/app/plume/secrets/plume/backup_aws_access_key_id
new file mode 100644
index 0000000..9235e53
--- /dev/null
+++ b/cluster/prod/app/plume/secrets/plume/backup_aws_access_key_id
@@ -0,0 +1 @@
+USER Backup AWS access key ID
diff --git a/cluster/prod/app/plume/secrets/plume/backup_aws_secret_access_key b/cluster/prod/app/plume/secrets/plume/backup_aws_secret_access_key
new file mode 100644
index 0000000..f34677e
--- /dev/null
+++ b/cluster/prod/app/plume/secrets/plume/backup_aws_secret_access_key
@@ -0,0 +1 @@
+USER Backup AWS secret access key
diff --git a/cluster/prod/app/plume/secrets/plume/backup_restic_password b/cluster/prod/app/plume/secrets/plume/backup_restic_password
new file mode 100644
index 0000000..fbaa5fa
--- /dev/null
+++ b/cluster/prod/app/plume/secrets/plume/backup_restic_password
@@ -0,0 +1 @@
+USER Restic password to encrypt backups
diff --git a/cluster/prod/app/plume/secrets/plume/backup_restic_repository b/cluster/prod/app/plume/secrets/plume/backup_restic_repository
new file mode 100644
index 0000000..3f6cb93
--- /dev/null
+++ b/cluster/prod/app/plume/secrets/plume/backup_restic_repository
@@ -0,0 +1 @@
+USER Restic repository, eg. s3:https://s3.garage.tld
diff --git a/cluster/prod/app/plume/secrets/plume/pgsql_pw b/cluster/prod/app/plume/secrets/plume/pgsql_pw
new file mode 100644
index 0000000..0f831bb
--- /dev/null
+++ b/cluster/prod/app/plume/secrets/plume/pgsql_pw
@@ -0,0 +1 @@
+SERVICE_PASSWORD plume
diff --git a/cluster/prod/app/plume/secrets/plume/secret_key b/cluster/prod/app/plume/secrets/plume/secret_key
new file mode 100644
index 0000000..978be54
--- /dev/null
+++ b/cluster/prod/app/plume/secrets/plume/secret_key
@@ -0,0 +1 @@
+CMD openssl rand -base64 32