Deployment
To deploy the Bulletin Board in a production environment, there are some extra precautions we need to take.
Infrastructure
The Bulletin Board server is a Ruby on Rails application. Apart for the server stack, we will need to set up:
-
Postgresql
as database; -
Redis
- used by Sidekiq.
Docker
The Bulletin Board server is published in Dockerhub as a Docker container.
If you want to deploy a modified version of the Bulletin Board, we highly recommend to use Dockerfile
in the root folder of the repository to build and release the application. The file Dockerfile.worker
is the same but changing the endpoint to use it as a worker. Take a look at the docker-compose.yml
provided in order to see how can you use the normal Dockerfile
just changing the command to execute.
Note that there are is also Dockerfile.release
in the repository. It is the same but without using and entrypoint and changing the default command to execute the db:migrate task. This is mostly intended for its use in heroku.
Important
You need to spin up two instances of the Bulletin Board, one for the server and one for the worker. The default entrypoint provided in the Dockerfile
executes whatever command is defined (by default rails server
), however you can use the ENV var RUN_SIDEKIQ
to override the command and use the same Dockerfile as a worker without any other modification. See the docker-compose.yml
file for an example.
ActiveStorage
The Bulletin Board uses ActiveStorage.
You will need to set it up with the credentials of the cloud storage of your choice in bulletin_board/server/config/storage.yml
, taking the secrets from environment variables.
Environment Variables
We’ll need to set up an array of environment variables in order for the sever to function correctly.
-
Rails:
-
RACK_ENV
andRAILS_ENV
with valueproduction
; -
RAILS_SERVE_STATIC_FILES
with valuetrue
; -
SECRET_KEY_BASE
as in any Rails application;
-
-
Connect to Postgres:
-
DATABASE_URL
with the full URL of the database;
-
-
Redis:
-
REDIS_URL
with the full URL of the Redis instance;
-
-
ActiveRecord:
-
The secrets of the cloud storage of your choice;
-
For instance, if using a compatible AWS provider you should define:
-
ACTIVE_STORAGE_SERVICE=s3
-
AWS_ACCESS_KEY_ID=**
-
AWS_SECRET_ACCESS_KEY=**
-
AWS_REGION=eu-west-1
-
AWS_BUCKET_NAME=bucket-name
-
If using a provider that is not Amazon also define
AWS_ENDPOINT
with the endpoint of the provider.
-
-
You can also easily use Azure or GCS providers (see the previous mentioned
storage.yml
file for the ENV vars), but in this case add the line that applies in your case to the filebulletin_board/server/Gemfile
:-
gem "azure-storage-blob", require: false
-
gem "google-cloud-storage", "~> 1.11", require: false
-
-
-
CORS:
-
CORS_ORIGIN_ALLOWED
with the list of hosts of Decidim instances that will use this Bulletin Board. If you don’t know what Decidim instances will use this Bulletin Board, you can put*
-