forked from tyage/slack-patron
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from tsg-ut/master-v2
master-v2
- Loading branch information
Showing
23 changed files
with
350 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
ARG VARIANT=2-bullseye | ||
FROM mcr.microsoft.com/vscode/devcontainers/ruby:${VARIANT} | ||
|
||
ARG NODE_VERSION="none" | ||
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: | ||
// https://github.com/microsoft/vscode-dev-containers/tree/v0.241.1/containers/docker-existing-docker-compose | ||
// If you want to run as a non-root user in the container, see .devcontainer/docker-compose.yml. | ||
{ | ||
"name": "Existing Docker Compose (Extend)", | ||
// Update the 'dockerComposeFile' list if you have more compose files or use different names. | ||
// The .devcontainer/docker-compose.yml file contains any overrides you need/want to make. | ||
"dockerComposeFile": [ | ||
"../docker-compose.yml", | ||
"docker-compose.yml" | ||
], | ||
// The 'service' property is the name of the service for the container that VS Code should | ||
// use. Update this value and .devcontainer/docker-compose.yml to the real service name. | ||
"service": "viewer", | ||
// The optional 'workspaceFolder' property is the path VS Code should open by default when | ||
// connected. This is typically a file mount in .devcontainer/docker-compose.yml | ||
"workspaceFolder": "/workspace", | ||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [], | ||
// Uncomment the next line if you want start specific services in your Docker Compose config. | ||
"runServices": [ | ||
"viewer", | ||
"connector", | ||
"elasticsearch", | ||
"mongo" | ||
], | ||
// Uncomment the next line if you want to keep your containers running after VS Code shuts down. | ||
// "shutdownAction": "none", | ||
// Uncomment the next line to run commands after the container is created - for example installing curl. | ||
// "postCreateCommand": "apt-get update && apt-get install -y curl", | ||
// Uncomment to connect as a non-root user if you've added one. See https://aka.ms/vscode-remote/containers/non-root. | ||
// "remoteUser": "vscode" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
version: '3' | ||
services: | ||
# Update this to the name of the service you want to work with in your docker-compose.yml file | ||
viewer: | ||
# If you want add a non-root user to your Dockerfile, you can use the "remoteUser" | ||
# property in devcontainer.json to cause VS Code its sub-processes (terminals, tasks, | ||
# debugging) to execute as the user. Uncomment the next line if you want the entire | ||
# container to run as this user instead. Note that, on Linux, you may need to | ||
# ensure the UID and GID of the container user you create matches your local user. | ||
# See https://aka.ms/vscode-remote/containers/non-root for details. | ||
# | ||
# user: vscode | ||
|
||
# Uncomment if you want to override the service's Dockerfile to one in the .devcontainer | ||
# folder. Note that the path of the Dockerfile and context is relative to the *primary* | ||
# docker-compose.yml file (the first in the devcontainer.json "dockerComposeFile" | ||
# array). The sample below assumes your primary file is in the root of your project. | ||
# | ||
build: | ||
context: . | ||
dockerfile: .devcontainer/Dockerfile | ||
args: | ||
VARIANT: 2 | ||
NODE_VERSION: 16 | ||
|
||
volumes: | ||
# Update this to wherever you want VS Code to mount the folder of your project | ||
- .:/workspace:cached | ||
- /workspace/viewer/node_modules | ||
# Uncomment the next line to use Docker from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker-compose for details. | ||
# - /var/run/docker.sock:/var/run/docker.sock | ||
|
||
# Uncomment the next four lines if you will use a ptrace-based debugger like C++, Go, and Rust. | ||
# cap_add: | ||
# - SYS_PTRACE | ||
# security_opt: | ||
# - seccomp:unconfined | ||
|
||
# Overrides default command so things don't shut down after the process ends. | ||
command: /bin/sh -c "while sleep 1000; do :; done" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
viewer/public/build | ||
viewer/node_modules | ||
viewer/npm-debug.log | ||
node_modules/ | ||
npm-debug.log | ||
.git/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# For most projects, this workflow file will not need changing; you simply need | ||
# to commit it to your repository. | ||
# | ||
# You may wish to alter this file to override the set of languages analyzed, | ||
# or to provide custom queries or build logic. | ||
# | ||
# ******** NOTE ******** | ||
# We have attempted to detect the languages in your repository. Please check | ||
# the `language` matrix defined below to confirm you have the correct set of | ||
# supported CodeQL languages. | ||
# | ||
name: "CodeQL" | ||
|
||
on: | ||
push: | ||
branches: [ "master", develop ] | ||
pull_request: | ||
# The branches below must be a subset of the branches above | ||
branches: [ "master" ] | ||
schedule: | ||
- cron: '16 15 * * 4' | ||
|
||
jobs: | ||
analyze: | ||
name: Analyze | ||
runs-on: ubuntu-latest | ||
permissions: | ||
actions: read | ||
contents: read | ||
security-events: write | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
language: [ 'javascript', 'ruby' ] | ||
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] | ||
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
# Initializes the CodeQL tools for scanning. | ||
- name: Initialize CodeQL | ||
uses: github/codeql-action/init@v2 | ||
with: | ||
languages: ${{ matrix.language }} | ||
# If you wish to specify custom queries, you can do so here or in a config file. | ||
# By default, queries listed here will override any specified in a config file. | ||
# Prefix the list here with "+" to use these queries and those in the config file. | ||
|
||
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs | ||
# queries: security-extended,security-and-quality | ||
|
||
|
||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java). | ||
# If this step fails, then you should remove it and run the build manually (see below) | ||
- name: Autobuild | ||
uses: github/codeql-action/autobuild@v2 | ||
|
||
# ℹ️ Command-line programs to run using the OS shell. | ||
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun | ||
|
||
# If the Autobuild fails above, remove it and uncomment the following three lines. | ||
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. | ||
|
||
# - run: | | ||
# echo "Run, Build Application using script" | ||
# ./location_of_script_within_repo/buildscript.sh | ||
|
||
- name: Perform CodeQL Analysis | ||
uses: github/codeql-action/analyze@v2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,3 @@ | |
/vendor/bundle | ||
config.yml | ||
/tmp | ||
/logs | ||
/pids | ||
/datadir | ||
/mongo-log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,12 @@ | ||
# Slack patron | ||
# Slack Patron | ||
|
||
Log and view all Slack messages. | ||
- Record Slack messages in MongoDB. | ||
- You can also import data from backup file. | ||
- Web interface for searching messages. | ||
|
||
PR is welcome!! | ||
 | ||
|
||
 | ||
# Docs | ||
|
||
## What Slack patron do? | ||
|
||
- Log slack messages, channels, users in MongoDB. | ||
- Also, you can import all data with backup file. | ||
- View these data in web browser. | ||
|
||
 | ||
|
||
## 1. Setup | ||
|
||
This app needs access token from Slack. | ||
|
||
Get access token from [here](https://slack-patron.herokuapp.com/) (or use [test token](https://api.slack.com/docs/oauth-test-tokens)). | ||
|
||
Then, generate `config.yml` with this command: | ||
|
||
```sh | ||
$ ruby ./bin/init.rb --token=YOUR_ACCESS_TOKEN | ||
``` | ||
|
||
You can edit `config.yml` for more configuration. | ||
|
||
## 2-A. Deploy with docker | ||
|
||
To deploy with docker, just run these commands! | ||
|
||
```sh | ||
$ docker-compose up -d | ||
$ open http://localhost:9292 # open http://localhost:9292 in your browser | ||
``` | ||
|
||
## 2-B. Deploy without docker | ||
|
||
You should edit `config.yml` and specify the location of mongo. | ||
|
||
### Requirements | ||
|
||
- ruby: 2.7.2 | ||
- mongo db: v3.2.11 | ||
- node.js: v14.15.3 | ||
|
||
### 2-B-1. Setup | ||
|
||
```sh | ||
$ mongod # you need to start mongo db server | ||
$ bundle install | ||
``` | ||
|
||
### 2-B-2. Start Slack Message Logger | ||
|
||
```sh | ||
$ bundle exec ruby ./logger/logger.rb | ||
``` | ||
|
||
### 2-B-3. Start Slack Message Viewer | ||
|
||
```sh | ||
$ ./viewer/setup.sh | ||
$ bundle exec rackup ./viewer/config.ru | ||
$ open http://localhost:9292 # open http://localhost:9292 in your browser | ||
``` | ||
|
||
## 3. Import Slack backup file | ||
|
||
### 3-A. With GUI (in viewer) | ||
|
||
Import dialog will appear when you click team name in viewer. | ||
|
||
### 3-B. With Command Line | ||
|
||
The size of Slack backup file is big and sometimes it is difficult to upload it with viewer. | ||
|
||
You can import Slack backup file with this command. | ||
|
||
```sh | ||
$ bundle exec ruby ./bin/import.rb PATH_TO_BACKUP_FILE | ||
``` | ||
- [./docs/DEVELOPMENT.md](./docs/DEVELOPMENT.md): for development | ||
- [./docs/BACKUP_IMPORT.md](./docs/BACKUP_IMPORT.md): for import Slack backup file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Import Slack backup file | ||
|
||
There are two ways to import Slack's backup file. | ||
|
||
## With GUI (in viewer) | ||
|
||
Import dialog will appear when you click team name in viewer. | ||
|
||
## With Command Line | ||
|
||
Import Slack backup file with GUI might be difficult because of its file size. | ||
|
||
You can also import the file with `./bin/import.rb`. | ||
|
||
```sh | ||
$ docker compose cp PATH_TO_BACKUP_FILE logger:/tmp/slack_backup.zip | ||
$ docker compose exec logger bash -c "bundle exec ruby ./bin/import.rb /tmp/slack_backup.zip" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Manual Setup for Development | ||
|
||
## 1. Start Devcontainer | ||
|
||
You can use devcontainer for development. | ||
|
||
```sh | ||
$ export SLACK_PATRON_SLACK_TOKEN=[YOUR TOKEN HERE] | ||
$ devcontainer up --workspace-folder .devcontainer . | ||
``` | ||
|
||
## 2. Setup | ||
|
||
```sh | ||
$ docker compose exec viewer bash # operate inside viewer container | ||
$ cd workspace | ||
$ bundle install | ||
$ ./viewer/setup.sh | ||
``` | ||
|
||
## 3. Start Slack Message Logger | ||
|
||
```sh | ||
$ bundle exec ruby ./logger/logger.rb & | ||
``` | ||
|
||
## 4. Start Slack Message Viewer | ||
|
||
```sh | ||
$ bundle exec rackup ./viewer/config.ru -o 0.0.0.0 | ||
``` | ||
|
||
Visit http://localhost:9292 |
Oops, something went wrong.