From 1f7bd93c5f4b939938c276bb59d41225539e2343 Mon Sep 17 00:00:00 2001 From: caminsha <31421093+caminsha@users.noreply.github.com> Date: Sat, 14 Aug 2021 12:24:38 +0200 Subject: Use environment variables (#3756) * Add .env file for docker-compose (fix #3755) Adding a .env has the advantage that the configuration can be stored in a separate file and it'll be possible to just get the newest docker-compose.yml file. * Update documentation for the .env file * Update Docker/README.md Co-authored-by: Frans de Jonge Co-authored-by: Frans de Jonge --- Docker/.env | 25 +++++++++++++++++++++++++ Docker/README.md | 7 ++++++- Docker/docker-compose.yml | 8 ++++---- 3 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 Docker/.env (limited to 'Docker') diff --git a/Docker/.env b/Docker/.env new file mode 100644 index 000000000..2b7a46618 --- /dev/null +++ b/Docker/.env @@ -0,0 +1,25 @@ +# Environment file for docker-compose +# In this file you need to define the different settings + + +# ==================================== +# Database +# ==================================== + + +# Database to use for freshrss +POSTGRES_DB=freshrss + +# User in the freshrss database +POSTGRES_USER=freshrss + +# Password for the defined user +POSTGRES_PASSWORD=freshrss + + +# ==================================== +# FreshRSS +# ==================================== + +# Exposed port for the docker-container +EXPOSED_PORT=8080 \ No newline at end of file diff --git a/Docker/README.md b/Docker/README.md index d63299de9..3353768ae 100644 --- a/Docker/README.md +++ b/Docker/README.md @@ -308,11 +308,16 @@ A [docker-compose.yml](docker-compose.yml) file is given as an example, using Po - In the `postgresql` service: * `container_name` directive. Whatever you set this to will be the value you put in the "Host" field during the "Database Configuration" step of installation; * the `volumes` section. Be careful to keep the path `/var/lib/postgresql/data` for the container. If the path is wrong, you will not get any error but your db will be gone at the next run; - * the `POSTGRES_PASSWORD` in the `environment` section; + * the `POSTGRES_PASSWORD` in the `.env` file; + * the `POSTGRES_DB ` in the `.env` file; + * the `POSTGRES_USER` in the `.env` file; - In the `freshrss` service: * the `volumes` section; * options under the `labels` section are specific to [Træfik](https://traefik.io/), a reverse proxy. If you are not using it, feel free to delete this section. If you are using it, adapt accordingly to your config, especially the `traefik.frontend.rule` option. * the `environment` section to adapt the strategy to update feeds. + * the `EXPOSED_PORT` variable in the `.env` file; + +If you don't want to use the `.env` file you can also directly edit the `docker-compose.yml` file. It's highly recommended to change the password. If you don't change it, it will use the default option. You can then launch the stack (FreshRSS + PostgreSQL) with: diff --git a/Docker/docker-compose.yml b/Docker/docker-compose.yml index 8fcc6f6d6..1f93a80cf 100644 --- a/Docker/docker-compose.yml +++ b/Docker/docker-compose.yml @@ -9,9 +9,9 @@ services: volumes: - db:/var/lib/postgresql/data environment: - POSTGRES_USER: freshrss - POSTGRES_PASSWORD: freshrss - POSTGRES_DB: freshrss + POSTGRES_USER: ${POSTGRES_USER:-freshrss} + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-freshrss} + POSTGRES_DB: ${POSTGRES_DB:-freshrss} freshrss-app: image: freshrss/freshrss:latest @@ -19,7 +19,7 @@ services: hostname: freshrss-app restart: unless-stopped ports: - - "8080:80" + - "${EXPOSED_PORT:-8080}:80" depends_on: - freshrss-db volumes: -- cgit v1.2.3