Home Posts About Admin

Previous Next

discource by podman

Feb. 28, 2022, 11:31 p.m. by lufy


Discourse® packaged by Bitnami

from: https://hub.docker.com/r/bitnami/discourse/

What is Discourse®?

Discourse is an open source discussion platform with built-in moderation and governance systems that let discussion communities protect themselves from bad actors even without official moderators.

Overview of Discourse®

Trademarks: This software listing is packaged by Bitnami. The respective trademarks mentioned in the offering are owned by the respective companies, and use of them does not imply any affiliation or endorsement.

TL;DR

$ curl -sSL https://raw.githubusercontent.com/bitnami/bitnami-docker-discourse/master/docker-compose.yml > docker-compose.yml
$ docker-compose up -d

Warning: This quick setup is only intended for development environments. You are encouraged to change the insecure default credentials and check out the available configuration options in the Environment Variables section for a more secure deployment.

Why use Bitnami Images?

This CVE scan report contains a security report with all open CVEs. To get the list of actionable security issues, find the "latest" tag, click the vulnerability report link under the corresponding "Security scan" field and then select the "Only show fixable" filter on the next page.

Supported tags and respective Dockerfile links

Learn more about the Bitnami tagging policy and the difference between rolling tags and immutable tags in our documentation page.

Subscribe to project updates by watching the bitnami/discourse GitHub repo.

Get this image

The recommended way to get the Bitnami Discourse Docker Image is to pull the prebuilt image from the Docker Hub Registry.

$ docker pull bitnami/discourse:latest

To use a specific version, you can pull a versioned tag. You can view the list of available versions in the Docker Hub Registry.

$ docker pull bitnami/discourse:[TAG]

If you wish, you can also build the image yourself.

$ docker build -t bitnami/discourse:latest 'https://github.com/bitnami/bitnami-docker-discourse.git#master:2/debian-10'

How to use this image

Discourse requires access to a PostgreSQL database to store information. We'll use the Bitnami Docker Image for PostgreSQL for the database requirements.

Run the application using Docker Compose

The main folder of this repository contains a functional docker-compose.yml file. Run the application using it as shown below:

$ curl -sSL https://raw.githubusercontent.com/bitnami/bitnami-docker-discourse/master/docker-compose.yml > docker-compose.yml
$ docker-compose up -d

Using the Docker Command Line

If you want to run the application manually instead of using docker-compose, these are the basic steps you need to run:

Step 1: Create a network

$ docker network create discourse-network

Step 2: Create a volume for PostgreSQL persistence and create a PostgreSQL container

$ docker volume create --name postgresql_data
$ docker run -d --name postgresql \
  --env ALLOW_EMPTY_PASSWORD=yes \
  --env POSTGRESQL_USERNAME=bn_discourse \
  --env POSTGRESQL_PASSWORD=bitnami123 \
  --env POSTGRESQL_DATABASE=bitnami_discourse \
  --network discourse-network \
  --volume postgresql_data:/bitnami/postgresql \
  bitnami/postgresql:latest

Step 3: Create a volume for Redis persistence and create a Redis container

$ docker volume create --name redis_data
$ docker run -d --name redis \
  --env ALLOW_EMPTY_PASSWORD=yes \
  --network discourse-network \
  --volume redis_data:/bitnami/redis \
  bitnami/redis:latest

Step 4: Create volumes for Discourse persistence and launch the container

$ docker volume create --name discourse_data
$ docker run -d --name discourse \
  -p 8080:8080 -p 8443:8443 \
  --env ALLOW_EMPTY_PASSWORD=yes \
  --env DISCOURSE_DATABASE_USER=bn_discourse \
  --env DISCOURSE_DATABASE_PASSWORD=bitnami123 \
  --env DISCOURSE_DATABASE_NAME=bitnami_discourse \
  --env DISCOURSE_HOST=www.example.com \
  --network discourse-network \
  --volume discourse_data:/bitnami/discourse \
  bitnami/discourse:latest

Step 5: Launch the Sidekiq container

