Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ jobs:
run: |
ruby auto_build.rb base_slim_stable_${{ matrix.arch }}

- name: build web_only images for `main` branch
working-directory: image
run: |
ruby auto_build.rb base_web_only_main_${{ matrix.arch }}

- name: build web_only images for `stable` branch
working-directory: image
run: |
ruby auto_build.rb base_web_only_stable_${{ matrix.arch }}

- name: build release images for `main` branch
working-directory: image
run: |
Expand All @@ -83,6 +93,8 @@ jobs:

- name: tag release images
run: |
docker tag discourse/base:build_web_only_main_${{ matrix.arch }} discourse/base:2.0.${{ env.TIMESTAMP }}-web-only-main-${{ matrix.arch }}
docker tag discourse/base:build_web_only_stable_${{ matrix.arch }} discourse/base:2.0.${{ env.TIMESTAMP }}-web-only-stable-${{ matrix.arch }}
docker tag discourse/base:build_release_main_${{ matrix.arch }} discourse/base:2.0.${{ env.TIMESTAMP }}-main-${{ matrix.arch }}
docker tag discourse/base:build_release_main_${{ matrix.arch }}_pg_15 discourse/base:2.0.${{ env.TIMESTAMP }}-main-${{ matrix.arch }}-pg-15
docker tag discourse/base:build_release_stable_${{ matrix.arch }} discourse/base:2.0.${{ env.TIMESTAMP }}-stable-${{ matrix.arch }}
Expand Down Expand Up @@ -132,6 +144,8 @@ jobs:
run: |
docker login --username discoursebuild --password $DOCKERHUB_PASSWORD
docker push discourse/base:2.0.${{ env.TIMESTAMP }}-slim-${{ matrix.arch }}
docker push discourse/base:2.0.${{ env.TIMESTAMP }}-web-only-main-${{ matrix.arch }}
docker push discourse/base:2.0.${{ env.TIMESTAMP }}-web-only-stable-${{ matrix.arch }}
docker push discourse/base:2.0.${{ env.TIMESTAMP }}-main-${{ matrix.arch }}
docker push discourse/base:2.0.${{ env.TIMESTAMP }}-main-${{ matrix.arch }}-pg-15
docker push discourse/base:2.0.${{ env.TIMESTAMP }}-stable-${{ matrix.arch }}
Expand Down Expand Up @@ -163,6 +177,26 @@ jobs:
-a discourse/base:2.0.${{ env.TIMESTAMP }}-slim-amd64 \
-a discourse/base:2.0.${{ env.TIMESTAMP }}-slim-arm64

# Web-Only `main` timestamped
docker manifest create discourse/base:2.0.${{ env.TIMESTAMP }}-web-only \
-a discourse/base:2.0.${{ env.TIMESTAMP }}-web-only-main-amd64 \
-a discourse/base:2.0.${{ env.TIMESTAMP }}-web-only-main-arm64

# Web-Only `main` release
docker manifest create discourse/base:web-only \
-a discourse/base:2.0.${{ env.TIMESTAMP }}-web-only-main-amd64 \
-a discourse/base:2.0.${{ env.TIMESTAMP }}-web-only-main-arm64

# Web-Only `stable` timestamped
docker manifest create discourse/base:2.0.${{ env.TIMESTAMP }}-web-only-stable \
-a discourse/base:2.0.${{ env.TIMESTAMP }}-web-only-stable-amd64 \
-a discourse/base:2.0.${{ env.TIMESTAMP }}-web-only-stable-arm64

# Web-Only `stable` release
docker manifest create discourse/base:web-only-stable \
-a discourse/base:2.0.${{ env.TIMESTAMP }}-web-only-stable-amd64 \
-a discourse/base:2.0.${{ env.TIMESTAMP }}-web-only-stable-arm64

# Full Discourse `main` branch timestamped
docker manifest create discourse/base:2.0.${{ env.TIMESTAMP }} \
-a discourse/base:2.0.${{ env.TIMESTAMP }}-main-amd64 \
Expand Down Expand Up @@ -200,6 +234,10 @@ jobs:

