From e5cdb2869f98f1e7aef16460d7fa2459a5f678c8 Mon Sep 17 00:00:00 2001 From: Eliot Berriot Date: Mon, 3 Sep 2018 21:45:17 +0200 Subject: [PATCH] Sample compose file and Dockerfile for deployment --- .dockerignore | 5 +++++ Dockerfile | 20 ++++++++++++++++++++ docs/INSTALL.md | 31 +++++++++++++++++++++++++++++++ docs/docker-compose.sample.yml | 18 ++++++++++++++++++ docs/docker.sample.env | 12 ++++++++++++ 5 files changed, 86 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docs/docker-compose.sample.yml create mode 100644 docs/docker.sample.env diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..98547cd --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +docs +data +Dockerfile +docker-compose.yml +.env diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a13a2f7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +FROM rust:1-stretch + +RUN apt-get update && apt-get install -y --no-install-recommends \ + gettext \ + postgresql-client \ + libpq-dev \ + git \ + curl \ + gcc \ + make \ + openssl \ + libssl-dev +WORKDIR /app +COPY Cargo.toml Cargo.lock ./ +RUN cargo install diesel_cli --no-default-features --features postgres --version '=1.2.0' +COPY . . +RUN cargo build +RUN rm -rf target/debug/incremental +CMD ["cargo", "run"] +EXPOSE 7878 diff --git a/docs/INSTALL.md b/docs/INSTALL.md index fba592d..e3a3651 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -17,6 +17,9 @@ All the following instructions will need a terminal. Here are the commands to install PostgreSQL and GetText on various operating systems. Some of them may need root permissions. +You can also install the project using Docker and docker-compose, please refer +to the `Docker install` section. + On **Debian**: ```bash @@ -142,7 +145,35 @@ mkdir media # Actually start Plume cargo run + +## Docker install + +You can use Docker and docker-compose in order to manage your Plume instance and +have it isolated from your host: + ``` +git clone git@github.com:Plume-org/Plume.git +cd Plume +cp docs/docker-compose.sample.yml docker-compose.yml +cp docs/docker.sample.env .env +# build the containers +docker-compose build +# launch the database +docker-compose up -d postgres +# run the migrations +docker-compose run --rm plume diesel migration run +# run interactive setup +docker-compose run --rm plume bash +cargo run +# copy the env file and paste it in your host .env file +cat .env +# leave the container +exit +# launch your instance for good +docker-compose up -d +``` + +Then, you can configure your reverse proxy. ## Configuring Nginx diff --git a/docs/docker-compose.sample.yml b/docs/docker-compose.sample.yml new file mode 100644 index 0000000..65150e5 --- /dev/null +++ b/docs/docker-compose.sample.yml @@ -0,0 +1,18 @@ +version: '3' + +services: + postgres: + image: postgres:10.5 + env_file: .env + restart: unless-stopped + volumes: + - "./data/postgres:/var/lib/postgresql/data" + plume: + build: . + env_file: .env + restart: unless-stopped + volumes: + - "./data/plume/static/media:/app/media" + - "./.env:/app/.env" + ports: + - "127.0.0.1:7878:7878" diff --git a/docs/docker.sample.env b/docs/docker.sample.env new file mode 100644 index 0000000..9708573 --- /dev/null +++ b/docs/docker.sample.env @@ -0,0 +1,12 @@ +BASE_URL=yourdomain.com +# generate one with openssl rand -base64 45 +ROCKET_SECRET_KEY=randomstringhere + +# you can safely leave those defaults +POSTGRES_USER=plume +POSTGRES_PASSWORD=plume +DB_URL=postgres://plume:plume@postgres:5432/plume +DATABASE_URL=postgres://plume:plume@postgres:5432/plume +USE_HTTPS=1 +ROCKET_ADDRESS=0.0.0.0 +ROCKET_PORT=7878