Skip to content

Commit 087367d

Browse files
committed
Add script to build a discourse image
1 parent 62fb034 commit 087367d

File tree

6 files changed

+88
-24
lines changed

6 files changed

+88
-24
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
temp
1+
.temp

Dockerfile

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,21 @@
1-
ARG DISCOURSE_VERSION="2.0.20251003-1437"
2-
FROM discourse/base:${DISCOURSE_VERSION}
1+
# All of this dockerfile is extracted from `./launcher start-cmd`
2+
# DISCOURSE_IMAGE needs to be made with `./launcher bootstrap`
3+
ARG DISCOURSE_IMAGE=local_discourse/default
4+
FROM ${DISCOURSE_IMAGE}
5+
6+
ENV RAILS_ENV=production
7+
ENV UNICORN_WORKERS=3
8+
ENV UNICORN_SIDEKIQS=1
9+
ENV RUBY_GC_HEAP_GROWTH_MAX_SLOTS=40000
10+
ENV RUBY_GC_HEAP_INIT_SLOTS=400000
11+
ENV RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR=1.5
12+
13+
ENV LC_ALL=en_US.UTF-8
14+
ENV LANGUAGE=en_US.UTF-8
15+
ENV LANG=en_US.UTF-8
16+
17+
VOLUME /shared
18+
19+
EXPOSE 80
20+
21+
CMD /sbin/boot

README.md

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,40 @@
11
# discourse-docker
22
Pretendo instance of discourse-docker, to make it a little more friendly to deploy as a container
33

4-
Todo: figure out how to run this. No idea whats going on
5-
6-
Maybe we should just use the launcher completely:
7-
- Make a web-only config file: `web-only.yml`
8-
- `launcher bootstrap web-only --skip-prereqs` -> build an image
9-
- `launcher start-cmd web-only --skip-prereqs` -> get start cmd
10-
- extract image name from start-cmd
11-
- `docker push IMAGE_NAME`
4+
It includes all the plugins that Pretendo runs.
5+
6+
## How to build an image
7+
Simply run `build.sh`, then build a container with `docker build -t hello-world .`
8+
9+
You need the following to properly host discourse:
10+
- Postgresql
11+
- Redis
12+
- A transactional SMTP server
13+
14+
The environment variables you'll need at runtime (inspired by samples/web_only.yml):
15+
```sh
16+
# General env
17+
DISCOURSE_HOSTNAME=forum.example.com
18+
19+
# Email
20+
DISCOURSE_SMTP_ADDRESS=
21+
DISCOURSE_SMTP_PORT=
22+
DISCOURSE_SMTP_USER_NAME=
23+
DISCOURSE_SMTP_PASSWORD=
24+
DISCOURSE_SMTP_ENABLE_START_TLS=
25+
DISCOURSE_SMTP_DOMAIN=
26+
DISCOURSE_NOTIFICATION_EMAIL=
27+
28+
# Postgres
29+
DISCOURSE_DB_SOCKET=
30+
DISCOURSE_DB_USERNAME=
31+
DISCOURSE_DB_PASSWORD=
32+
DISCOURSE_DB_HOST=
33+
34+
# Redis
35+
DISCOURSE_REDIS_HOST=
36+
```
37+
38+
More details about hosting it:
39+
- You need to mount `/shared` at a persistent location
40+
- Port `80` is exposed in the container

assets/default.container.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Basics for web_only
2+
templates:
3+
- "templates/web.template.yml"
4+
- "templates/web.ratelimited.template.yml"
5+
6+
# Plugins
7+
hooks:
8+
after_code:
9+
- exec:
10+
cd: $home/plugins
11+
cmd:
12+
- git clone https://github.com/discourse/docker_manager.git

build.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
# Download deps
4+
rm -rf .temp
5+
mkdir .temp
6+
git clone https://github.com/discourse/discourse_docker .temp/repo
7+
8+
# Configure launcher
9+
cp assets/default.container.yml .temp/repo/containers/default.yml
10+
11+
# Patch default templates to disable database migration on compile
12+
sed -i 's/echo $pups_command/pups_command="$pups_command --skip-tags migrate,precompile"; echo $pups_command/g' .temp/repo/launcher
13+
14+
# Bootstrap container
15+
cd .temp/repo
16+
./launcher bootstrap default --skip-prereqs
17+
echo "Built container 'local_discourse/default'"

retrieve-version.sh

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)