AutoMuteUs を docker でセルフホストする方法を超短的に説明

Dockerfile を下記内容で用意

FROM golang:1.15-alpine AS builder

# Git is required for getting the dependencies.
# hadolint ignore=DL3018
RUN apk add --no-cache git

WORKDIR /src

# Fetch dependencies first; they are less susceptible to change on every build
# and will therefore be cached for speeding up the next build
COPY ./go.mod ./go.sum ./
RUN go mod download

# Import the code from the context.
COPY ./ ./

# Build the executable to `/app`. Mark the build as statically linked.
# hadolint ignore=SC2155
RUN export TAG=$(git describe --tags "$(git rev-list --tags --max-count=1)") && \
    export COMMIT=$(git rev-parse --short HEAD) && \
    CGO_ENABLED=0 \
    go build -installsuffix 'static' \
    -ldflags="-X main.version=${TAG} -X main.commit=${COMMIT}" \
    -o /app .

FROM alpine:3.12.2 AS final

# Set up non-root user and app directory
# * Non-root because of the principle of least privlege
# * App directory to allow mounting volumes
RUN addgroup -g 1000 bot && \
    adduser -HD -u 1000 -G bot bot && \
    mkdir -p /app/logs /app/locales /app/storage && \
    chown -R bot:bot /app
USER bot
WORKDIR /app

# Import the compiled executable and locales.
COPY --from=builder /app /app
COPY ./locales/ /app/locales
COPY ./storage/postgres.sql /app/storage/postgres.sql

# Port used for health/liveliness checks
EXPOSE 8080
# Port used for prometheus metrics
EXPOSE 2112

ENV LOCALE_PATH="/app/locales" \
    LOG_PATH="/app/logs"
VOLUME ["/app/logs"]

# Run the compiled binary.
ENTRYPOINT ["./app"]

設定類を .env ファイルで用意

# Please refer to the latest versions of Galactus and AutoMuteUs when specifying these versions:
# Automuteus: https://github.com/denverquane/automuteus/releases
# or https://hub.docker.com/repository/docker/denverquane/amongusdiscord/tags?page=1&ordering=last_updated

# Galactus: https://github.com/automuteus/galactus/releases
# or https://hub.docker.com/repository/docker/automuteus/galactus/tags?page=1&ordering=last_updated

AUTOMUTEUS_TAG=6.5.5
GALACTUS_TAG=2.4.1

# change these, but see comment below about HOST/PORT
DISCORD_BOT_TOKEN=[DISCORD_BOT_TOKEN]
GALACTUS_HOST=http://localhost:8123
GALACTUS_EXTERNAL_PORT=

# recommend changing these to something more secure
POSTGRES_USER=postgres
POSTGRES_PASS=putsomesecretpasswordhere

# GALACTUS_HOST can include the port or not. If you don't include the port,
# it will default to :80/:443 depending on http:// v https://
# **Make sure that GALACTUS_EXTERNAL_PORT matches the Port for the above host, UNLESS you use a reverse proxy/nginx!!!**
# Ex: if GALACTUS_HOST=http://localhost, then GALACTUS_EXTERNAL_PORT should be 80 (HTTP)
# Ex: if GALACTUS_HOST=https://localhost, then GALACTUS_EXTERNAL_PORT should be 443 (HTTPS)
# Ex: if GALACTUS_HOST=http://localhost:8123, then GALACTUS_EXTERNAL_PORT should be 8123
# If you use a reverse proxy, then GALACTUS_HOST should have the port of your reverse proxy, and it should proxy to the
# GALACTUS_EXTERNAL_PORT (ex 443 -> 8123)

# Optional, leave alone by default
EMOJI_GUILD_ID=
# comma-separated
WORKER_BOT_TOKENS=
CAPTURE_TIMEOUT=
AUTOMUTEUS_LISTENING=

# DO NOT change these unless you really know what you're doing
BROKER_PORT=8123
GALACTUS_PORT=5858
GALACTUS_REDIS_ADDR=redis:6379
AUTOMUTEUS_REDIS_ADDR=redis:6379
GALACTUS_ADDR=http://galactus:5858
POSTGRES_ADDR=postgres:5432

[DISCORD_BOT_TOKEN] には DISCORDのボットのトークンを記載、
postgresql のパスワードは必要に応じて変更。
あとは、ボットへの権限付与を忘れずに。

docker-compose up で起動。docker-compose down で終了。