docker manifest push discourse/base:2.0.${{ env.TIMESTAMP }}-slim
docker manifest push discourse/base:slim
docker manifest push discourse/base:2.0.${{ env.TIMESTAMP }}-web-only
docker manifest push discourse/base:2.0.${{ env.TIMESTAMP }}-web-only-stable
docker manifest push discourse/base:web-only
docker manifest push discourse/base:web-only-stable
docker manifest push discourse/base:2.0.${{ env.TIMESTAMP }}
docker manifest push discourse/base:2.0.${{ env.TIMESTAMP }}-pg-15
docker manifest push discourse/base:2.0.${{ env.TIMESTAMP }}-stable
Expand Down
25 changes: 25 additions & 0 deletions image/auto_build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,31 @@
"--platform linux/arm64 --target discourse_slim --build-arg=\"DISCOURSE_BRANCH=stable\"",
use_cache: true,
},
base_web_only_main_amd64: {
name: "base",
tag: "discourse/base:build_web_only_main_amd64",
extra_args: "--target discourse_web_only",
use_cache: true,
},
base_web_only_stable_amd64: {
name: "base",
tag: "discourse/base:build_web_only_stable_amd64",
extra_args: "--target discourse_web_only --build-arg=\"DISCOURSE_BRANCH=stable\"",
use_cache: true,
},
base_web_only_main_arm64: {
name: "base",
tag: "discourse/base:build_web_only_main_arm64",
extra_args: "--platform linux/arm64 --target discourse_web_only",
use_cache: true,
},
base_web_only_stable_arm64: {
name: "base",
tag: "discourse/base:build_web_only_stable_arm64",
extra_args:
"--platform linux/arm64 --target discourse_web_only --build-arg=\"DISCOURSE_BRANCH=stable\"",
use_cache: true,
},
base_release_main_amd64: {
name: "base",
tag: "discourse/base:build_release_main_amd64",
Expand Down
18 changes: 7 additions & 11 deletions image/base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ RUN --mount=type=tmpfs,target=/var/log \
sh -c "test -f /sbin/initctl || ln -s /bin/true /sbin/initctl"; \
apt-get -y update && DEBIAN_FRONTEND=noninteractive apt-get -y install runit socat \
libpq-dev postgresql-client-${PG_MAJOR} \
postgresql-${PG_MAJOR} postgresql-contrib-${PG_MAJOR} postgresql-${PG_MAJOR}-pgvector \
nodejs yarn &&\
mkdir -p /etc/runit/1.d

Expand Down Expand Up @@ -130,7 +129,6 @@ ADD install-jemalloc /tmp/install-jemalloc
RUN /tmp/install-jemalloc

ADD install-redis /tmp/install-redis
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be moved too.

Copy link
Member Author

@featheredtoast featheredtoast May 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd need a way to add it to the dev image as well when we build that, as that also needs to be able to run install-redis in a different context.

My concern with copying is that any changes to install-redis could get out of sync in an update.

Probably a preferred solution or way forward that would allow is to give a shared context, IE reorganize things so all dockerfiles live under a common directory. base.dockerfile dev.dockerfile test.dockerfile etc. but I'd prefer that reorganization be left for a potential future refactor stage.

RUN /tmp/install-redis

ADD install-oxipng /tmp/install-oxipng
RUN /tmp/install-oxipng
Expand All @@ -145,14 +143,6 @@ RUN gem install pups --force &&\
ADD thpoff.c /src/thpoff.c
RUN gcc -o /usr/local/sbin/thpoff /src/thpoff.c && rm /src/thpoff.c

# clean up for docker squash
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We no longer use docker squash - that has been gone for a long time. Here, we now desire /tmp to stick around as a way of keeping /tmp/install-redis around for installing later within a build for discourse-dev.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we could delete these after the RUN command that generates them to keep the image small.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other option we have is to add a tmpfs have a for these during the build.

Note that I'm keeping /tmp around to ensure install-redis remains as needed - it's called in both this image as well as the dev image.

RUN rm -fr /usr/local/share/doc &&\
rm -fr /usr/local/share/ri &&\
rm -fr /var/lib/apt/lists/* &&\
rm -fr /root/.gem &&\
rm -fr /root/.npm &&\
rm -fr /tmp/*

# this is required for aarch64 which uses buildx
# see https://github.com/docker/buildx/issues/150
RUN rm -f /etc/service
Expand All @@ -168,7 +158,7 @@ RUN install -dm 0755 -o discourse -g discourse /var/www/discourse &&\
sudo -u discourse git clone --branch $DISCOURSE_BRANCH --filter=tree:0 https://github.com/discourse/discourse.git /var/www/discourse &&\
gem install bundler --conservative -v $(awk '/BUNDLED WITH/ { getline; gsub(/ /,""); print $0 }' /var/www/discourse/Gemfile.lock)

FROM discourse_slim AS discourse_release
FROM discourse_slim AS discourse_web_only
ENV RAILS_ENV=production

RUN cd /var/www/discourse &&\
Expand All @@ -181,3 +171,9 @@ RUN cd /var/www/discourse &&\

RUN cd /var/www/discourse &&\
sudo -u discourse /bin/bash -c 'if [ -f yarn.lock ]; then yarn install --frozen-lockfile && yarn cache clean; else pnpm install --frozen-lockfile; fi'

FROM discourse_web_only AS discourse_release
RUN --mount=type=tmpfs,target=/var/log \
apt-get -y update && DEBIAN_FRONTEND=noninteractive apt-get -y install \
postgresql-${PG_MAJOR} postgresql-contrib-${PG_MAJOR} postgresql-${PG_MAJOR}-pgvector
RUN /tmp/install-redis
6 changes: 6 additions & 0 deletions image/discourse_dev/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ FROM discourse/base:$from_tag

#LABEL maintainer="Sam Saffron \"https://twitter.com/samsaffron\""

# Install Postgres and Redis
RUN --mount=type=tmpfs,target=/var/log \
apt-get -y update && DEBIAN_FRONTEND=noninteractive apt-get -y install \
postgresql-${PG_MAJOR} postgresql-contrib-${PG_MAJOR} postgresql-${PG_MAJOR}-pgvector
RUN /tmp/install-redis

# Remove the code added on base image
RUN rm -rf /var/www/*

Expand Down