From ef3c07237c9d05058605932978c711ae5f6952b6 Mon Sep 17 00:00:00 2001 From: Adrien Dorsaz Date: Sun, 31 May 2026 10:04:29 +0200 Subject: [PATCH 1/5] deployment: update container build sources (still using ruby 2) The easiest was to update the Debian base image to bullseye as previous Debian releases have been archived. This commit backports too the new deployment file structure from the rails7 branch. It uses more generic terms like `Containerfile` and `compose.yaml` instead of docker specific names like `Dockerfile` and `docker-compose.yaml`. You should be able to use `podman` dans `docker` to run the linuxfr stack. --- Docker.md => Container.md | 83 ++++++++++++------- README.md | 6 +- docker-compose.yaml => compose.yaml | 22 +++-- .../database/{Dockerfile => Containerfile} | 0 deployment/default.env | 7 ++ .../{Dockerfile => Containerfile} | 6 +- .../linuxfr-img/{Dockerfile => Containerfile} | 17 ++-- .../linuxfr.org/{Dockerfile => Containerfile} | 4 +- deployment/nginx/templates/dlfp.conf.template | 13 ++- .../nginx/templates/image.dlfp.conf.template | 4 +- 10 files changed, 105 insertions(+), 57 deletions(-) rename Docker.md => Container.md (57%) rename docker-compose.yaml => compose.yaml (80%) rename deployment/database/{Dockerfile => Containerfile} (100%) rename deployment/linuxfr-board/{Dockerfile => Containerfile} (87%) rename deployment/linuxfr-img/{Dockerfile => Containerfile} (81%) rename deployment/linuxfr.org/{Dockerfile => Containerfile} (95%) diff --git a/Docker.md b/Container.md similarity index 57% rename from Docker.md rename to Container.md index 02234fe74..7bae0b621 100644 --- a/Docker.md +++ b/Container.md @@ -1,19 +1,47 @@ -LinuxFr on Docker ------------------ +LinuxFr with Containers +----------------------- -To simplify set up of a developement environment, LinuxFr.org can be -run on Docker with `docker compose up`. +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`](./compose.yaml) +file which describes how to build all needed services. -To init the SQL database schema, you need to wait upto the `database` -container to be ready to listen MySQL connections. +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](https://docs.docker.com/compose/) 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](https://github.com/containers/podman-compose/) +tool. The podman cli itself provides a wrapper of one of these two tools +through the +[`podman compose` command](https://docs.podman.io/en/latest/markdown/podman-compose.1.html). +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 | 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". +Or you can check the `database` container status to be *healthy* with the +`docker compose ps` command. Then, open a second terminal and run: @@ -21,16 +49,9 @@ 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](http://dlfp.lo) +Finally, the environment is ready and you can open [http://dlfp.lo:9000](http://dlfp.lo:9000) in your favorite browser. -Note: to be able to access this URL, 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 -``` - Personalize configuration ========================= @@ -40,24 +61,22 @@ 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. -You can also configure your own Redis service and your own MySQL -service. - -If you want to change the application port and/or other configurations, you can -[override](https://docs.docker.com/compose/extends/) -the docker compose configuration (in particular the `nginx` service for -the port). +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). -Notice, that if LinuxFr.org doesn't run on port 80, the image cache -service won't work well and so you won't be able to see images in the news. +You can also configure your own Redis service and your own MySQL +service by updating environment variables in the same file. Test modifications ================== -The docker compose is currently configured to share `./app`, `./db` and -`./public` directories with the docker container. +The compose file currently shares `./app`, `./db` and +`./public` directories with the container. -So you can update files with your prefered IDE on your machine. Rails +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 @@ -75,13 +94,13 @@ Run application tests ===================== To help maintainers, we are in the process of adding tests to check the -application has still the expected behaviour. +application has still the expected behavior. To get help about writing tests, see the [Ruby on Rails documentation](https://guides.rubyonrails.org/testing.html#the-rails-test-runner) . -To run tests with Docker environment, you need to use this command: +To run tests with containers, you need to use this command: ``` docker compose exec linuxfr.org bin/rails test -v @@ -114,10 +133,10 @@ use: docker compose exec linuxfr.org bin/rails db:reset ``` -Services provided by the docker compose +Services provided by the compose file ======================================= -Currently, these services are directly enabled by docker compose: +Currently, these services are directly enabled by compose: 1. The [LinuxFr.org](https://github.com/linuxfrorg/linuxfr.org) ruby on rails application itself diff --git a/README.md b/README.md index ed27f6db9..159336532 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,9 @@ Install See [INSTALL.md](INSTALL.md) to set up LinuxFr.org on a Debian environment. -Alternatively, you can read [Docker.md](Docker.md) to setup easily -LinuxFr.org development environment with the Docker engine and -[docker-compose](https://docs.docker.com/compose/). +Alternatively, you can read [Container.md](Container.md) to setup easily +LinuxFr.org development environment with a container engine like Docker or +Podman and use the [container composer](https://docs.docker.com/compose/). See also -------- diff --git a/docker-compose.yaml b/compose.yaml similarity index 80% rename from docker-compose.yaml rename to compose.yaml index 6e1afd3e2..e5273d39f 100644 --- a/docker-compose.yaml +++ b/compose.yaml @@ -2,7 +2,7 @@ services: linuxfr.org: build: context: . - dockerfile: deployment/linuxfr.org/Dockerfile + dockerfile: deployment/linuxfr.org/Containerfile env_file: - deployment/default.env volumes: @@ -10,6 +10,8 @@ services: # and see the result without need to restart the container - ./app:/linuxfr.org/app:Z - ./db:/linuxfr.org/db:Z + - ./Gemfile:/linuxfr.org/Gemfile:Z + - ./Gemfile.lock:/linuxfr.org/Gemfile.lock:Z - ./lib:/linuxfr.org/lib:Z - ./public:/linuxfr.org/public:Z - ./test:/linuxfr.org/test:Z @@ -32,6 +34,7 @@ services: linuxfr-board: build: context: deployment/linuxfr-board + dockerfile: Containerfile env_file: - deployment/default.env healthcheck: @@ -46,6 +49,7 @@ services: linuxfr-img: build: context: deployment/linuxfr-img + dockerfile: Containerfile env_file: - deployment/default.env healthcheck: @@ -60,7 +64,7 @@ services: - cache-img:/linuxfr-img/cache nginx: - image: docker.io/nginx:stable + image: docker.io/nginxinc/nginx-unprivileged:stable-alpine env_file: - deployment/default.env volumes: @@ -68,11 +72,14 @@ services: - ./public/fonts:/var/linuxfr/fonts:Z - data-uploads:/var/linuxfr/uploads ports: - - target: 80 - published: 127.0.0.1:80 + - target: 8080 + # If you customize the published port, you have to update the + # DOMAIN_HTTP_PORT and IMAGE_DOMAIN_HTTP_PORT variables + # into the `deployment/default.env` file too + published: 127.0.0.1:9000 protocol: tcp healthcheck: - test: ["CMD", "curl", "--silent", "--fail", "--fail-early", "--head", "http://$$DOMAIN", "http://$$DOMAIN/img", "http://$$DOMAIN/b", "http://$$IMAGE_DOMAIN/status"] + test: ["CMD", "curl", "--silent", "--fail", "--fail-early", "--location", "--head", "http://$$DOMAIN:8080", "http://$$DOMAIN:8080/img/status", "http://$$DOMAIN:8080/b", "http://$$IMAGE_DOMAIN:8080/status"] interval: 10s start_period: 5s depends_on: @@ -94,12 +101,13 @@ services: networks: default: aliases: - - ${DOMAIN} - - ${IMAGE_DOMAIN} + - $${DOMAIN} + - $${IMAGE_DOMAIN} database: build: context: deployment/database + dockerfile: Containerfile env_file: - deployment/default.env ports: diff --git a/deployment/database/Dockerfile b/deployment/database/Containerfile similarity index 100% rename from deployment/database/Dockerfile rename to deployment/database/Containerfile diff --git a/deployment/default.env b/deployment/default.env index 5bd82e4fc..45106cb73 100644 --- a/deployment/default.env +++ b/deployment/default.env @@ -1,6 +1,13 @@ # LinuxFr configuration DOMAIN=dlfp.lo +# If you want to customize the public HTTP port, do not forget to add it to +# published ports of the `nginx` service into the `compose.yaml` file. +DOMAIN_HTTP_PORT=9000 + IMAGE_DOMAIN=image.dlfp.lo +# If you want to customize the image public HTTP port, do not forget to add it to +# published ports of the `nginx` service into the `compose.yaml` file. +IMAGE_DOMAIN_HTTP_PORT=9000 # Redis service is used as a caching service and a publish/subscribe service # to allow the different LinuxFr tools work together diff --git a/deployment/linuxfr-board/Dockerfile b/deployment/linuxfr-board/Containerfile similarity index 87% rename from deployment/linuxfr-board/Dockerfile rename to deployment/linuxfr-board/Containerfile index b64158800..e33160f84 100644 --- a/deployment/linuxfr-board/Dockerfile +++ b/deployment/linuxfr-board/Containerfile @@ -1,4 +1,4 @@ -FROM docker.io/ruby:2-slim-buster +FROM docker.io/debian:bullseye-slim LABEL org.opencontainers.image.title="Board for LinuxFr.org" LABEL org.opencontainers.image.description="Users of the LinuxFr.org website can chat on a space called the board (« la tribune » in french). \ @@ -6,7 +6,7 @@ This Ruby daemon notifies the users when something is said with Server-Sent Even LABEL org.opencontainers.image.source="https://github.com/linuxfrorg/board-sse-linuxfr.org" LABEL org.opencontainers.image.url="https://github.com/linuxfrorg/board-sse-linuxfr.org" LABEL org.opencontainers.image.licenses="AGPL-3.0-only" -LABEL org.opencontainers.image.version="1.1" +LABEL org.opencontainers.image.version="1-ruby2-bullseye" LABEL org.opencontainers.image.authors="Adrien Dorsaz " ARG UID=1200 @@ -25,6 +25,8 @@ RUN \ USER ${UID} WORKDIR /linuxfr-board ENV HOME=/linuxfr-board +ENV GEM_HOME=/linuxfr-board/.gem +ENV PATH=/bin:/usr/bin:/linuxfr-board/.gem/bin # Install board-linuxfr RUN gem install board-linuxfr -v '~> 0.1.3' diff --git a/deployment/linuxfr-img/Dockerfile b/deployment/linuxfr-img/Containerfile similarity index 81% rename from deployment/linuxfr-img/Dockerfile rename to deployment/linuxfr-img/Containerfile index 0a2509e15..7af8fcdfd 100644 --- a/deployment/linuxfr-img/Dockerfile +++ b/deployment/linuxfr-img/Containerfile @@ -1,11 +1,13 @@ -FROM docker.io/debian:bullseye-slim as build +FROM docker.io/debian:trixie-slim as base + +FROM base as build LABEL org.opencontainers.image.title="LinuxFr.org image caching service" LABEL org.opencontainers.image.description="Store external images into a cache to not flood external website" LABEL org.opencontainers.image.source="https://github.com/linuxfrorg/img-LinuxFr.org" LABEL org.opencontainers.image.url="https://github.com/linuxfrorg/linuxfr.org/blob/main/Container.md" LABEL org.opencontainers.image.licenses="AGPL-3.0-only" -LABEL org.opencontainers.image.version="2.1" +LABEL org.opencontainers.image.version="main-trixie" LABEL org.opencontainers.image.authors="Adrien Dorsaz " ARG UID=1200 @@ -24,9 +26,14 @@ ENV HOME=/linuxfr-img WORKDIR /linuxfr-img # Build linuxfr-img -RUN go get -u github.com/linuxfrorg/img-LinuxFr.org +RUN \ + set -eux; \ + IFS=$'\n\t'; \ + git clone https://github.com/linuxfrorg/img-LinuxFr.org; \ + cd img-LinuxFr.org; \ + go install; -FROM docker.io/debian:bullseye-slim as deploy +FROM base as deploy ARG UID=1200 @@ -40,8 +47,6 @@ RUN \ apt-get clean; USER ${UID} -ENV GOPATH=/linuxfr-img -ENV HOME=/linuxfr-img WORKDIR /linuxfr-img COPY --from=build --chown=${UID}:0 --chmod=770 /linuxfr-img/bin/img-LinuxFr.org . diff --git a/deployment/linuxfr.org/Dockerfile b/deployment/linuxfr.org/Containerfile similarity index 95% rename from deployment/linuxfr.org/Dockerfile rename to deployment/linuxfr.org/Containerfile index b3256821e..9a5408daa 100644 --- a/deployment/linuxfr.org/Dockerfile +++ b/deployment/linuxfr.org/Containerfile @@ -3,9 +3,9 @@ FROM docker.io/debian:bullseye-slim LABEL org.opencontainers.image.title="LinuxFr.org website" LABEL org.opencontainers.image.description="Run LinuxFr.org Ruby on Rails website" LABEL org.opencontainers.image.source="https://github.com/linuxfrorg/linuxfr.org" -LABEL org.opencontainers.image.url="https://github.com/linuxfrorg/linuxfr.org/blob/main/Docker.md" +LABEL org.opencontainers.image.url="https://github.com/linuxfrorg/linuxfr.org/blob/main/Container.md" LABEL org.opencontainers.image.licenses="AGPL-3.0-only" -LABEL org.opencontainers.image.version="2.0" +LABEL org.opencontainers.image.version="main-bullseye" LABEL org.opencontainers.image.authors="Adrien Dorsaz " ARG UID=1200 diff --git a/deployment/nginx/templates/dlfp.conf.template b/deployment/nginx/templates/dlfp.conf.template index 8525f5cf5..cb0b3cfd9 100644 --- a/deployment/nginx/templates/dlfp.conf.template +++ b/deployment/nginx/templates/dlfp.conf.template @@ -1,6 +1,6 @@ -server { - listen 80; - listen [::]:80; +server { + listen 8080; + listen [::]:8080; server_name ${DOMAIN}; @@ -14,6 +14,11 @@ server { root /var/linuxfr/uploads; } + # Only used for health check command line in compose.yaml + location /img/status { + proxy_pass http://linuxfr-img:8000/status; + } + location /img/ { proxy_pass http://linuxfr-img:8000; } @@ -29,6 +34,8 @@ server { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; + proxy_buffers 8 16k; + proxy_buffer_size 32k; proxy_pass http://linuxfr.org:3000; } } diff --git a/deployment/nginx/templates/image.dlfp.conf.template b/deployment/nginx/templates/image.dlfp.conf.template index 35f53c974..e2454d8ab 100644 --- a/deployment/nginx/templates/image.dlfp.conf.template +++ b/deployment/nginx/templates/image.dlfp.conf.template @@ -1,6 +1,6 @@ server { - listen 80; - listen [::]:80; + listen 8080; + listen [::]:8080; server_name ${IMAGE_DOMAIN}; From fda8c591cfdbd71c9e970b9eaabeece47ddd8e11 Mon Sep 17 00:00:00 2001 From: Adrien Dorsaz Date: Fri, 20 Sep 2024 08:37:55 +0200 Subject: [PATCH 2/5] backport: use custom HTTP public port to use rootless containers by default This commit introduces two new global constants MY_PUBLIC_URL and IMG_PUBLIC_URL which should be used now to build URLs. For alpha and production Ruby environments, they are fixed with their real values directly in the `config/environments/*.rb` files. For the development Ruby environment, they are both defined by default to `http://dlfp.lo`. You can customize either by updating the `config/environments/development.rb` file or by setting the *process* environment variables `DOMAIN`, `DOMAIN_HTTP_PORT`, `IMAGE_DOMAIN` and `IMAGE_DOMAIN_HTTP_PORT`. For containers, you can set these variables in the `deployment/default.env` file. For containers the default IMG_DOMAIN is set to `img.dlfp.lo`. --- INSTALL.md | 17 +++++++--- .../admin/stylesheets_controller.rb | 2 +- app/helpers/atom_helper.rb | 2 +- app/models/diary.rb | 2 +- app/models/image.rb | 2 +- app/models/node.rb | 2 +- app/uploaders/avatar_uploader.rb | 4 +-- app/uploaders/stylesheet_uploader.rb | 2 +- app/views/bookmarks/_bookmark.atom.builder | 2 +- app/views/diaries/_diary.atom.builder | 2 +- app/views/news/_news.atom.builder | 4 +-- app/views/polls/_poll.atom.builder | 2 +- app/views/posts/_post.atom.builder | 2 +- app/views/stylesheets/edit.html.haml | 2 +- app/views/trackers/_tracker.atom.builder | 2 +- app/views/wiki_pages/_wiki_page.atom.builder | 2 +- config/environments/alpha.rb | 2 ++ config/environments/development.rb | 31 +++++++++++++++++-- config/environments/production.rb | 6 ++-- config/environments/test.rb | 6 ++-- 20 files changed, 69 insertions(+), 27 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index b156f3eff..409d74533 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -153,11 +153,20 @@ Additionally, you run the boards within another terminal: This extra step isn't really needed to be able to use LinuxFr.org. -In the `config/environments/development.rb` file, there are two domains set -inside variables `MY_DOMAIN` and `IMG_DOMAIN`. -By default both domains are `dlfp.lo`. +In the `config/environments/development.rb` file, there are these variables: -You'll find this domain inside some documents like emails to confirm user +1. `MY_DOMAIN` and `IMG_DOMAIN` which define the domain name for the LinuxFr + service and the image caching service. + By default both domain names are `dlfp.lo`. + +2. `MY_PUBLIC_URL` and `IMG_PUBLIC_PORT` which define the public HTTP port for + both services. + By default both ports are `80`. + +These two set of variables are used to build the public url of the two +services. By default both public urls are `http://dlfp.lo`. + +You'll find this public url inside some documents like emails to confirm user subscription. To simplify your usage of LinuxFr.org, you should consider install a website locally using this domain name. diff --git a/app/controllers/admin/stylesheets_controller.rb b/app/controllers/admin/stylesheets_controller.rb index 9c6812556..07adf7f71 100644 --- a/app/controllers/admin/stylesheets_controller.rb +++ b/app/controllers/admin/stylesheets_controller.rb @@ -6,7 +6,7 @@ def show def create Stylesheet.temporary(current_account, params[:url]) do - redirect_to "/" + Stylesheet.capture("https://#{MY_DOMAIN}/", cookies) + redirect_to "/" + Stylesheet.capture("#{MY_PUBLIC_URL}/", cookies) end end diff --git a/app/helpers/atom_helper.rb b/app/helpers/atom_helper.rb index fcf088c18..f2a27a3a1 100644 --- a/app/helpers/atom_helper.rb +++ b/app/helpers/atom_helper.rb @@ -5,7 +5,7 @@ def atom_comments_link(content, url) str = <<-EOS

Commentaires : - voir le flux Atom + voir le flux Atom ouvrir dans le navigateur

EOS diff --git a/app/models/diary.rb b/app/models/diary.rb index 7c265d815..37649506e 100644 --- a/app/models/diary.rb +++ b/app/models/diary.rb @@ -80,7 +80,7 @@ def convert @news.save! $redis.set "convert/#{@news.id}", self.id @news.node.update_column(:cc_licensed, node.cc_licensed) - @news.links.create title: "Journal à l’origine de la dépêche", url: "https://#{MY_DOMAIN}/users/#{owner.to_param}/journaux/#{to_param}", lang: "fr" + @news.links.create title: "Journal à l’origine de la dépêche", url: "#{MY_PUBLIC_URL}/users/#{owner.to_param}/journaux/#{to_param}", lang: "fr" @news end end diff --git a/app/models/image.rb b/app/models/image.rb index b47cb17c2..1b0061a1d 100644 --- a/app/models/image.rb +++ b/app/models/image.rb @@ -69,7 +69,7 @@ def src(type="img") return link if internal_link? return E403 if blacklisted? register_in_redis - "https://#{IMG_DOMAIN}/#{type}/#{encoded_link}/#{filename}" + "#{IMG_PUBLIC_URL}/#{type}/#{encoded_link}/#{filename}" end def src_attr diff --git a/app/models/node.rb b/app/models/node.rb index 50e427ea6..643109252 100644 --- a/app/models/node.rb +++ b/app/models/node.rb @@ -178,7 +178,7 @@ def set_taglist(list, user_id) if tag.new_record? tag.save! user = User.find(user_id) - Board.amr_notification("L’étiquette #{tagname} https://#{MY_DOMAIN}/tags/#{tagname}/public vient d’être créée par #{user.name} https://#{MY_DOMAIN}/users/#{user.cached_slug}") + Board.amr_notification("L’étiquette #{tagname} #{MY_PUBLIC_URL}/tags/#{tagname}/public vient d’être créée par #{user.name} #{MY_PUBLIC_URL}/users/#{user.cached_slug}") end taggings.create(tag_id: tag.id, user_id: user_id) end diff --git a/app/uploaders/avatar_uploader.rb b/app/uploaders/avatar_uploader.rb index 98c64d146..ab4532009 100644 --- a/app/uploaders/avatar_uploader.rb +++ b/app/uploaders/avatar_uploader.rb @@ -3,7 +3,7 @@ class AvatarUploader < CarrierWave::Uploader::Base AVATAR_SIZE = 64 - DEFAULT_AVATAR_URL = "https://#{MY_DOMAIN}/images/default-avatar.svg" + DEFAULT_AVATAR_URL = "#{MY_PUBLIC_URL}/images/default-avatar.svg" include CarrierWave::MiniMagick process resize_and_pad: [AVATAR_SIZE, AVATAR_SIZE] @@ -13,7 +13,7 @@ def base_dir end def url - super.sub(base_dir.to_s, "https://#{IMG_DOMAIN}") + super.sub(base_dir.to_s, "#{IMG_PUBLIC_URL}") end def store_dir diff --git a/app/uploaders/stylesheet_uploader.rb b/app/uploaders/stylesheet_uploader.rb index a265c5e79..cdc372423 100644 --- a/app/uploaders/stylesheet_uploader.rb +++ b/app/uploaders/stylesheet_uploader.rb @@ -6,7 +6,7 @@ def base_dir end def url - super.sub(base_dir.to_s, "https://#{IMG_DOMAIN}") + super.sub(base_dir.to_s, "#{IMG_PUBLIC_URL}") end def store_dir diff --git a/app/views/bookmarks/_bookmark.atom.builder b/app/views/bookmarks/_bookmark.atom.builder index 92f629804..31bacb8c2 100644 --- a/app/views/bookmarks/_bookmark.atom.builder +++ b/app/views/bookmarks/_bookmark.atom.builder @@ -8,5 +8,5 @@ feed.entry(bookmark, :url => url) do |entry| bookmark.node.popular_tags.each do |tag| entry.category(:term => tag.name) end - entry.wfw :commentRss, "https://#{MY_DOMAIN}/nodes/#{bookmark.node.id}/comments.atom" + entry.wfw :commentRss, "#{MY_PUBLIC_URL}/nodes/#{bookmark.node.id}/comments.atom" end diff --git a/app/views/diaries/_diary.atom.builder b/app/views/diaries/_diary.atom.builder index 6f9cf9149..d23660c03 100644 --- a/app/views/diaries/_diary.atom.builder +++ b/app/views/diaries/_diary.atom.builder @@ -12,5 +12,5 @@ feed.entry(diary, :url => url) do |entry| diary.node.popular_tags.each do |tag| entry.category(:term => tag.name) end - entry.wfw :commentRss, "https://#{MY_DOMAIN}/nodes/#{diary.node.id}/comments.atom" + entry.wfw :commentRss, "#{MY_PUBLIC_URL}/nodes/#{diary.node.id}/comments.atom" end diff --git a/app/views/news/_news.atom.builder b/app/views/news/_news.atom.builder index d0c66edd3..ea991d0da 100644 --- a/app/views/news/_news.atom.builder +++ b/app/views/news/_news.atom.builder @@ -7,7 +7,7 @@ feed.entry(news, :published => news.node.created_at) do |entry| first = content_tag(:div, news.body) links = content_tag(:ul, news.links.map.with_index do |l,i| content_tag(:li, "lien nᵒ #{i+1} : ".html_safe + - link_to(l.title, "https://#{MY_DOMAIN}/redirect/#{l.id}", :title => l.url, :hreflang => l.lang)) + link_to(l.title, "#{MY_PUBLIC_URL}/redirect/#{l.id}", :title => l.url, :hreflang => l.lang)) end.join.html_safe) second = content_tag(:div, news.second_part) if news.published? @@ -32,6 +32,6 @@ feed.entry(news, :published => news.node.created_at) do |entry| entry.category(:term => tag.name) end if news.published? - entry.wfw :commentRss, "https://#{MY_DOMAIN}/nodes/#{news.node.id}/comments.atom" + entry.wfw :commentRss, "#{MY_PUBLIC_URL}/nodes/#{news.node.id}/comments.atom" end end diff --git a/app/views/polls/_poll.atom.builder b/app/views/polls/_poll.atom.builder index 852e2d6ce..c5e123cf1 100644 --- a/app/views/polls/_poll.atom.builder +++ b/app/views/polls/_poll.atom.builder @@ -9,5 +9,5 @@ feed.entry(poll, :published => poll.node.created_at) do |entry| poll.node.popular_tags.each do |tag| entry.category(:term => tag.name) end - entry.wfw :commentRss, "https://#{MY_DOMAIN}/nodes/#{poll.node.id}/comments.atom" + entry.wfw :commentRss, "#{MY_PUBLIC_URL}/nodes/#{poll.node.id}/comments.atom" end diff --git a/app/views/posts/_post.atom.builder b/app/views/posts/_post.atom.builder index aa73c3487..606aac7e7 100644 --- a/app/views/posts/_post.atom.builder +++ b/app/views/posts/_post.atom.builder @@ -10,5 +10,5 @@ feed.entry(post, :url => url) do |entry| post.node.popular_tags.each do |tag| entry.category(:term => tag.name) end - entry.wfw :commentRss, "https://#{MY_DOMAIN}/nodes/#{post.node.id}/comments.atom" + entry.wfw :commentRss, "#{MY_PUBLIC_URL}/nodes/#{post.node.id}/comments.atom" end diff --git a/app/views/stylesheets/edit.html.haml b/app/views/stylesheets/edit.html.haml index 9983f3734..539c2a2d6 100644 --- a/app/views/stylesheets/edit.html.haml +++ b/app/views/stylesheets/edit.html.haml @@ -33,7 +33,7 @@ Pour cela, il vous suffit de commencer votre feuille de style par la déclaration suivante : %pre - @import url("https://#{MY_DOMAIN}/assets/application.css"); + @import url("#{MY_PUBLIC_URL}/assets/application.css"); %div.sideforms = form_tag "/stylesheet", method: :put do diff --git a/app/views/trackers/_tracker.atom.builder b/app/views/trackers/_tracker.atom.builder index deffa237b..479e1ab88 100644 --- a/app/views/trackers/_tracker.atom.builder +++ b/app/views/trackers/_tracker.atom.builder @@ -8,5 +8,5 @@ feed.entry(tracker) do |entry| tracker.node.popular_tags.each do |tag| entry.category(:term => tag.name) end - entry.wfw :commentRss, "https://#{MY_DOMAIN}/nodes/#{tracker.node.id}/comments.atom" + entry.wfw :commentRss, "#{MY_PUBLIC_URL}/nodes/#{tracker.node.id}/comments.atom" end diff --git a/app/views/wiki_pages/_wiki_page.atom.builder b/app/views/wiki_pages/_wiki_page.atom.builder index 022a6e4ba..7cc4089a6 100644 --- a/app/views/wiki_pages/_wiki_page.atom.builder +++ b/app/views/wiki_pages/_wiki_page.atom.builder @@ -9,5 +9,5 @@ feed.entry(wiki_page) do |entry| wiki_page.node.popular_tags.each do |tag| entry.category(:term => tag.name) end - entry.wfw :commentRss, "https://#{MY_DOMAIN}/nodes/#{wiki_page.node.id}/comments.atom" + entry.wfw :commentRss, "#{MY_PUBLIC_URL}/nodes/#{wiki_page.node.id}/comments.atom" end diff --git a/config/environments/alpha.rb b/config/environments/alpha.rb index 978bfc536..1818b16ee 100644 --- a/config/environments/alpha.rb +++ b/config/environments/alpha.rb @@ -1,7 +1,9 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. MY_DOMAIN = 'alpha.linuxfr.org' + MY_PUBLIC_URL = 'https://alpha.linuxfr.org' IMG_DOMAIN = 'img.alpha.linuxfr.org' + IMG_PUBLIC_URL = 'https://img.alpha.linuxfr.org' # Code is not reloaded between requests. config.cache_classes = true diff --git a/config/environments/development.rb b/config/environments/development.rb index b8de73c14..d1075c2b6 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,7 +1,34 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. - MY_DOMAIN = ENV["DOMAIN"] || 'dlfp.lo' - IMG_DOMAIN = ENV["IMAGE_DOMAIN"] || 'dlfp.lo' + MY_DOMAIN = ENV["DOMAIN"] || "dlfp.lo" + MY_PUBLIC_PORT = ENV["DOMAIN_HTTP_PORT"] || "80" + + linuxfr_service_url = "http://#{MY_DOMAIN}" + if MY_PUBLIC_PORT != "" and MY_PUBLIC_PORT != "80" + linuxfr_service_url = "#{linuxfr_service_url}:#{ MY_PUBLIC_PORT}" + end + + if MY_PUBLIC_PORT == "443" + linuxfr_service_url = "https://#{MY_DOMAIN}" + end + MY_PUBLIC_URL = linuxfr_service_url + + + IMG_DOMAIN = ENV["IMAGE_DOMAIN"] || "dlfp.lo" + IMG_PUBLIC_PORT = ENV["IMAGE_DOMAIN_HTTP_PORT"] || "80" + + image_service_url = "http://#{IMG_DOMAIN}" + if IMG_PUBLIC_PORT != "" and IMG_PUBLIC_PORT != "80" + image_service_url = "#{image_service_url}:#{ IMG_PUBLIC_PORT}" + end + + if IMG_PUBLIC_PORT == "443" + image_service_url = "https://#{IMG_DOMAIN}" + end + IMG_PUBLIC_URL = image_service_url + + config.hosts << MY_DOMAIN + config.hosts << IMG_DOMAIN # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development diff --git a/config/environments/production.rb b/config/environments/production.rb index ba6ecd28e..8883e8701 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,7 +1,9 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. - MY_DOMAIN = 'linuxfr.org' - IMG_DOMAIN = 'img.linuxfr.org' + MY_DOMAIN = "linuxfr.org" + MY_PUBLIC_URL = 'https://linuxfr.org' + IMG_DOMAIN = "img.linuxfr.org" + IMG_PUBLIC_URL = 'https://img.linuxfr.org' # Code is not reloaded between requests. config.cache_classes = true diff --git a/config/environments/test.rb b/config/environments/test.rb index 6eb6bad93..6461b8b29 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,7 +1,9 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. - MY_DOMAIN = 'dlfp.lo' - IMG_DOMAIN = 'img.dlfp.lo' + MY_DOMAIN = "dlfp.lo" + MY_PUBLIC_URL = "http://dlfp.lo:9000" + IMG_DOMAIN = "img.dlfp.lo" + IMG_PUBLIC_URL = "http://dlfp.lo:9000" # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that From 7fe3d0b456984b8093d66c2d6c4bdd62599c4e1e Mon Sep 17 00:00:00 2001 From: Adrien Dorsaz Date: Sun, 31 May 2026 10:36:48 +0200 Subject: [PATCH 3/5] fix development.rb: `config.hosts` does not exists with Rails 5.2 --- config/environments/development.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/config/environments/development.rb b/config/environments/development.rb index d1075c2b6..ce60ba6a6 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -27,9 +27,6 @@ end IMG_PUBLIC_URL = image_service_url - config.hosts << MY_DOMAIN - config.hosts << IMG_DOMAIN - # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. From c1f87e998e5ebffe511a0300cf5e3744540a15d5 Mon Sep 17 00:00:00 2001 From: Adrien Dorsaz Date: Sun, 31 May 2026 21:37:16 +0200 Subject: [PATCH 4/5] make compose.yaml compatible with docker --- compose.yaml | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/compose.yaml b/compose.yaml index e5273d39f..e5ab54363 100644 --- a/compose.yaml +++ b/compose.yaml @@ -20,7 +20,7 @@ services: tmpfs: - /linuxfr.org/public/tmp:size=100M healthcheck: - test: ["CMD", "curl", "--silent", "--fail", "--head", "http://localhost:3000"] + test: curl --silent --fail --head http://localhost:3000 interval: 10s start_period: 5s depends_on: @@ -38,7 +38,7 @@ services: env_file: - deployment/default.env healthcheck: - test: ["CMD", "curl", "--silent", "--fail", "--head", "http://localhost:9000"] + test: curl --silent --fail --head http://localhost:9000 interval: 10s start_period: 5s depends_on: @@ -53,7 +53,7 @@ services: env_file: - deployment/default.env healthcheck: - test: ["CMD", "curl", "--silent", "--fail", "--head", "http://localhost:8000/status"] + test: curl --silent --fail --head http://localhost:8000/status interval: 10s start_period: 5s depends_on: @@ -76,10 +76,14 @@ services: # If you customize the published port, you have to update the # DOMAIN_HTTP_PORT and IMAGE_DOMAIN_HTTP_PORT variables # into the `deployment/default.env` file too - published: 127.0.0.1:9000 + published: 9000 + host_ip: 127.0.0.1 protocol: tcp healthcheck: - test: ["CMD", "curl", "--silent", "--fail", "--fail-early", "--location", "--head", "http://$$DOMAIN:8080", "http://$$DOMAIN:8080/img/status", "http://$$DOMAIN:8080/b", "http://$$IMAGE_DOMAIN:8080/status"] + test: >- + curl --silent --fail --fail-early --location --head + http://$$DOMAIN:8080 http://$$DOMAIN:8080/img/status + http://$$DOMAIN:8080/b http://$$IMAGE_DOMAIN:8080/status interval: 10s start_period: 5s depends_on: @@ -103,6 +107,9 @@ services: aliases: - $${DOMAIN} - $${IMAGE_DOMAIN} + # fallback for Docker as it cannot add aliases from environment variables + - dlfp.lo + - image.dlfp.lo database: build: @@ -112,10 +119,13 @@ services: - deployment/default.env ports: - target: 3306 - published: 127.0.0.1:3306 + published: 3306 + host_ip: 127.0.0.1 protocol: tcp healthcheck: - test: ["CMD", "mysql", "-h", "127.0.0.1", "-u", "$$MYSQL_USER", "--password=$$MYSQL_PASSWORD", "--execute", "\"SHOW DATABASES;\""] + test: >- + exec mysql -h 127.0.0.1 -u $$MYSQL_USER --password=$$MYSQL_PASSWORD + --execute 'SHOW DATABASES;' interval: 10s start_period: 5s volumes: @@ -124,7 +134,7 @@ services: redis: image: docker.io/redis:5 healthcheck: - test: ["CMD", "redis-cli", "--raw", "incr", "ping"] + test: redis-cli --raw incr ping interval: 10s start_period: 5s volumes: From 199bf4e13a82a0d6b2ba1c743a671d9697215a1d Mon Sep 17 00:00:00 2001 From: Adrien Dorsaz Date: Sun, 31 May 2026 21:55:19 +0200 Subject: [PATCH 5/5] fix linuxfr-img container cache folder permission Create the cache folder with permissions for ${UID} so docker/podman now which rights to set when it creates the`cache-img` volume for this path. --- deployment/linuxfr-img/Containerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/deployment/linuxfr-img/Containerfile b/deployment/linuxfr-img/Containerfile index 7af8fcdfd..d141461ab 100644 --- a/deployment/linuxfr-img/Containerfile +++ b/deployment/linuxfr-img/Containerfile @@ -44,7 +44,10 @@ RUN \ apt-get update; \ apt-get install -y --no-install-recommends \ curl; \ - apt-get clean; + apt-get clean; \ + mkdir -p /linuxfr-img/cache; \ + chown -R ${UID}:0 /linuxfr-img; \ + chmod -R 770 /linuxfr-img; USER ${UID} WORKDIR /linuxfr-img