Move `RAILS_ENV` to release image; build discourse_dev from slim (#725)
authorDavid Taylor <david@taylorhq.com>
Wed, 26 Jul 2023 11:18:10 +0000 (12:18 +0100)
committerGitHub <noreply@github.com>
Wed, 26 Jul 2023 11:18:10 +0000 (12:18 +0100)
Unfortunately there is no way to 'unset' an ENV in a Dockerfile. We were working around this by setting `RAILS_ENV` to an empty string in the discourse_dev dockerfile, but that didn't work in every situation.

The discourse_dev image doesn't rely on anything in the 'release' layer of the base image. In fact, it deletes the entire contents of `/var/www/*`.

This commit resolves the situation by:

- Moving the `RAILS_ENV=production` line to the 'release' layer of the base image
- Updating the discourse_dev image to be based on the 'slim' base image

image/base/release.Dockerfile
image/base/slim.Dockerfile
image/discourse_dev/Dockerfile

index 7a7aba82358cbdd5b8773bfb0de06dfd8baff2bd..95c0c9c81ec9cba902f5290ab29df45544368b88 100644 (file)
@@ -3,6 +3,8 @@ ARG tag=build_slim
 
 FROM $from:$tag
 
+ENV RAILS_ENV=production
+
 RUN cd /var/www/discourse &&\
     sudo -u discourse bundle config --local deployment true &&\
     sudo -u discourse bundle config --local path ./vendor/bundle &&\
index a5cc08671660f3b5dd3878f0df955621fa323ccd..f36c5937b94ed2115bc3bb42c7317b551f7cef89 100644 (file)
@@ -4,7 +4,6 @@ FROM debian:bullseye-slim
 
 ENV PG_MAJOR=13 \
     RUBY_ALLOCATOR=/usr/lib/libjemalloc.so.1 \
-    RAILS_ENV=production \
     RUSTUP_HOME=/usr/local/rustup \
     CARGO_HOME=/usr/local/cargo \
     PATH=/usr/local/cargo/bin:$PATH \
index 478cd56234bbd4ca7d1fc44a1e141d943e04f605..4bbd9e4c941494c65c2a03268497f14244fd4aa9 100644 (file)
@@ -1,9 +1,6 @@
 # NAME:     discourse/discourse_dev
 # VERSION:  release
-FROM discourse/base:release
-
-# Unset RAILS_ENV to allow running both dev stuff and tests
-ENV RAILS_ENV=
+FROM discourse/base:slim
 
 #LABEL maintainer="Sam Saffron \"https://twitter.com/samsaffron\""