$ docker run -d --name sidekiq \
  --network discourse-network \
  --volume discourse_data:/bitnami/discourse \
  bitnami/discourse:latest /opt/bitnami/scripts/discourse-sidekiq/run.sh

Access your application at http://your-ip/

Troubleshooting discourse

If you need to run discourse administrative commands like Create admin account from console, you can do so by executing a shell inside the container and running with the proper environment variables.

cd /opt/bitnami/discourse
RAILS_ENV=production bundle exec rake admin:create

Persisting your application

If you remove the container all your data will be lost, and the next time you run the image the database will be reinitialized. To avoid this loss of data, you should mount a volume that will persist even after the container is removed.

For persistence you should mount a directory at the /bitnami/discourse path. If the mounted directory is empty, it will be initialized on the first run. Additionally you should mount a volume for persistence of the PostgreSQL data.

The above examples define the Docker volumes named postgresql_data and discourse_data. The Discourse application state will persist as long as volumes are not removed.

To avoid inadvertent removal of volumes, you can mount host directories as data volumes. Alternatively you can make use of volume plugins to host the volume data.

Mount host directories as data volumes with Docker Compose

This requires a minor change to the docker-compose.yml file present in this repository:

   postgresql:
     ...
     volumes:
-      - 'postgresql_data:/bitnami/postgresql'
+      - /path/to/postgresql-persistence:/bitnami/postgresql
   ...
   redis:
     ...
     volumes:
-      - 'redis_data:/bitnami/redis'
+      - /path/to/redis-persistence:/bitnami/redis
   ...
   discourse:
     ...
     volumes:
-      - 'discourse_data:/bitnami/discourse'
+      - /path/to/discourse-persistence:/bitnami/discourse
   ...
   sidekiq:
     ...
     volumes:
-      - 'discourse_data:/bitnami/discourse'
+      - /path/to/discourse-persistence:/bitnami/discourse
   ...
-volumes:
-  postgresql_data:
-    driver: local
-  redis_data:
-    driver: local
-  discourse_data:
-    driver: local

Mount host directories as data volumes using the Docker command line

Step 1: Create a network (if it does not exist)

$ docker network create discourse-network

Step 2. Create a PostgreSQL container with host volume

$ docker run -d --name postgresql \
  --env ALLOW_EMPTY_PASSWORD=yes \
  --env POSTGRESQL_USERNAME=bn_discourse \
  --env POSTGRESQL_PASSWORD=bitnami123 \
  --env POSTGRESQL_DATABASE=bitnami_discourse \
  --network discourse-network \
  --volume /path/to/postgresql-persistence:/bitnami/postgresql \
  bitnami/postgresql:latest

Step 3. Create a Redis container with host volume

$ docker run -d --name redis \
  --env ALLOW_EMPTY_PASSWORD=yes \
  --network discourse-network \
  --volume /path/to/redis-persistence:/bitnami/redis \
  bitnami/redis:latest

Step 4. Create the Discourse container with host volumes

$ docker run -d --name discourse \
  -p 8080:8080 -p 8443:8443 \
  --env ALLOW_EMPTY_PASSWORD=yes \
  --env DISCOURSE_DATABASE_USER=bn_discourse \
  --env DISCOURSE_DATABASE_PASSWORD=bitnami123 \
  --env DISCOURSE_DATABASE_NAME=bitnami_discourse \
  --env DISCOURSE_HOST=www.example.com \
  --network discourse-network \
  --volume /path/to/discourse-persistence:/bitnami/discourse \
  bitnami/discourse:latest

Step 5. Create the Sidekiq container with host volumes

$ docker run -d --name sidekiq \
  --network discourse-network \
  --volume /path/to/discourse-persistence:/bitnami/discourse \
  bitnami/discourse:latest

Configuration

Configuration files

You can mount your configuration files to the /opt/bitnami/discourse/mounted-conf directory. Make sure that your configuration files follow the standardized names used by Discourse. Some of the most common files include:

The set of default standard configuration files may be found here. You may refer to the the Discourse webpage for further details and specific configuration guides.

