Alliance Auth -- Docker
Prerequesites
You should have the following available on the system you are using to set this up:
- Docker - https://docs.docker.com/get-docker/
- git
- curl
Setup Guide
- run
bash <(curl -s https://gitlab.com/allianceauth/allianceauth/-/raw/master/docker/scripts/download.sh)
. This will download all the files you need to install auth and place them in a directory namedaa-docker
. Feel free to rename/move this folder. - run
./scripts/prepare-env.sh
to set up your environment - (optional) Change
PROTOCOL
tohttp://
if not using SSL in.env
- run
docker-compose --env-file=.env up -d
(NOTE: if this command hangs, follow the instructions here) - run
docker-compose exec allianceauth bash
to open up a terminal inside your auth container - run
auth migrate
- run
auth collectstatic
- run
auth createsuperuser
- visit http://yourdomain:81 to set up nginx proxy manager (NOTE: if this doesn't work, the machine likely has a firewall. You'll want to open up ports 80,443, and 81. Instructions for ufw)
- login with user
admin@example.com
and passwordchangeme
, then update your password as requested - click on "Proxy Hosts"
- click "Add Proxy Host", with the following settings for auth. The example uses
auth.localhost
for the domain, but you'll want to use whatever address you have auth configured on - click "Add Proxy Host", with the following settings for grafana. The example uses
grafana.localhost
for the domain
Congrats! You should now see auth running at http://auth.yourdomain and grafana at http://grafana.yourdomain!
SSL Guide
Unless you're running auth locally in docker for testing, you should be using SSL. Thankfully, setting up SSL in nginx Proxy Manager takes about three clicks.
- Edit your existing proxy host, and go to the SSL tab. Select "Request a new SSL Certificate" from the drop down.
- Now, enable "Force SSL" and "HTTP/2 Support". (NOTE: Do not enable HSTS unless you know what you're doing. This will force your domains to only work with SSL enabled, and is cached extremely hard in browsers. )
- (optional) select "Use a DNS Challenge". This is not a required option, but it is recommended if you use a supported DNS provider. You'll then be asked for an API key for the provider you choose. If you use Cloudflare, you'll probably have issues getting SSL certs unless you use a DNS Challenge.
- The email address here will be used to notify you if there are issues renewing your certificates.
- Repeat for any other services, like grafana.
That's it! You should now be able to access your auth install at https://auth.yourdomain
Adding extra packages
There are a handful of ways to add packages:
- Running
pip install
in the container - Modifying the container's initial command to install packages
- Building a custom Docker image (recommended, and less scary than it sounds!)
Using a custom docker image
Using a custom docker image is the preferred approach, as it gives you the stability of packages only changing when you tell them to, along with packages not having to be downloaded every time your container restarts
- Add each additional package that you want to install to a single line in
conf/requirements.txt
. It is recommended, but not required, that you include a version number as well. This will keep your packages from magically updating. You can lookup packages on https://package.wiki, and copy everything afterpip install
from the top of the page to use the most recent version. It should look something likeallianceauth-signal-pings==0.0.7
. Every entry in this file should be on a separate line - In
docker-compose.yml
, comment out theimage
line underallianceauth
(line 36... ish) and uncomment thebuild
section - Now run
docker-compose --env-file=.env up -d
, your custom container will be built, and auth will have your new packages. Make sure to follow the package's instructions on config values that go inlocal.py
NOTE: It is recommended that you put any secret values (API keys, database credentials, etc) in an environment variable instead of hardcoding them into local.py
. This gives you the ability to track your config in git without committing passwords. To do this, just add it to your .env
file, and then reference in local.py
with os.environ.get("SECRET_NAME")
Updating Auth
Base Image
Whether you're using a custom image or not, the version of auth is dictated by $AA_DOCKER_TAG in your .env
file.
- To update to a new version of auth, update the version number at the end (or replace the whole value with the tag in the release notes).
- Next, run
docker-compose pull
- Finally, run
docker-compose --env-file=.env up -d
NOTE: If you specify a version of allianceauth in your requirements.txt
in a custom image it will override the version from the base image. Not recommended unless you know what you're doing
Custom Packages
- Update the versions in your
requirements.txt
file - Run
docker-compose build
- Run
docker-compose --env-file=.env up -d
Notes
Apple M1 Support
If you want to run locally on an M1 powered Apple device, you'll need to add platform: linux/x86_64
under each container in docker-compose.yml
as the auth container is not compiled for ARM (other containers may work without this, but it's known to work if added to all containers).
Example:
redis:
platform: linux/x86_64
image: redis:6.2