Move from standalone container to separate web and data containers

Excellent. Nope that will be perfect. Thanks again! Very much appreciated.

1 Like

The command is now ./discourse-setup --two-container

worked as expected just now :smiling_face_with_three_hearts:

2 Likes

Good catch! Did it print a message that made it easy to figure that out?

I’ve been meaning to clean up this topic since they change.

1 Like

Yes, very helpful thanks.

2 Likes

Are there any plans to migrate from the old “container links” thing to proper setup with a custom network with two containers being connected to it?
“Links” are legacy and may be removed in the future according to Docker docs

1 Like

That sounds like a good idea.

Unless someone beats me to it, I’ll see about subunits /creating a PR to switch to networks and /or sockets (which some prefer anyway) and creating a howto to convert an existing setup to the new configuration.

5 Likes

@pfaffman I don’t know whether you got around to it, but if you did, want to link to it here? :relaxed:

3 Likes

Should we add a && ./launcher cleanup to the end of these commands?

I’ve found after switching to a two container install that it doesn’t take long to fill up the available storage with old images.

1 Like

I definitely recommend that in my guide… A lot of folks deploy on smallish systems like DO droplets and I know I’ve helped others who didn’t quite realize where their space was going.

2 Likes

@pfaffman, Hi,
A few days ago I installed AWS EC2 with a single container and everything worked fine. But I need exactly the two container configuration, web_only on EC2 and data on AWS RDS (PostgreSQL 15.3 on port 5432 => I can’t choose another version, and the database has no DB_NAME parameter). As a Redis cluster I tried using AWS ElastiCache, but then left a link in the data.yml to the existing template:

  #- "templates/postgres.template.yml"
  - "templates/redis.template.yml"

After successfully bootstrapping data and web_only I can’t open the webpage. “This site can’t be reached”

I haven’t made any changes to DNS records or changed the access settings in AWS security groups (firewall for web and database).

Successfully bootstrapped, to startup use ./launcher start data
root@ip-172-31-3-68:/var/discourse# ./launcher start data
x86_64 arch detected.

+ /usr/bin/docker run --shm-size=512m -d --restart=always -e LANG=en_US.UTF-8 -e LC_ALL=en_US.UTF-8 -e LANGUAGE=en_US.UTF-8 -h ip-172-31-3-68-data -e DOCKER_HOST_IP=172.17.0.1 --name data -t -v /var/discourse/shared/data:/shared -v /var/discourse/shared/data/log/var-log:/var/log --mac-address <...> local_discourse/data /sbin/boot
27b66e577d250e4178f5e145c9962be7b5f2d905cfacd233d3d2278e7b83aa93
Successfully bootstrapped, to startup use ./launcher start web_only
root@ip-172-31-3-68:/var/discourse# ./launcher start web_only
x86_64 arch detected.

+ /usr/bin/docker run --shm-size=512m --link data:data -d --restart=always -e LANG=en_US.UTF-8 -e RAILS_ENV=production -e UNICORN_WORKERS=2 -e UNICORN_SIDEKIQS=1 -e RUBY_GC_HEAP_GROWTH_MAX_SLOTS=40000 -e RUBY_GC_HEAP_INIT_SLOTS=400000 -e RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR=1.5 -e DISCOURSE_DB_SOCKET= -e DISCOURSE_DB_HOST=database-discourse.<..>.rds.amazonaws.com -e DISCOURSE_DB_PORT= -e LETSENCRYPT_DIR=/shared/letsencrypt -e DISCOURSE_FORCE_HTTPS=true -e LC_ALL=en_US.UTF-8 -e LANGUAGE=en_US.UTF-8 -e DISCOURSE_HOSTNAME=talk.furtherium.com -e DISCOURSE_DEVELOPER_EMAILS=hello@furtherium.com -e DISCOURSE_SMTP_ADDRESS=email-smtp.us-east-2.amazonaws.com -e DISCOURSE_SMTP_PORT=587 -e DISCOURSE_SMTP_USER_NAME=A<...>S -e DISCOURSE_SMTP_PASSWORD=B<...>M -e DISCOURSE_NOTIFICATION_EMAIL=noreply@talk.furtherium.com -e LETSENCRYPT_ACCOUNT_EMAIL=me@example.com -e DISCOURSE_DB_NAME= -e DISCOURSE_DB_USERNAME=postgres -e DISCOURSE_DB_PASSWORD=7<...>1 -e DISCOURSE_REDIS_HOST=data -h ip-172-31-3-68-web-only -e DOCKER_HOST_IP=172.17.0.1 --name web_only -t -p 80:80 -p 443:443 -v /var/discourse/shared/web-only:/shared -v /var/discourse/shared/web-only/log/var-log:/var/log --mac-address <...> local_discourse/web_only /sbin/boot
1233f1c660eb7cecc48d2a840aae037b46ecfd7afe029ef89b2e686b136b9886
  • I checked the connection to the database from SSH using telnet - OK
  • I can see the database connections in the AWS RDS dashboard
  • I have rebooted instances 3 times
  • I have run rebuild 3-4 times without errors
  • I checked the list of active containers and images, cleaned up unnecessary ones
CONTAINER ID   IMAGE                      COMMAND        CREATED          STATUS          PORTS                                                                      NAMES
1233f1c660eb   local_discourse/web_only   "/sbin/boot"   18 minutes ago   Up 18 minutes   0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp   web_only
27b66e577d25   local_discourse/data       "/sbin/boot"   47 minutes ago   Up 47 minutes                                                                              data

What else can I do? Thank you for your efforts and time!

You do not. You only need the web container and to delete the Postgres and Redis templates. Elasticache is, in my opinion, absurdly expensive, so you could run it on your EC2 if you’re using a single host.

Just add the ENV variables to your existing app.yml and delete the unnecessary templates. I heard recently that this site is running on PG15, so that should be fine.

Thanks for the reply, Jay (@pfaffman). I just want to clarify:

  • should I use the single container app.yml installation and comment in the lines about database and redis? and also in the ENV field of app.yml then add lines for the remote database in AWS (DB_USER, etc. - from web_only as now)?
  • or do I leave it as is, but stop the data container and leave only web-only?
  • If I don’t use ElastiCache, then I need to leave the “templates/redis.template.yml” line?