Environment variables

When you start the Discourse image, you can adjust the configuration of the instance by passing one or more environment variables either on the docker-compose file or on the docker run command line. If you want to add a new environment variable:

Available environment variables:

User and Site configuration
Database connection configuration
Redis connection configuration
Create a database for Discourse using postgresql-client
SMTP Configuration

To configure Discourse to send email using SMTP you can set the following environment variables:

Examples

SMTP configuration using a Gmail account

This would be an example of SMTP configuration using a Gmail account:

In order to verify your configuration works properly, you can test your configuration parameters from the container itself.

$ docker run -u root -it bitnami/discourse:latest bash
$ install_packages swaks
$ swaks --to your_email@domain.com --from your_email@domain.com --server your.smtp.server.com --auth LOGIN --auth-user your_email@domain.com -tls

See the documentation on troubleshooting SMTP issues if there are problems.

Connect Discourse container to an existing database

The Bitnami Discourse container supports connecting the Discourse application to an external database. This would be an example of using an external database for Discourse.

In case the database already contains data from a previous Discourse installation, you need to set the variable DISCOURSE_SKIP_BOOTSTRAP to yes. Otherwise, the container would execute the installation wizard and could modify the existing data in the database. Note that, when setting DISCOURSE_SKIP_BOOTSTRAP to yes, values for environment variables such as DISCOURSE_USERNAMEDISCOURSE_PASSWORD or DISCOURSE_EMAIL will be ignored.

Logging

The Bitnami Discourse Docker image sends the container logs to stdout. To view the logs:

$ docker logs discourse

Or using Docker Compose:

$ docker-compose logs discourse

You can configure the containers logging driver using the --log-driver option if you wish to consume the container logs differently. In the default configuration docker uses the json-file driver.

Maintenance

Backing up your container

To backup your data, configuration and logs, follow these simple steps:

Step 1: Stop the currently running container

$ docker stop discourse

Or using Docker Compose:

$ docker-compose stop discourse

Step 2: Run the backup command

We need to mount two volumes in a container we will use to create the backup: a directory on your host to store the backup in, and the volumes from the container we just stopped so we can access the data.

$ docker run --rm -v /path/to/discourse-backups:/backups --volumes-from discourse busybox \
  cp -a /bitnami/discourse /backups/latest

Restoring a backup

Restoring a backup is as simple as mounting the backup as volumes in the containers.

For the PostgreSQL database container:

 $ docker run -d --name postgresql \
   ...
-  --volume /path/to/postgresql-persistence:/bitnami/postgresql \
+  --volume /path/to/postgresql-backups/latest:/bitnami/postgresql \
   bitnami/postgresql:latest

For the Discourse container:

 $ docker run -d --name discourse \
   ...
-  --volume /path/to/discourse-persistence:/bitnami/discourse \
+  --volume /path/to/discourse-backups/latest:/bitnami/discourse \
   bitnami/discourse:latest

Upgrade this image

Bitnami provides up-to-date versions of PostgreSQL and Discourse, including security patches, soon after they are made upstream. We recommend that you follow these steps to upgrade your container. We will cover here the upgrade of the Discourse container. For the PostgreSQL upgrade see: https://github.com/bitnami/bitnami-docker-postgresql/blob/master/README.md#upgrade-this-image

The bitnami/discourse:latest tag always points to the most recent release. To get the most recent release you can simple repull the latest tag from the Docker Hub with docker pull bitnami/discourse:latest. However it is recommended to use tagged versions.

Step 1: Get the updated image

$ docker pull bitnami/discourse:latest

Step 2: Stop the running container

Stop the currently running container using the command

$ docker-compose stop discourse

Step 3: Take a snapshot of the application state

Follow the steps in Backing up your container to take a snapshot of the current application state.

Step 4: Remove the currently running container

Remove the currently running container by executing the following command:

docker-compose rm -v discourse

Step 5: Run the new image

Update the image tag in docker-compose.yml and re-create your container with the new image:

$ docker-compose up -d


Previous Next

Comment is not approved to this article.