Jelajahi Sumber

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 <fransdejonge@gmail.com>

Co-authored-by: Frans de Jonge <fransdejonge@gmail.com>
caminsha 4 tahun lalu
induk
melakukan
1f7bd93c5f
3 mengubah file dengan 35 tambahan dan 5 penghapusan
  1. 25 0
      Docker/.env
  2. 6 1
      Docker/README.md
  3. 4 4
      Docker/docker-compose.yml

+ 25 - 0
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

+ 6 - 1
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:
 

+ 4 - 4
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: