Skip to content
Extraits de code Groupes Projets
Valider 429c7186 rédigé par Travis Ralston's avatar Travis Ralston
Parcourir les fichiers

Add a Dockerfile and supporting configuration

Things need to be stored in a volume, so we also add a bunch of configuration options for moving the persistence around.
parent a115e329
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
.git
node_modules
# This is just stuff we don't need
.travis.yml
.gitignore
build
*.db
discord-registration.yaml
*.png
README.md
test
docs
config.yaml
tools
FROM node:alpine
COPY . /tmp/src
RUN apk add --no-cache -t build-deps make gcc g++ python ca-certificates libc-dev wget \
&& cd /tmp/src \
&& npm install \
&& npm run build \
&& mv build / \
&& mv config / \
&& mv node_modules / \
&& cd / \
&& rm -rf /tmp/* \
&& apk del build-deps
ENV NODE_ENV=production
CMD node /build/discordas.js -p 9005 -c /data/config.yaml -f /data/discord-registration.yaml
EXPOSE 9005
VOLUME ["/data"]
......@@ -47,6 +47,32 @@ Please also be aware that this is an unoffical project worked on in my (Half-Sho
* Copy ``discord-registration.yaml`` to your Synapse's directory.
#### Docker
Following the instructions above, generate a registration file. The file may also be hand-crafted if you're familiar with the layout. You'll need this file to use the Docker image.
```
# Create the volume where we'll keep the bridge's files
mkdir -p /matrix-appservice-discord
# Create the configuration file. Use the sample configuration file as a template.
# Be sure to set the database paths to something like this:
# database:
# filename: "/data/discord.db"
# userStorePath: "/data/user-store.db"
# roomStorePath: "/data/room-store.db"
nano /matrix-appservice-discord/config.yaml
# Copy the registration file to the volume
cp discord-registration.yaml /matrix-appservice-discord/discord-registration.yaml
# Optional: Build the container yourself (requires a git clone, and to be in the root of the project)
docker build -t half-shot/matrix-appservice-discord .
# Run the container
docker run -v /matrix-appservice-discord:/data -p 9005:9005 half-shot/matrix-appservice-discord
```
#### 3PID Protocol Support
This bridge support searching for rooms within networks via the 3pid system
......
......@@ -15,5 +15,7 @@ logging:
level: "warn" #silly, verbose, info, http, warn, error
database:
filename: "discord.db"
userStorePath: "user-store.db"
roomStorePath: "room-store.db"
room:
defaultVisibility: "public"
......@@ -44,6 +44,10 @@ properties:
properties:
filename:
type: "string"
userStorePath:
type: "string"
roomStorePath:
type: "string"
room:
type: "object"
required: ["defaultVisibility"]
......
......@@ -23,6 +23,8 @@ class DiscordBridgeConfigBridge {
class DiscordBridgeConfigDatabase {
public filename: string;
public userStorePath: string;
public roomStorePath: string;
}
export class DiscordBridgeConfigAuth {
......
......@@ -38,7 +38,7 @@ function generateRegistration(reg, callback) {
function run (port: number, config: DiscordBridgeConfig) {
log.level = config.logging ? (config.logging.level || "warn") : "warn";
log.info("discordas", "Starting Discord AS");
const yamlConfig = yaml.safeLoad(fs.readFileSync("discord-registration.yaml", "utf8"));
const yamlConfig = yaml.safeLoad(fs.readFileSync(cli.opts.registrationPath, "utf8"));
const registration = AppServiceRegistration.fromObject(yamlConfig);
if (registration === null) {
throw new Error("Failed to parse registration file");
......@@ -69,6 +69,8 @@ function run (port: number, config: DiscordBridgeConfig) {
domain: config.bridge.domain,
homeserverUrl: config.bridge.homeserverUrl,
registration,
userStore: config.database.userStorePath,
roomStore: config.database.roomStorePath,
});
provisioner.SetBridge(bridge);
roomhandler.setBridge(bridge);
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter