discourse_docker.git
18 months agoFEATURE: Fix Discourse installation support in China (#793)
耗子 [Mon, 6 May 2024 05:47:35 +0000 (13:47 +0800)]
FEATURE: Fix Discourse installation support in China (#793)

This commit does 2 things:

1. Added a new yarn hook to replace the npm mirror before `yarn install`.
2. Modified `web.china.template.yml` to add more mirror sources.

Below is an explanation of these modifications:

- The GitHub proxy added in `web.china.template.yml` has existed in China for many years, and its repository https://github.com/hunshcn/gh-proxy has 6k+ stars, which can ensure its security and stability.
- The NPM mirror site added in `web.china.template.yml` is maintained by Alibaba Group, one of the largest Internet companies in China.
- Modified the Gem mirror in `web.china.template.yml` to the mirror provided by Tsinghua University, one of the top universities in China.
- The reason why sed is used to replace the `yarn.lock` file is because `yarn install --frozen-lockfile` is used for installation below. If the url is not replaced, the NPM mirror will not take effect.

After applying these modifications, I successfully installed Discourse on the Tencent Cloud China server. No more network problems.

18 months agoDEV: Bump default base image for launcher to `discourse/base:2.0.20240502-0021` ...
Alan Guo Xiang Tan [Thu, 2 May 2024 01:46:00 +0000 (09:46 +0800)]
DEV: Bump default base image for launcher to `discourse/base:2.0.20240502-0021` (#795)

This is necessary to pull in 303b646c3c48fc3179af954433d9fa797e70a3b9

18 months agoDEV: Bump Ruby to 3.2.4 (#794)
Alan Guo Xiang Tan [Tue, 30 Apr 2024 00:30:31 +0000 (08:30 +0800)]
DEV: Bump Ruby to 3.2.4 (#794)

This commit updates Ruby to 3.2.4 which includes security fixes for the
following CVEs:

* CVE-2024-27282: Arbitrary memory address read vulnerability with Regex search
* CVE-2024-27281: RCE vulnerability with .rdoc_options in RDoc
* CVE-2024-27280: Buffer overread vulnerability in StringIO

19 months agoDEV: update postgres 15 template for tags (#790)
Jeff Wong [Thu, 11 Apr 2024 18:52:00 +0000 (11:52 -0700)]
DEV: update postgres 15 template for tags (#790)

19 months agoAdd tags to pups templates (#751)
Jeff Wong [Wed, 10 Apr 2024 23:29:57 +0000 (16:29 -0700)]
Add tags to pups templates (#751)

* Add tags to pups templates

The purpose here is to allow greater flexibility in how and where
docker images are built and run. It achieves this by breaking up
build steps into distinct run steps which can be saved along the way.
Customizable base images may then be prebuilt with as many batteries
included as possible, with zero environment setup so those images
can then be configured at a later stage.

Add the ability to run partial pups configuration:
`build`: build base image with no db - ember build.
`precompile`: precompile stage that requires postgres and redis.
`migrate`: run migration tasks.
`db`: start bundled postgres/redis, if included.

Adds a create_db script in postgres template for creating db on the fly.
Called below in unicorn run:

updates unicorn run command with 3 env flags:
CREATE_DB_ON_BOOT: if 1, creates base db schema, allows for deferral of creation.
MIGRATE_ON_BOOT: if 1, runs db:migrate - allows for deferral of db migration.
PRECOMPILE_ON_BOOT: if 1, precompiles assets (without ember build).

PRECOMPILE_ON_BOOT initially defaults to 1 in base builds (no tags).
During the `precompile` build step, this updates the default to be 0.

All other new flags default to 0 (off). With these three flags, we're now able
to ship and start a container from a base image, and it'll be able to bootstrap
a blank database.

Updates hook to start redis before_db_migrate as before_code hook
is not guaranteed to fire before migrate tasks if pups is filtered by tags.

19 months agoRemoving the -p from the "nc" command. (#697)
SnR [Thu, 4 Apr 2024 02:23:47 +0000 (05:23 +0300)]
Removing the -p from the "nc" command. (#697)

Removing the -p from the "nc" command.
Reason:
# nc -w 4 -l -p 80
nc: cannot use -p and -l

Without -p it works just fine.

> -l' Used to specify that nc should listen for an incoming connection rather than initiate a connection to a remote host. It is an error to use this option in conjunction with the -p, -s, or -z options. Additionally, any timeouts specified with the -w option are ignored.

20 months agoDEV: Set RUBY_VERSION and DEBIAN_RELEASE env (#789)
Alan Guo Xiang Tan [Wed, 27 Mar 2024 22:40:38 +0000 (06:40 +0800)]
DEV: Set RUBY_VERSION and DEBIAN_RELEASE env (#789)

Why this change?

This envs allows the Debian release name and Ruby version to be easily
determined without having to know which commands to run.

20 months agoRevert "Upgrade Debian to Bookworm" (#788)
Alan Guo Xiang Tan [Tue, 26 Mar 2024 22:32:09 +0000 (06:32 +0800)]
Revert "Upgrade Debian to Bookworm" (#788)

This reverts commit 23e7b55d42a573bfc313ff965ed3c0a1ea7e0f45.

The CI build on `discourse/discourse` and our internal CI is broken
because of this.

20 months agoUpgrade Debian to Bookworm
Loïc Guitaut [Tue, 26 Mar 2024 09:13:38 +0000 (10:13 +0100)]
Upgrade Debian to Bookworm

20 months agoDEV: Add a default browser for testem in discourse_test
Loïc Guitaut [Mon, 25 Mar 2024 16:55:20 +0000 (17:55 +0100)]
DEV: Add a default browser for testem in discourse_test

Related to https://github.com/discourse/discourse/pull/26244

20 months agoAdd Chromium to our images
Loïc Guitaut [Thu, 21 Mar 2024 15:27:02 +0000 (16:27 +0100)]
Add Chromium to our images

Chrome isn’t available for aarch64 yet, but Chromium (which is basically
the same browser without the proprietary bits from Google) is shipped by
Debian. They also ship a Chrome driver compiled for aarch64.

This patch adds Chromium to our images without removing Chrome on
x86_64, allowing a smooth transition to using Chromium only.

20 months agoIncrease build time for arm64 scheduled build (#785)
Alan Guo Xiang Tan [Fri, 22 Mar 2024 12:41:24 +0000 (20:41 +0800)]
Increase build time for arm64 scheduled build (#785)

Scheduled build for arm64 running on 2cores is timing out at 30 minutes.
Let's give it some more time

20 months agoRevert "Use Chromium instead of Chrome (#782)" (#783)
Alan Guo Xiang Tan [Wed, 20 Mar 2024 23:46:57 +0000 (07:46 +0800)]
Revert "Use Chromium instead of Chrome (#782)" (#783)

This reverts commit e6ffa64d9d7622327b134c8397f59edf832e4299.

We need to fix the various Chrome assumptions in Discourse core.

20 months agoFix: Remove egrep for grep -E (#680)
Steffy Fort [Wed, 20 Mar 2024 21:54:55 +0000 (22:54 +0100)]
Fix: Remove egrep for grep -E (#680)

Co-authored-by: Steffy Fort <steffy.fort@cozycloud.cc>
20 months agoUse Chromium instead of Chrome (#782)
Loïc Guitaut [Wed, 20 Mar 2024 21:48:52 +0000 (22:48 +0100)]
Use Chromium instead of Chrome (#782)

Chrome isn’t available yet for aarch64, but Chromium (which is basically
the same browser without the proprietary bits from Google) is shipped by
Debian. They also ship a Chrome driver compiled for aarch64.

By using Chromium instead of Chrome, we unify how we do things
regardless of the architecture used in the generated image.

20 months agoRefactor Github action build workflow to build for both arm64/amd64 (#781)
Alan Guo Xiang Tan [Tue, 19 Mar 2024 22:26:36 +0000 (06:26 +0800)]
Refactor Github action build workflow to build for both arm64/amd64 (#781)

Why this change?

Now that we can efficiently build Docker images targeted at `linux/arm64`,
we will start to release images for `linux/arm64` in the same way we do
for `linux/amd64` images.

Images released for `linux/amd64` are tagged as follows:

1. discourse/base:2.0.\<datetime\>-slim
2. discourse/base:slim
3. discourse/base:2.0.\<datetime\>
4. discourse/base:release

For `linux/arm64`, the images are tagged as follows:

1. discourse/base:2.0.\<datetime\>-slim-arm64
2. discourse/base:slim-arm64
3. discourse/base:2.0.\<datetime\>-arm64
4. discourse/base:release-arm64
5. discourse/base:aarch64 (For backwards compatibility)

For `linux/arm64`, we unfortunately cannot install chrome because chrome
does not currently release binaries for the arch. Therefore, we install
chromium which chrome is based off and also install the chromedriver
binary for `linux/arm64` released by the electron project.

20 months agoUse Github hosted ARM runners to build arm64/aarch64 release image (#779)
Alan Guo Xiang Tan [Tue, 19 Mar 2024 02:29:56 +0000 (10:29 +0800)]
Use Github hosted ARM runners to build arm64/aarch64 release image (#779)

Why this change?

We have been given access to Github's private beta of ARM hosted
runners. Switching to ARM runners should drastically speed up the time
required for us to build our ARM image.

What does this change do?

1. Switch to use Github's ARM hosted runners.
2. Build release image for arm64 as well. We previously only built the
   slim image because building the release image through emulation is
   way too slow so we skipped the release image.
3. Update `bundle` in `release.Dockerfile` to install gems in parallel
   based on the number of cores instead of hardcoding it to 4 jobs.

20 months agoFEATURE: Update RUBY_ALLOCATOR to work on both x64 and arm64 (#777)
Rafael dos Santos Silva [Mon, 4 Mar 2024 15:42:49 +0000 (12:42 -0300)]
FEATURE: Update RUBY_ALLOCATOR to work on both x64 and arm64 (#777)

automatically

While x64 is still on jemalloc 3.6, arm64 is using latest jemalloc.

They have different names for the library file, so we will now use the
symlink to automatically load the one available.

20 months agoFIX: Config page size for Redis Jemalloc on ARM64 (#776)
Rafael dos Santos Silva [Fri, 1 Mar 2024 20:14:57 +0000 (17:14 -0300)]
FIX: Config page size for Redis Jemalloc on ARM64 (#776)

20 months agoFIX: Move arm to newer jemalloc (#775)
Rafael dos Santos Silva [Fri, 1 Mar 2024 17:34:46 +0000 (14:34 -0300)]
FIX: Move arm to newer jemalloc (#775)

20 months agoremove swapfile script
Andrew Schleifer [Thu, 29 Feb 2024 13:46:23 +0000 (13:46 +0000)]
remove swapfile script

The instructions have, for quite some time now, pointed users at the
`discourse-setup` script. That will prompt the user to create a swapfile
if necessary and configure relevant sysctls.

20 months agoFIX: Adapt jemalloc page size for pi5 bookworm PAGESIZE (#774)
Rafael dos Santos Silva [Thu, 29 Feb 2024 17:13:54 +0000 (14:13 -0300)]
FIX: Adapt jemalloc page size for pi5 bookworm PAGESIZE (#774)

Debian Bookwork on Pi 5 uses 64k pages, so we need to adapt the jemalloc.

This should be compatible with pi4 and older too.

20 months agouse DISCOURSE_BASE_URL in mail-receiver sample
Evgeni Golov [Fri, 22 Sep 2023 07:21:52 +0000 (09:21 +0200)]
use DISCOURSE_BASE_URL in mail-receiver sample

while `DISCOURSE_MAIL_ENDPOINT` is still accepted by the mail-receiver code, the documentation prefers `DISCOURSE_BASE_URL` and so should this example

see https://github.com/discourse/mail-receiver/blob/deae52039f4679b31e01302dadace3c0f018cec8/README.md

20 months agoFEATURE: Add template for PostgreSQL 15
Mwaniki Wairungu [Thu, 29 Feb 2024 09:36:58 +0000 (12:36 +0300)]
FEATURE: Add template for PostgreSQL 15

The new templates/postgres.15.template.yml file allows bootstrapping
new containers using PostgreSQL version 15, or upgrading an existing
container running on older PostgreSQL versions.

The default postgres template and base image shall be bumped in a
follow-up commit.

21 months agoPERF: Speed up building slim image by setting --jobs to number of cores (#770)
Alan Guo Xiang Tan [Tue, 6 Feb 2024 08:38:04 +0000 (16:38 +0800)]
PERF: Speed up building slim image by setting --jobs to number of cores (#770)

On a M3 Max macbook pro with 14 cores,

Before:

```
=> [25/44] RUN /tmp/install-imagemagick                                 150.6s
=> [27/44] RUN /tmp/install-jemalloc                                     54.9s
=> [31/44] RUN /tmp/install-redis                                        42.9s
```

After:

```
=> [25/44] RUN /tmp/install-imagemagick                                  44.4s
=> [27/44] RUN /tmp/install-jemalloc                                     13.7s
=> [31/44] RUN /tmp/install-redis                                        11.7s
```

21 months agoPERF: Use `-O2` gcc compilation flag for imagemagick (#768)
Alan Guo Xiang Tan [Mon, 5 Feb 2024 23:43:15 +0000 (07:43 +0800)]
PERF: Use `-O2` gcc compilation flag for imagemagick (#768)

Why this change?

We have noticed that our compiled imagemagick binary is slower than the
distributed binaries in the same environment and started debugging why.
One thing I noticed is that distributed binaries usually include the
`-O2` gcc compilation flag. When applying it locally, I saw significant
speed up.

Without -O2 flag:

```
root@1d7277f72a4f:/# time convert -limit memory 10GiB -limit disk 10GiB -size $(seq 8000 8500 | shuf | head -n1)x9000 xc:"rgb($(shuf -i 0-255 -n1),$(shuf -i 0-255 -n1),$(shuf -i 0-255 -n1))" random_image.png

real 0m3.376s
user 0m6.355s
sys 0m0.410s
root@1d7277f72a4f:/# time identify -format "%Q" random_image.png
92
real 0m1.018s
user 0m0.883s
sys 0m0.135s
```

With -O2 flag:

```
root@0779afa71102:/# time convert -limit memory 10GiB -limit disk 10GiB -size $(seq 8000 8500 | shuf | head -n1)x9000 xc:"rgb($(shuf -i 0-255 -n1),$(shuf -i 0-255 -n1),$(shuf -i 0-255 -n1))" random_image.png

real 0m1.118s
user 0m1.555s
sys 0m1.680s
root@0779afa71102:/# time identify -format "%Q" random_image.png
92
real 0m0.330s
user 0m0.197s
sys 0m0.133s
```

21 months agoFEATURE: Add early support for aarch64 in dev env
Loïc Guitaut [Thu, 11 Jan 2024 17:00:45 +0000 (18:00 +0100)]
FEATURE: Add early support for aarch64 in dev env

This patch adds some new steps to support the aarch64 architecture
on Linux.

An updated version of Rust is needed to compile the `selenium-manager`
binary as it’s not shipped with the `selenium-webdriver` gem yet.
In the same vein, Google doesn’t ship an aarch64 version of Chrome yet,
so it doesn’t make sense to install even Chromium in the image. We have
to rely on Firefox to run the system specs.

23 months agoBump default base image to discourse/base:2.0.20231218-0429
Chris Rendle-Short [Mon, 18 Dec 2023 23:30:51 +0000 (10:30 +1100)]
Bump default base image to discourse/base:2.0.20231218-0429

23 months agoSECURITY: Bump Nginx to 1.25.3 (#763)
Chris Rendle-Short [Mon, 18 Dec 2023 04:18:44 +0000 (15:18 +1100)]
SECURITY: Bump Nginx to 1.25.3 (#763)

The updated version contains mitigations against CVE-2023-44487 (HTTP/2 rapid reset attack).

Upstream changelog: https://nginx.org/en/CHANGES

23 months agoBump default base image to discourse/base:2.0.20231214-0023
Andrew Schleifer [Fri, 15 Dec 2023 05:14:16 +0000 (05:14 +0000)]
Bump default base image to discourse/base:2.0.20231214-0023

23 months agoDEV: add plugin_compatibility hook (#760)
Jeff Wong [Wed, 6 Dec 2023 21:08:48 +0000 (13:08 -0800)]
DEV: add plugin_compatibility hook (#760)

23 months agoFIX: Y/n prompt should treat "no value" as yes
Michael Brown [Thu, 30 Nov 2023 20:05:16 +0000 (15:05 -0500)]
FIX: Y/n prompt should treat "no value" as yes

2 years agoFIX: Install plugin gems in `discourse/discourse_test` image (#758)
Alan Guo Xiang Tan [Thu, 23 Nov 2023 10:12:37 +0000 (18:12 +0800)]
FIX: Install plugin gems in `discourse/discourse_test` image (#758)

Why this change?

In
https://github.com/discourse/discourse/commit/dec68d780c58ef0954865b786d04b653c20e26fa,
the `plugin:install_all_gems` Rake task was made a noop because the Rake
task itself was flawed and running a Rake task will actually activate
all plugins which installs the required gems in the process. However,
plugins are not automatically activated in the test environment which
this image operates in. As such, we need to set `LOAD_PLUGINS=1` to when
running the `plugin:install_all_gems` Rake task.

2 years agoDEV: Parameterize offline page repository (#754)
Jeff Wong [Thu, 9 Nov 2023 23:08:35 +0000 (15:08 -0800)]
DEV: Parameterize offline page repository (#754)

allow for a custom offline page repository

2 years agoadd env for migrate, precompile and create db on boot (#753)
Jeff Wong [Wed, 8 Nov 2023 02:10:32 +0000 (18:10 -0800)]
add env for migrate, precompile and create db on boot (#753)

2 years agoFEATURE: add offline page template (#752)
Jeff Wong [Thu, 2 Nov 2023 05:07:05 +0000 (22:07 -0700)]
FEATURE: add offline page template (#752)

* FEATURE: add offline page template

2 years agoBump base image for pups update (#749)
Jeff Wong [Mon, 23 Oct 2023 20:08:42 +0000 (13:08 -0700)]
Bump base image for pups update (#749)

2 years agoBump default base image to 2.0.20231023-1613 (#748)
Jeff Wong [Mon, 23 Oct 2023 18:35:30 +0000 (11:35 -0700)]
Bump default base image to 2.0.20231023-1613 (#748)

Updates latest version of pups, allowing --tags and --skip-tags arguments

2 years agoDEV: Fix broken ARM64 build (#745)
Alan Guo Xiang Tan [Tue, 17 Oct 2023 08:08:49 +0000 (16:08 +0800)]
DEV: Fix broken ARM64 build (#745)

Why this change?

The `docker tag discourse/base:aarch64-slim localhost:5000/discourse/base:aarch64-slim
` command broked in 0c93b2207d22b9de69b503460dc269f8b33935c2 because
there is no `aarch64-slim` image being built. Instead, the `ruby
auto_build.rb base_slime_64` command builds an image with the
`discourse/base:build_slim_arm64` tag.

What does this change do?

This change removes the tagging command because it is pointless for us
to tag it.

2 years agoDEV: Remove use of `--squash` flag and switch to buildx (#743)
Alan Guo Xiang Tan [Mon, 16 Oct 2023 02:41:05 +0000 (10:41 +0800)]
DEV: Remove use of `--squash` flag and switch to buildx (#743)

Why this change?

In CI, we are seeing the following warning message:

```
WARNING: experimental flag squash is removed with BuildKit. You should squash inside build using a multi-stage Dockerfile for efficiency.
```

Basically, the `--squash` flag has not been working for quite some time
and is redundant.

What does this change do?

* This change removes the use of the `--squash` flag.

* This change uses the `buildx` tool in `auto_build.rb` as we prepare to
  build images for multiple platforms.

2 years agofixup count of physical cores in discourse-setup (#739)
BigEd [Mon, 9 Oct 2023 13:47:25 +0000 (14:47 +0100)]
fixup count of physical cores in discourse-setup (#739)

See also PR #702 for branch master

2 years agoBump default base image to discourse/base:2.0.20231004-0028
Andrew Schleifer [Wed, 4 Oct 2023 03:52:52 +0000 (03:52 +0000)]
Bump default base image to discourse/base:2.0.20231004-0028

2 years agoDEV: Configure bundle jobs to 4 (#736)
Alan Guo Xiang Tan [Fri, 15 Sep 2023 01:49:13 +0000 (09:49 +0800)]
DEV: Configure bundle jobs to 4 (#736)

This ensures that we be default runs bundle install with at least 4
jobs.

2 years agoDEV: Install bundler version used by Discourse as a default. (#735)
Alan Guo Xiang Tan [Thu, 14 Sep 2023 00:38:47 +0000 (08:38 +0800)]
DEV: Install bundler version used by Discourse as a default. (#735)

Why this change?

Previously we were running `gem install bundler` to install bundler but
this would install the latest bundler version instead of the bundler
version being used by Discourse. As a result, we end up having to
install bundler over and over again when using the image most of the
time.

2 years agoDEV: Switch test container to use exec instead of shell entrypoint (#734)
Daniel Waterworth [Mon, 11 Sep 2023 16:24:21 +0000 (11:24 -0500)]
DEV: Switch test container to use exec instead of shell entrypoint (#734)

This allows command line arguments to be passed.

2 years agoDEV: Add minio install to test image (#726)
Martin Brennan [Wed, 30 Aug 2023 00:47:32 +0000 (10:47 +1000)]
DEV: Add minio install to test image (#726)

Relies on discourse/discourse#22975 to be merged first;
the minio_runner gem can self-install minio, but it's better to just bake the binaries
into the test image. Just uses the script/install_minio.rb script to use the gem to
install required binaries.

We are adding minio to the core project to run system tests for S3 uploads
using minio as a mock S3 store.

2 years agoBump default base image to discourse/base:2.0.20230825-1850 (#731)
Leonardo Mosquera [Mon, 28 Aug 2023 18:12:24 +0000 (15:12 -0300)]
Bump default base image to discourse/base:2.0.20230825-1850 (#731)

2 years agoInstall latest Postgres client version besides the one for PG_MAJOR (#729)
Leonardo Mosquera [Fri, 25 Aug 2023 18:30:28 +0000 (15:30 -0300)]
Install latest Postgres client version besides the one for PG_MAJOR (#729)

Before, if a remote server is upgraded to a newer PG version, it wouldn't be able to be backed up from inside the application, since `pg_dump` would be a lower version, resulting in this:

```
pg_dump: error: server version: 15.3; pg_dump version: 13.11 (Debian 13.11-1.pgdg110+1)
pg_dump: error: aborting because of server version mismatch
```

With this change, `postgresql-${PG_MAJOR}` pulls in `postgresql-client` for the server version, AND `postgresql-client` metapackage pulls in the latest version available in the upstream Apt repository.

This guarantees there will be a `pg_dump` for the latest version available, so a remote server freshly upgraded to that latest version will always be able to be backed up from inside the application (since [`pg_wrapper`](https://github.com/credativ/postgresql-common/blob/master/pg_wrapper#L110) chooses the latest locally available version for remote connections).

* Bump Postgres client version ahead of Postgres server version bump
* Fall back to PG_MAJOR if client env var is undefined
* Use postgresql-client metapackage instead for latest client version

2 years agoDEV: Use `plain` buildkit output (#730)
Jarek Radosz [Fri, 25 Aug 2023 09:21:54 +0000 (11:21 +0200)]
DEV: Use `plain` buildkit output (#730)

it's much more CI-friendly

2 years agoFEATURE: add ripgrep to the base image (#728)
Sam [Thu, 24 Aug 2023 18:33:55 +0000 (04:33 +1000)]
FEATURE: add ripgrep to the base image (#728)

ripgrep is going to be used by discourse-ai to extract context from files
on the local disk.

This does increase the size of the image by 1.7MB or so, but heavily simplifies
deployment

Alternative mechanisms exists such as packing the binary in a gem but we
would pay more at install time delays.

2 years agoMove `RAILS_ENV` to release image; build discourse_dev from slim (#725)
David Taylor [Wed, 26 Jul 2023 11:18:10 +0000 (12:18 +0100)]
Move `RAILS_ENV` to release image; build discourse_dev from slim (#725)

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

2 years agoEnable pgvector in postgres template (#724)
Rafael dos Santos Silva [Thu, 13 Jul 2023 18:34:12 +0000 (15:34 -0300)]
Enable pgvector in postgres template (#724)

2 years agoBump default base image to discourse/base:2.0.20230711-0100
Andrew Schleifer [Tue, 11 Jul 2023 06:05:36 +0000 (06:05 +0000)]
Bump default base image to discourse/base:2.0.20230711-0100

2 years agoFIX: Cleanup node_modules when using non-default branch (#722)
David Taylor [Tue, 4 Jul 2023 13:39:54 +0000 (14:39 +0100)]
FIX: Cleanup node_modules when using non-default branch (#722)

Yarn seems to have issues 'downgrading' our set of packages from tests-passed (which are pre-installed in the base image) to the versions on the stable branch.

In the medium term we intend to switch to the pnpm package manager, which shouldn't have this issue. In the meantime, we can work around the problem by deleting the pre-installed node_modules and installing from scratch.

https://meta.discourse.org/t/270491

2 years agoBump default base image to discourse/base:2.0.20230703-0055
Andrew Schleifer [Mon, 3 Jul 2023 09:48:28 +0000 (09:48 +0000)]
Bump default base image to discourse/base:2.0.20230703-0055

2 years agobump acme.sh to 3.0.6
Andrew Schleifer [Wed, 14 Jun 2023 09:01:55 +0000 (09:01 +0000)]
bump acme.sh to 3.0.6

2 years agoPERF: Uninstall rust toolkit once ruby is built (#718)
David Taylor [Fri, 9 Jun 2023 12:40:27 +0000 (13:40 +0100)]
PERF: Uninstall rust toolkit once ruby is built (#718)

This tooling adds significant size to our docker image. We only need rust tooling while installing ruby/oxipng, and can clean it up immediately afterwards to avoid it persisting in the image

2 years agoSkip attempting `maxminddb:get` during build (#716)
David Taylor [Tue, 6 Jun 2023 09:37:15 +0000 (10:37 +0100)]
Skip attempting `maxminddb:get` during build (#716)

Fetching the maxmind database requires a license key, which we do not include during our base image build. This rake task has been failing with an error for some time

```
MaxMind IP database updates require a license
```

Following https://github.com/discourse/discourse/commit/0330f51d75b34c41666266d5fee4174b136be728, the task now hard-fails and breaks the build.

2 years agoFEATURE: Install pgvector for PostgreSQL (#684)
Rafael dos Santos Silva [Thu, 1 Jun 2023 00:32:19 +0000 (21:32 -0300)]
FEATURE: Install pgvector for PostgreSQL (#684)

2 years agoDEV: Remove `RUBY_GLOBAL_METHOD_CACHE_SIZE` (#711)
Jarek Radosz [Tue, 9 May 2023 09:57:55 +0000 (11:57 +0200)]
DEV: Remove `RUBY_GLOBAL_METHOD_CACHE_SIZE` (#711)

It doesn't do anything since ruby 3.0.0.preview1. It was removed in https://github.com/ruby/ruby/pull/2888

2 years agoBump default base image to 2.0.20230502-0058 (#715)
David Taylor [Tue, 2 May 2023 14:55:16 +0000 (15:55 +0100)]
Bump default base image to 2.0.20230502-0058 (#715)

2 years agoDEV: Introduce `enable-ruby-yjit template
Alan Guo Xiang Tan [Mon, 1 May 2023 02:50:50 +0000 (10:50 +0800)]
DEV: Introduce `enable-ruby-yjit template

This adds the `RUBY_YJIT_ENABLE` environment variable which would enable
Ruby 3.2's YJIT. See
https://github.com/ruby/ruby/blob/master/doc/yjit/yjit.md for more
information about YJIT.

2 years agotemplates: abort on fetch error
Saj Goonatilleke [Thu, 27 Apr 2023 09:29:23 +0000 (19:29 +1000)]
templates: abort on fetch error

2 years agoDEV: Install all yarn dependencies (#708)
David Taylor [Mon, 24 Apr 2023 10:33:34 +0000 (11:33 +0100)]
DEV: Install all yarn dependencies (#708)

`devDependencies` is often used for things like ember-cli build tooling. Until now we have been moving those things to `dependencies` in our `package.json`, but it makes more sense for us to conform to the industry norms.

2 years agoBump default base image to discourse/base:2.0.20230420-0104
Andrew Schleifer [Fri, 21 Apr 2023 04:10:11 +0000 (04:10 +0000)]
Bump default base image to discourse/base:2.0.20230420-0104

2 years agoDEV: Wait up to 10 minutes for safe PG stop (#709)
Rafael dos Santos Silva [Wed, 19 Apr 2023 20:02:28 +0000 (17:02 -0300)]
DEV: Wait up to 10 minutes for safe PG stop (#709)

Over the years we had LOTS of cases of PostgreSQL instances that weren't stopped properly. This gives PG more time to handle it's shutdown cleanly on the worst case, but will still shutdown fast in normal cases.

2 years agoFEATURE: Store the `version` parameter as custom value in git config
Gerhard Schlager [Thu, 13 Apr 2023 10:41:02 +0000 (12:41 +0200)]
FEATURE: Store the `version` parameter as custom value in git config

This is particularly useful when the version is pointing to a git tag like `beta`, otherwise we won't be able to reliably detect the tracked version at runtime.

2 years agoFIX: Rebuild fails when tracked `version` switches from branch to tag
Gerhard Schlager [Thu, 13 Apr 2023 10:39:19 +0000 (12:39 +0200)]
FIX: Rebuild fails when tracked `version` switches from branch to tag

We are replacing the `beta` branch with a tag of the same name. Rebuilding a container will fail when a user tracks the `beta` version and the base image was built at a time where `beta` was still a branch. This resolves that by pruning tags and branches and forcing an update of tags during the rebuild.

2 years agoBump default base image to run Ruby 3.2.2 as default
Alan Guo Xiang Tan [Mon, 10 Apr 2023 00:35:12 +0000 (08:35 +0800)]
Bump default base image to run Ruby 3.2.2 as default

Ruby 3.2.2 was released with a two security fixes. While the security
fixes have been assessed to have low impact on Discourse, we still want
to get the upgrade in as a preventive measure.

2 years agoAdd template to enable an IPv6 listener
Michael Brown [Tue, 4 Apr 2023 17:36:41 +0000 (13:36 -0400)]
Add template to enable an IPv6 listener

By default nginx in the container only listens for IPv4 connections. Some users
want to enable direct IPv6 connectivity to the container either via forwarding
or NAT. This provides an easy method to allow that.

2 years agoRemove stable-specific image (#700)
David Taylor [Tue, 4 Apr 2023 09:05:11 +0000 (10:05 +0100)]
Remove stable-specific image (#700)

This was only introduced as a temporary solution for Discourse 2.8, which is now EOL

2 years agoBum to latest Ruby (#699)
Rafael dos Santos Silva [Fri, 31 Mar 2023 14:50:12 +0000 (11:50 -0300)]
Bum to latest Ruby (#699)

2 years agoDEV: Ubuntu installs do not like bullseye-backports (#698)
Blake Erickson [Sun, 26 Mar 2023 13:12:01 +0000 (07:12 -0600)]
DEV: Ubuntu installs do not like bullseye-backports (#698)

Check for Ubuntu 22.04 and 22.10 versions before trying to use
`bullseye-backports` otherwise they throw this error.

```
E: The value 'bullseye-backports' is invalid for APT::Default-Release as
such a release is not available in the sources failed
```

2 years agoFIX: Rebuild was broken when an older image with shallow clone was used (#696)
Gerhard Schlager [Mon, 13 Mar 2023 20:55:19 +0000 (21:55 +0100)]
FIX: Rebuild was broken when an older image with shallow clone was used (#696)

This adds the original special handling for shallow clones back. It can be removed once everyone uses images with partial clones.

2 years agoBump base image to support partial clone (#695)
Gerhard Schlager [Mon, 13 Mar 2023 14:31:22 +0000 (15:31 +0100)]
Bump base image to support partial clone (#695)

2 years agoDEV: Create partial clone of discourse repository (#691)
Gerhard Schlager [Mon, 13 Mar 2023 09:58:46 +0000 (10:58 +0100)]
DEV: Create partial clone of discourse repository (#691)

A treeless clone is nearly as small as a shallow clone, but it contains the full history which makes it possible to easily checkout tags and commits and allows all features of docker_manager to work correctly.

See https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/ for more information on treeless clones.

Also this change makes it possible to correctly pull the main branch which didn't work before.

2 years agoDEV: Remove deprecation warnings from bundler (#690)
Gerhard Schlager [Mon, 13 Mar 2023 09:55:44 +0000 (10:55 +0100)]
DEV: Remove deprecation warnings from bundler (#690)

2 years agoFIX: Compiling oxipng didn't work on aarch64 (#694)
Gerhard Schlager [Mon, 13 Mar 2023 09:55:15 +0000 (10:55 +0100)]
FIX: Compiling oxipng didn't work on aarch64 (#694)

This uses the new sparse-registry feature from Rust 1.68 which lowers the memory usage. This avoids that cargo is killed due to an OOM issue (exit code 137) during "Updating crates.io index".

2 years agoCompile oxipng from source (#688)
Derek J. Lambert [Thu, 9 Mar 2023 02:04:11 +0000 (20:04 -0600)]
Compile oxipng from source (#688)

* Download and compile oxipng from source
* Move oxipng install step after rust since it uses cargo

2 years agoBump base image for Ruby 3.2 (#682)
Rafael dos Santos Silva [Fri, 24 Feb 2023 14:39:14 +0000 (11:39 -0300)]
Bump base image for Ruby 3.2 (#682)

2 years agoBump default base image to discourse/base:2.0.20230217-0055
Andrew Schleifer [Fri, 17 Feb 2023 04:40:41 +0000 (04:40 +0000)]
Bump default base image to discourse/base:2.0.20230217-0055

2 years agoDEV: Bump Ruby to 3.2.1 (#650)
Rafael dos Santos Silva [Fri, 17 Feb 2023 23:04:22 +0000 (20:04 -0300)]
DEV: Bump Ruby to 3.2.1 (#650)

* DEV: Bump Ruby to 3.2.0

* Add libffi-dev

* Ruby 3.2.1

2 years agoDEV: Remove `Press any key` from arm64 path (#675)
Jarek Radosz [Thu, 16 Feb 2023 11:07:09 +0000 (12:07 +0100)]
DEV: Remove `Press any key` from arm64 path (#675)

2 years agoDEV: update ImageMagick to 7.1.0-62 (#679)
Gabe Pacuilla [Tue, 14 Feb 2023 04:01:50 +0000 (23:01 -0500)]
DEV: update ImageMagick to 7.1.0-62 (#679)

2 years agoCorrect parameter naming for PTY.spawn (#678)
Leonardo Mosquera [Mon, 13 Feb 2023 23:19:47 +0000 (20:19 -0300)]
Correct parameter naming for PTY.spawn (#678)

Per the docs, first parameter for the block is STDOUT + STDERR, 2nd one is STDIN:
https://ruby-doc.org/3.1.3/exts/pty/PTY.html#method-c-spawn

As it is now, the method looks like it's reading from STDIN, though in
fact it's reading from an incorrectly named parameter for STDOUT.

2 years agoFIX: Relax min kernel version (#674) [ci skip]
Rafael dos Santos Silva [Fri, 3 Feb 2023 19:47:47 +0000 (16:47 -0300)]
FIX: Relax min kernel version (#674) [ci skip]

Users reported Discourse installing fine on kernel 4.4+.

See https://meta.discourse.org/t/kernel-version-upgrade-required-when-manually-updating-discourse/253756?u=falco

2 years agoAdd kernel version check (#673) [ci skip]
Rafael dos Santos Silva [Tue, 31 Jan 2023 18:31:02 +0000 (15:31 -0300)]
Add kernel version check (#673) [ci skip]

On Ruby 3.1 there is a `RuntimeException` when calling `Random.urandom` on platforms where it's not properly implemented, which includes people running Ubuntu 14.04 with kernel 3.13.

See

https://meta.discourse.org/t/docker-build-broken-site-down/252047
https://meta.discourse.org/t/undefined-method-deprecated-for-nil-nilclass-on-rebuild/251711
https://meta.discourse.org/t/discourse-update-error/253197
https://meta.discourse.org/t/bootstrap-failure-during-most-recent-upgrade/253424

2 years agoFIX: Perform git operations as owning user (#672)
David Taylor [Mon, 30 Jan 2023 16:06:46 +0000 (16:06 +0000)]
FIX: Perform git operations as owning user (#672)

The `git` version in our discourse_test docker image was recently updated to include a permissions check before running any git commands. For this to pass, git operations must be performed by the user which owns the git repository's directory.

2 years agoBump base image for ImageMagick SVG fix
Rafael dos Santos Silva [Wed, 18 Jan 2023 15:10:43 +0000 (12:10 -0300)]
Bump base image for ImageMagick SVG fix

2 years agoAdd explicit SVG delete to ImageMagick
Rafael dos Santos Silva [Fri, 13 Jan 2023 02:35:56 +0000 (23:35 -0300)]
Add explicit SVG delete to ImageMagick

2 years agoBump stable image
Rafael dos Santos Silva [Thu, 12 Jan 2023 03:51:54 +0000 (00:51 -0300)]
Bump stable image

2 years agoFix permissions error in dev image (#666)
David Taylor [Tue, 10 Jan 2023 20:43:35 +0000 (20:43 +0000)]
Fix permissions error in dev image (#666)

2 years agodiscourse_dev: use local bundler directory for temp install (#662)
David Taylor [Tue, 3 Jan 2023 17:58:51 +0000 (17:58 +0000)]
discourse_dev: use local bundler directory for temp install (#662)

discourse_dev installs a temporary version of Discourse to create a pre-migrated database. Previously this was installing gems in the global bundler directory, which could lead to permissions errors. This commit makes it use a local vendor directory, just like we do in the production install of Discourse.

2 years agoUpdate deprecated `::set-output` in GitHub actions workflow (#664)
David Taylor [Tue, 3 Jan 2023 17:29:46 +0000 (17:29 +0000)]
Update deprecated `::set-output` in GitHub actions workflow (#664)

2 years agodiscourse_test: Only apply `ENTRYPOINT` to release image (#663)
David Taylor [Tue, 3 Jan 2023 17:20:49 +0000 (17:20 +0000)]
discourse_test: Only apply `ENTRYPOINT` to release image (#663)

The slim images aren't able to run the full `rake docker:test` task, so having it as the entrypoint doesn't make sense. We only want it as the entrypoint on `discourse_test:release`

2 years agoUse larger GitHub actions workers (#661)
David Taylor [Tue, 3 Jan 2023 16:36:36 +0000 (16:36 +0000)]
Use larger GitHub actions workers (#661)

Larger workers will be used for non-cron triggers to improve feedback-loop time when actively working on changes to the repository

2 years agoFix tagging
David Taylor [Fri, 30 Dec 2022 20:11:52 +0000 (20:11 +0000)]
Fix tagging

2 years agoDEV: Allow booting app with slim image and make default for aarch46
David Taylor [Fri, 30 Dec 2022 12:45:32 +0000 (12:45 +0000)]
DEV: Allow booting app with slim image and make default for aarch46

2 years agoRevert "Revert last nginx bump"
Rafael dos Santos Silva [Fri, 30 Dec 2022 16:03:59 +0000 (13:03 -0300)]
Revert "Revert last nginx bump"

This reverts commit f2d598c2cd2341b1b18bf040e6349678edc55b1b.

We fixed the nginx.config in core to work with latest nginx

2 years agoRevert last nginx bump
Rafael dos Santos Silva [Wed, 28 Dec 2022 23:10:13 +0000 (20:10 -0300)]
Revert last nginx bump

Still investigating, but something between a Discourse site being
proxied as unicorn>nginx>haproxy>cloudflare broke on the new nginx.