Commit Graph

1589 Commits

Author SHA1 Message Date
Alan Guo Xiang Tan fa4c815dbc
FIX: Use `sharedscripts` in `/etc/logrotate.d/rails` (#819)
This commit adds `sharedscripts` which will ensure that our `postrotate`
script is only ran once even if multiple log files in the `/shared/log/rails/`
are rotated. If `sharedscripts` is not specified, we are sending `sv 1
unicorn` once per log file rotated and this has resulted in weird
behaviours like our Sidekiq process hanging indefinitely.

Note the following from the manpage for logrotate:

```
sharedscripts
Normally, prerotate and postrotate scripts are run for each log which is rotated and the absolute path to the log file is passed as first argument to the script. That means a single script may be run multiple times for log file entries which match multiple files (such as the /var/log/news/* example). If sharedscripts is specified, the scripts are only run once, no matter how many logs match the wildcarded pattern, and whole pattern is passed to them.
```
2024-07-31 12:04:14 +08:00
Juan David Martínez Cubillos f2d50d7008
DEV: Updated vanilla.template.yml (#817)
* DEV: Updated vanilla.template.yml

* updated vanilla.template.yml to make the migration process more straight forward

* removed branch pull

* implemented suggested changes

* added suggested chantes

* added before_code hook to set remote fork

* updated with suggested changes
2024-07-30 10:11:11 -05:00
Alan Guo Xiang Tan f7855481fb
DEV: Remove useless lines from `web.template.yml` (#816)
The lines are not necessary because those config has already been set in
when we are building the image.
2024-07-11 07:28:47 +08:00
Alan Guo Xiang Tan dfd3fcee0e
Bump timeout for arm64 scheduled builds to 60 mins. (#815)
We are hitting timeouts at 45mins.
2024-07-10 10:46:30 +08:00
Alan Guo Xiang Tan eded2f8b5d
Bump base image used by launcher to pull in Ruby 3.3.3 (#813) 2024-07-09 10:06:19 +08:00
Kelv 3654acb2da
DEV: update to use IM7 syntax magick in validation command (#814) 2024-07-08 17:34:01 +08:00
Rafael dos Santos Silva ffa826494b
DEV: Add poppler-utils for PDF -> text handling (#812) 2024-06-25 11:41:23 -03:00
Rafael dos Santos Silva daa3862e60
DEV: Allow ImageMagick to handle PDFs. (#811) 2024-06-24 13:24:15 -03:00
Alan Guo Xiang Tan 3bb36df2ad
DEV: Bump Ruby to 3.3.3 (#807)
Pulls in some bugfixes which may or may not be affecting us.
2024-06-14 08:19:55 +08:00
Alan Guo Xiang Tan 964236a5e8
FEATURE: Bump base image used by launcher to pull in Ruby 3.3.x take 2 (#805)
First attempt in 01ce8cf8f9 was reverted
because our new base image was not compatible with the stable branch of
discourse/discourse.
2024-06-03 10:33:29 +08:00
Alan Guo Xiang Tan f4d4f8ab6b
Bump Ruby to 3.3.2 (#806)
Pulls in lots of bug fixes: https://github.com/ruby/ruby/releases/tag/v3_3_2
2024-05-31 06:31:15 +08:00
David Taylor 7bcf0a4399
Revert "FEATURE: Bump base image used by launcher to pull in Ruby 3.3.1 (#802)" (#803)
This reverts commit 01ce8cf8f9.

We are investigating incompatibilities with Discourse stable.
2024-05-20 12:10:53 +01:00
Alan Guo Xiang Tan 01ce8cf8f9
FEATURE: Bump base image used by launcher to pull in Ruby 3.3.1 (#802) 2024-05-20 10:52:34 +08:00
Alan Guo Xiang Tan 9f47034b0b
FEATURE: Bump Ruby to 3.3.1 (#801)
Bumping Ruby to 3.3.1 to pull in latest performance and memory
improvements made to YJIT. On Discourse hosting services with Ruby 3.3.1
+ YJIT, we saw an
estimate 10-20% improvement in time spent executing Ruby code over Ruby
3.2.3 + YJIT.
2024-05-20 09:09:12 +08:00
Alan Guo Xiang Tan 3596dc1686
FEATURE: Update `discourse-setup` to prompt for MaxMind account ID (#796)
In order to download the free MaxMind GeoLite2 databases, an account ID
and license key is required going forward. This commit updates
`discourse-setup` to start prompting the user to provide the MaxMind
Account ID first before asking for the MaxMind license key. If the user
does not provide the Account ID, the script will not prompt for the
license key as we assume the user has opted out.

We are aware that we don't have a reliable way to test for changes to
the `discourse-setup` script but it is what it is at this point in time.
We intend to invest resources in improving things in the future but now
is not the time.
2024-05-09 15:40:01 +08:00
Jay Pfaffman f98af894ec
Update discourse-setup (#799)
DEV: `./launcher stop` needs to be skipped when in debug mode
2024-05-09 15:19:54 +08:00
Alan Guo Xiang Tan 6c890061e7
DEV: Build/release `discourse/base:release-ruby-3.3.1` for testing (#800)
This commit adds a `ruby_3_3` job to our Github workflow which releases
a `discourse/base:release-ruby-3.3.1` Docker image to allow us to test
Ruby 3.3.1 before eventually changing to that version as the default.
2024-05-07 13:29:45 +08:00
耗子 c99f0c3e32
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.
2024-05-06 13:47:35 +08:00
Alan Guo Xiang Tan 6c42a465c9
DEV: Bump default base image for launcher to `discourse/base:2.0.20240502-0021` (#795)
This is necessary to pull in 303b646c3c
2024-05-02 09:46:00 +08:00
Alan Guo Xiang Tan 303b646c3c
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
2024-04-30 08:30:31 +08:00
Jeff Wong 9815b99f6c
DEV: update postgres 15 template for tags (#790) 2024-04-11 11:52:00 -07:00
Jeff Wong 26ae3e7143
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.
2024-04-10 16:29:57 -07:00
SnR 869cdb3672
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.
2024-04-04 10:23:47 +08:00
Alan Guo Xiang Tan ac585c7b7f
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.
2024-03-28 06:40:38 +08:00
Alan Guo Xiang Tan fcc6326c22
Revert "Upgrade Debian to Bookworm" (#788)
This reverts commit 23e7b55d42.

The CI build on `discourse/discourse` and our internal CI is broken
because of this.
2024-03-27 06:32:09 +08:00
Loïc Guitaut 23e7b55d42 Upgrade Debian to Bookworm 2024-03-26 16:43:03 +01:00
Loïc Guitaut 2f14e3d5e3 DEV: Add a default browser for testem in discourse_test
Related to https://github.com/discourse/discourse/pull/26244
2024-03-25 18:04:36 +01:00
Loïc Guitaut 961a4a13ca 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.
2024-03-25 11:20:56 +01:00
Alan Guo Xiang Tan 5bbffa83bd
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
2024-03-22 20:41:24 +08:00
Alan Guo Xiang Tan 68d150d372
Revert "Use Chromium instead of Chrome (#782)" (#783)
This reverts commit e6ffa64d9d.

We need to fix the various Chrome assumptions in Discourse core.
2024-03-21 07:46:57 +08:00
Steffy Fort 23e03a1ee1
Fix: Remove egrep for grep -E (#680)
Co-authored-by: Steffy Fort <steffy.fort@cozycloud.cc>
2024-03-21 05:54:55 +08:00
Loïc Guitaut e6ffa64d9d
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.
2024-03-21 05:48:52 +08:00
Alan Guo Xiang Tan 4bece5f47e
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.
2024-03-20 06:26:36 +08:00
Alan Guo Xiang Tan bbefa1e5f3
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.
2024-03-19 10:29:56 +08:00
Rafael dos Santos Silva 957aed8cdd
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.
2024-03-04 12:42:49 -03:00
Rafael dos Santos Silva 6765ecc554
FIX: Config page size for Redis Jemalloc on ARM64 (#776) 2024-03-01 17:14:57 -03:00
Rafael dos Santos Silva 62bdb930d9
FIX: Move arm to newer jemalloc (#775) 2024-03-01 14:34:46 -03:00
Andrew Schleifer 64ae2b03b2 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.
2024-03-01 10:18:53 +08:00
Rafael dos Santos Silva 4d0e712b9e
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.
2024-02-29 14:13:54 -03:00
Evgeni Golov 352d9dbe98 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 deae52039f/README.md
2024-02-29 22:14:35 +08:00
Mwaniki Wairungu 0f4e63540d 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.
2024-02-29 22:09:16 +08:00
Alan Guo Xiang Tan 7cc301e9a9
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
```
2024-02-06 16:38:04 +08:00
Alan Guo Xiang Tan a03cdcb257
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
```
2024-02-06 07:43:15 +08:00
Loïc Guitaut 1964d1737a 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.
2024-01-30 10:23:57 +01:00
Chris Rendle-Short fcce137604 Bump default base image to discourse/base:2.0.20231218-0429 2023-12-19 11:24:35 +11:00
Chris Rendle-Short 529267f1ec
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
2023-12-18 15:18:44 +11:00
Andrew Schleifer d0d787a14c Bump default base image to discourse/base:2.0.20231214-0023 2023-12-17 17:50:34 +08:00
Jeff Wong dfcbcf9ac5
DEV: add plugin_compatibility hook (#760) 2023-12-06 13:08:48 -08:00
Michael Brown 1f33e0ad55
FIX: Y/n prompt should treat "no value" as yes 2023-12-01 18:25:13 -05:00
Alan Guo Xiang Tan e06026b97c
FIX: Install plugin gems in `discourse/discourse_test` image (#758)
Why this change?

In
dec68d780c,
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.
2023-11-23 18:12:37 +08:00