Commit graph

1604 commits

Author SHA1 Message Date
David Taylor
98c5337c12
Warmup yarn and bundle caches in dev image ()
Uses a multi-stage build with bind mount to avoid adding the discourse repo itself to the layers
2024-08-20 14:51:32 +01:00
David Taylor
7b0e4b45b5
dev: add user-installed gems to PATH ()
This is important for usability of things like discourse_theme, and editor tooling (e.g. ruby-lsp)
2024-08-20 14:51:14 +01:00
David Taylor
8aff5b6588
Use flaky-test-retry system ()
We use this on the main core repository, so it makes sense to use it here as well. It should reduce the overall flakiness of the discourse_docker build.
2024-08-20 13:44:25 +01:00
David Taylor
f1c9d8afb2
DEV: Simplify discourse_dev postgres setup ()
- Remove manual database creation, and instead promote discourse user to postgres SUPERUSER. This means that `db:drop` and `db:create` commands can be run in the dev image, just like in other local development environments. As well as simplifying things, it fixes turbo_rspec, which was previously impossible in the docker dev environment (because `discourse` didn't have permissions to create the parallel databases)

- Stop pre-migrating test database in dev image. It adds additional build time & image size, and doesn't actually help because core's `bin/docker/boot_dev` script overwrites the container's postgres directory with a volume mount
2024-08-19 16:44:23 +01:00
Alan Guo Xiang Tan
6f8c17dbf4
Upgrade nginx to 1.26.1 since it is the new stable version ()
Since 1.26.x has been marked stable, 1.25.x is automatically EOL as
nginx only maintains one mainline version and one stable version.
2024-08-19 09:19:54 +08:00
Pablo Ganuza Vidal
f953eb623a
Fix verification of ports ()
nc needs -p to publish verification code correctly, at least in Debian 12
2024-08-19 08:39:29 +10:00
Derek J. Lambert
fc9fbedfac
FIX: Broken config and variable handling in setup script ()
* FIX: Variable isn't being set

* DEV: Goodbye tabs, they're probably feeling lonely anyway

* FIX: Variable is never used. No need for command substitution

* FIX: The likelihood of knowing the PID for the script before execution is exceptionally low
2024-08-19 08:35:56 +10:00
Jay Pfaffman
b7a6888a2b
bash tab completion for launcher + discourse-setup ()
add tab completion for launcher and discourse-setup.

For launcher, offers command (e.g., rebuild, start) and then offers yml files from containers directory. After that switches (e.g., --run-image) are offered. (Will not offer switches except in final position, sorry.)

discourse-setup offers switches (e.g., --two-container).

discourse-docter has no command line arguments.
2024-08-19 08:31:55 +10:00
Jeff Wong
9f80d83b32
DEV: allow multiple configure runs ()
when we have already run an initial setup, fall back to just checking for
socket, rather than outright failing if the init script has already been run.

This allows 'configure' steps to be re-run in standalone cases.

eg: `launcher2 configure app && launcher2 configure app`

current version: fails as it's missing the install_postgres file
with PR: checks for psql socket, and builds.

doing something like `launcher2 start app && launcher2 configure app` would also
print out a more correct error message, "postgres already running stop container"
2024-08-12 07:43:26 -07:00
Rafael dos Santos Silva
618ab51850
Update pgvector to 0.7 ()
* Update pgvector to 0.7

* escape

* drop version
2024-08-09 11:16:38 -03:00
Alan Guo Xiang Tan
494e353c2d
Revert "Switch to Chrome for Testing and drop support for Chromium ()" ()
This reverts commit bdfcc8ad23.

Broke the test build
2024-08-09 11:05:25 +08:00
Alan Guo Xiang Tan
bdfcc8ad23
Switch to Chrome for Testing and drop support for Chromium ()
We started installing Chromium because there is no linux ARM support
for Chrome yet. However, trying to run tests on Chromium seems to be
extra challenging. For example, upgrading to Debian 12 causes our
Javascript tests to fail on Chromium but not on Chrome.

Chrome for Testing was built specifically for web app testing so let's
follow Google's recommendation.
2024-08-09 09:55:50 +08:00
Alan Guo Xiang Tan
21a0351e30
Build discourse/base and discourse/discourse_test image for bookworm ()
We need to upgrade to bookworm because bullseye is EOL. This commit when merged into branch will push the following images to Docker hub:

1. `discourse/base:slim-bookworm`
2. `discourse/base:release-bookworm`
3. `discourse/discourse_test:slim-bookworm`
4. `discourse/discourse_test:slim-browsers-bookworm`
5. `discourse/discourse_test:release-bookworm`
2024-08-08 16:29:53 +08:00
Alan Guo Xiang Tan
9e253b704c
FIX: Remove bundle config jobs ()
This fixes a regression introduced in
bbefa1e5f3. Basically, we cannot configure
the default bundle jobs when building the image because the number of
cores used to build the image can be different from the number of cores
on the machine running the image.
2024-08-08 11:23:54 +08:00
David Taylor
6f7f62ceca
Increase yarn network-timeout from 30s to 60s ()
A number of people have reported hitting yarn timeouts on low-spec DO droplets, which causes the build to fail. This should provide a little more leeway
2024-08-07 14:13:50 +01:00
Alan Guo Xiang Tan
fa4c815dbc
FIX: Use sharedscripts in /etc/logrotate.d/rails ()
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 ()
* 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 ()
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. ()
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 () 2024-07-09 10:06:19 +08:00
Kelv
3654acb2da
DEV: update to use IM7 syntax magick in validation command () 2024-07-08 17:34:01 +08:00
Rafael dos Santos Silva
ffa826494b
DEV: Add poppler-utils for PDF -> text handling () 2024-06-25 11:41:23 -03:00
Rafael dos Santos Silva
daa3862e60
DEV: Allow ImageMagick to handle PDFs. () 2024-06-24 13:24:15 -03:00
Alan Guo Xiang Tan
3bb36df2ad
DEV: Bump Ruby to 3.3.3 ()
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 ()
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 ()
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 ()" ()
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 () 2024-05-20 10:52:34 +08:00
Alan Guo Xiang Tan
9f47034b0b
FEATURE: Bump Ruby to 3.3.1 ()
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 ()
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 ()
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 ()
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 ()
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 ()
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 ()
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 () 2024-04-11 11:52:00 -07:00
Jeff Wong
26ae3e7143
Add tags to pups templates ()
* 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. ()
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 ()
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" ()
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 ()
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 ()" ()
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 ()
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 ()
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 ()
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 ()
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 ()
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