To simplify set up of a development environment, LinuxFr.org can be
run with a container engine like Docker or Podman with the compose.yml
file which describes how to build all needed services.
By default, the LinuxFr.org services will be provided under the domain names
dlfp.lo and image.dlfp.lo. So you'll need to add the
following line into the /etc/hosts file of your machine:
127.0.0.1 dlfp.lo image.dlfp.lo
Then, if you use the Docker engine, you can use the docker compose up
command to start the system (you need to install the
Docker compose plugin first).
Note: with the Docker engine, you need to enable the Docker BuildKit builder. Either you have a Docker version which uses it by default, or you set the environment variable
export DOCKER_BUILDKIT=1.
If you use the Podman engine, you can either use the same Docker compose plugin
or the podman-compose
tool. The podman cli itself provides a wrapper of one of these two tools
through the
podman compose command.
Thus you need to use the podman compose up command to start the system.
At this point, this documentation will give you docker compose commands,
but you should be able to use podman compose without any issue.
To setup the SQL database schema, you need to wait until the database
container becomes ready to listen MySQL connections.
For example, you should see in the logs:
database_1 | 2020-09-21 16:03:12 139820938893312 [Note] mysqld: ready for connections.
database_1 | Version: '10.1.46-MariaDB-1~bionic' socket: '/var/run/mysqld/mysqld.sock' port: 3306 mariadb.org binary distribution
Or you can check the database container status to be healthy with the
docker compose ps command.
Then, open a second terminal and run:
docker compose exec linuxfr.org bin/rails db:setup
Finally, the environment is ready and you can open http://dlfp.lo:9000 in your favorite browser.
By default, you don't need to update the configuration.
If you want, you can change the domain names used by the LinuxFr.org
web application. To do this, you can setup DOMAIN and IMAGE_DOMAIN
variables in the deployment/default.env file.
Within the same file, you can update the HTTP listening ports by updating the
DOMAIN_HTTP_PORT and IMAGE_DOMAIN_HTTP_PORT variables (both are set to
9000 by default). If you modify them, don't forget to add the new values as
published ports for the nginx service in the compose.yaml file (they have
to target the 8080 container port).
You can also configure your own Redis service and your own MySQL service by updating environment variables in the same file.
The compose file currently shares ./app, ./db and
./public directories with the container.
So you can update files with your preferred IDE on your machine. Rails will directly detect changes and apply them on next page reload.
Furthermore, if you need to access the Rails console, you need a second terminal and run:
docker compose exec linuxfr.org bin/rails console
Note: currently, we didn't configure rails to show directly the
webconsole in your browser. That's just because of time needed to
find the good configuration, any help will be appreciated !
To help maintainers, we are in the process of adding tests to check the application has still the expected behavior.
To get help about writing tests, see the Ruby on Rails documentation .
To run tests with containers, you need to use this command:
docker compose exec linuxfr.org bin/rails test -v
In case you need to inspect the database, the port 3306 of your machine is
by default bound to the port 3306 of the database container.
Thus you can connect to the linuxfr database with hostname localhost and the
username, password and database name defined in the deployment/default.env
configuration file (all three last are by default linuxfr_rails).
In case you need to apply new database migrations, you need a second terminal and run:
docker compose exec linuxfr.org bin/rails db:migrate
If you had issue and want to reset all data in your database system, use:
docker compose exec linuxfr.org bin/rails db:reset
Currently, these services are directly enabled by compose:
- The LinuxFr.org ruby on rails application itself
- The board service which is responsible of tribunes and dynamic collaborative editions of news
- The image service which is caching external images to avoid to run DOS on external services hosting the images used in news, diaries...
For now, these services aren't available:
- The epub service,
because it requires to run
LinuxFr.org with a TLS certificate. When the service will accept to
fetch articles with simple
http://, we'll be able to provide it directly with docker compose. - The svgtex service, because LinuxFr
has hard-coded the
localhosthostname in it's HTML Pipeline tool
Fortunately, you can already hack LinuxFr.org deeply without these services.