This is provided as an example, on the off-chance it might be useful to someone, and it does not claim to be authoratative. No warranty is implied or given. Use at your own risk. This may not be the best way to do this, and it may have unforseen failings.
requirements: podman, git
The use case here is to install an opinionated production ready misago in a podman pod, with an external postgresql database (ie in another pod, or externally provisioned - one can also add a postgresql container to this pod), and behind a reverse-proxy that handles certificates and access authentication. In my case this is caddy2, but it should work with the usual suspects. Backup, in my case, is handled by the excellent borgmatic which dumps the database and de-duplicate and backups that and the static files. So you should note that this guide does not address backup.
Building
Move to your build host and git clone the latest misago-docker
git clone https://github.com/rafalp/misago_docker.git --depth=1
then cd into the misago
directory within the cloned repository, and build the misago container
podman build -t localhost/misago:0.29 -f Dockerfile
This example is for the current (at the time of writing) version 0.29. Amend this tag on the container to reflect the version actually built.
Backup the image
This can be useful in the case that you are building the image to use it on a different machine (without pushing it to a repository), or to include in your backup sets to rebuild your stack.
podman save -m -o misago.0.29.tar \
localhost/misago:0.29
to load this image on another machine, or to restore it as part of a backup restore.
podman load -i misago.0.29.tar
Define the image to use
Tag this image as the latest image. This will allow us the facility to build future versions and tag as latest the image that we wish our deployment to use, as well as the option for automatic updates controlled by podman.
podman image tag localhost/misago:0.29 localhost/misago:latest
Preparing the installation
Choose the preferred location for your containers persistent files. I tend to use /var/lib/misago
for systems level installations, but you don't have to. You may prefer something in the user home directory if you are running the containers rootless (you are on your own there, I'm keeping this simple by way of example). Let's call this location [app]
create directory structure
This is the file structure your containers will need to persist values.
mkdir -p [app]/{logs,misago,nginx,redis}
mkdir -p [app]/nginx/vhost.d
mkdir -p [app]/logs/{nginx,misago,celery}
mkdir -p [app]/misago/{avatargallery,media,static,theme,userdata}
mkdir -p [app]/misago/theme/{static,template}
Add the nginx configuration
Into the [app]/nginx directory put the custom nginx.conf
to serve misago to the reverse proxy of your choice. In the server block, this needs to reflect the pod name that you create for the install. In this case myinstance
(see server_name myinstance; # substitute your machine's IP address or FQDN
). Note that the location alias of /media and /static refers to within the container, and does not require changing.
# nginx.conf
events {}
http {
include /etc/nginx/mime.types;
upstream misago {
# server unix:///path/to/your/mysite/mysite.sock; # for a file socket
server 127.0.0.1:3031; # for a web port socket (we'll use this first)
}
server {
# the port your site will be served on
listen 80;
# the domain name it will serve for
server_name myinstance; # substitute your machine's IP address or FQDN
charset utf-8;
# max upload size
client_max_body_size 75M; # adjust to taste
# Django media
location /media {
alias /misago/media; # your Django project's media files - amend as required
uwsgi_param Host $host;
uwsgi_param X-Real-IP $remote_addr;
uwsgi_param X-Forwarded-For $proxy_add_x_forwarded_for;
uwsgi_param X-Forwarded-Proto $http_x_forwarded_proto;
}
location /static {
alias /misago/static; # your Django project's static files - amend as required
uwsgi_param Host $host;
uwsgi_param X-Real-IP $remote_addr;
uwsgi_param X-Forwarded-For $proxy_add_x_forwarded_for;
uwsgi_param X-Forwarded-Proto $http_x_forwarded_proto;
}
# Finally, send all non-media requests to the Django server.
location / {
uwsgi_pass misago;
include /etc/nginx/uwsgi_params; # the uwsgi_params file you installed
uwsgi_param Host $host;
uwsgi_param X-Real-IP $remote_addr;
uwsgi_param X-Forwarded-For $proxy_add_x_forwarded_for;
uwsgi_param X-Forwarded-Proto $http_x_forwarded_proto;
}
}
}
create [your.domain.com]_location in the nginx/vhost.d directrory
# your.domain.com_location
# Additional Nginx configuration for Misago vhost
# Set max upload size at 16 megabytes
client_max_body_size 16M;
# Enable GZIP
gzip on;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_min_length 1100;
gzip_buffers 4 8k;
gzip_proxied any;
gzip_types
# text/html is always compressed by HttpGzipModule
text/css
text/javascript
text/xml
text/plain
text/x-component
application/javascript
application/json
application/xml
application/rss+xml
font/truetype
font/opentype
application/vnd.ms-fontobject
image/svg+xml;
location /static/ {
root /misago;
expires max;
# Enable GZIP
gzip on;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_min_length 1100;
gzip_buffers 4 8k;
gzip_types
# text/html is always compressed by HttpGzipModule
text/css
text/javascript
text/xml
text/plain
text/x-component
application/javascript
application/json
application/xml
application/rss+xml
font/truetype
font/opentype
application/vnd.ms-fontobject
image/svg+xml;
}
location /media/ {
root /misago;
expires max;
# Enable GZIP
gzip on;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_min_length 1100;
gzip_buffers 4 8k;
gzip_types
# text/html is always compressed by HttpGzipModule
text/css
text/javascript
text/xml
text/plain
text/x-component
application/javascript
application/json
application/xml
application/rss+xml
font/truetype
font/opentype
application/vnd.ms-fontobject
image/svg+xml;