Skip to content
This repository was archived by the owner on Apr 10, 2022. It is now read-only.

Commit 58ba773

Browse files
committed
initial commit
0 parents  commit 58ba773

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+15000
-0
lines changed

Diff for: .github/workflows/cd-ci.yml

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: CD-CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- dev
8+
paths-ignore:
9+
- '*.md'
10+
11+
pull_request:
12+
branches:
13+
- master
14+
- dev
15+
types:
16+
- opened
17+
- synchronize
18+
paths-ignore:
19+
- '*.md'
20+
env:
21+
PYTHON_WORKING_DIR: python
22+
FRONTEND_WORKING_DIR: next
23+
24+
jobs:
25+
26+
lint-backend:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v2
31+
32+
- name: Setup Node.js
33+
uses: actions/setup-node@v2
34+
35+
- name: Install Dependencies
36+
run: yarn install --frozen-lockfile
37+
working-directory: ${{env.BACKEND_WORKING_DIR}}
38+
39+
- name: Lint ESLint
40+
run: yarn lint:eslint
41+
working-directory: ${{env.BACKEND_WORKING_DIR}}
42+
43+
- name: Lint Prettier
44+
run: yarn lint:prettier
45+
working-directory: ${{env.BACKEND_WORKING_DIR}}
46+
47+
lint-frontend:
48+
runs-on: ubuntu-latest
49+
steps:
50+
- name: Checkout
51+
uses: actions/checkout@v2
52+
53+
- name: Setup Node.js
54+
uses: actions/setup-node@v2
55+
56+
- name: Install Dependencies
57+
run: yarn install --frozen-lockfile
58+
working-directory: ${{env.FRONTEND_WORKING_DIR}}
59+
60+
- name: Lint ESLint
61+
run: yarn lint:eslint
62+
working-directory: ${{env.FRONTEND_WORKING_DIR}}
63+
64+
- name: Lint Prettier
65+
run: yarn lint:prettier
66+
working-directory: ${{env.FRONTEND_WORKING_DIR}}

Diff for: .github/workflows/deploy.yml

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Deploy to Docker Hub
2+
3+
on:
4+
push:
5+
paths-ignore:
6+
- .gitignore
7+
- LICENSE
8+
- '**.md'
9+
branches-ignore:
10+
- 'releases/**'
11+
12+
release:
13+
types:
14+
- published
15+
16+
workflow_dispatch:
17+
18+
env:
19+
BACKEND_DOCKER_IMAGE: iamtakagi/dispotify_backend
20+
FRONTEND_DOCKER_IMAGE: iamtakagi/dispotify_frontend
21+
22+
BACKEND_DOCKER_CONTEXT: backend
23+
FRONTEND_DOCKER_CONTEXT: frontend
24+
25+
jobs:
26+
build:
27+
runs-on: ubuntu-latest
28+
29+
steps:
30+
- name: Checkout Repository
31+
uses: actions/checkout@v2
32+
33+
- name: Login to Docker Hub
34+
uses: docker/login-action@v1
35+
with:
36+
username: ${{ secrets.DOCKERHUB_USERNAME }}
37+
password: ${{ secrets.DOCKERHUB_TOKEN }}
38+
39+
# Backend
40+
- name: Build & Push (master) - Backend
41+
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
42+
uses: docker/build-push-action@v2
43+
with:
44+
push: true
45+
tags: ${{ env.BACKEND_DOCKER_IMAGE }}:latest
46+
context: ${{ env.BACKEND_DOCKER_CONTEXT }}
47+
- name: Build & Push (dev) - Backend
48+
if: github.event_name == 'push' && github.ref == 'refs/heads/dev'
49+
uses: docker/build-push-action@v2
50+
with:
51+
push: true
52+
tags: ${{ env.BACKEND_DOCKER_IMAGE }}:dev
53+
context: ${{ env.BACKEND_DOCKER_CONTEXT }}
54+
- name: Build & Push (Release) - Backend
55+
if: github.event_name == 'release'
56+
uses: docker/build-push-action@v2
57+
with:
58+
push: true
59+
tags: ${{ env.BACKEND_DOCKER_IMAGE }}:${{ github.event.release.tag_name }}
60+
context: ${{ env.BACKEND_DOCKER_CONTEXT }}
61+
62+
# Frontend
63+
- name: Build & Push (master) - Frontend
64+
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
65+
uses: docker/build-push-action@v2
66+
with:
67+
push: true
68+
tags: ${{ env.FRONTEND_DOCKER_IMAGE }}:latest
69+
context: ${{ env.FRONTEND_DOCKER_CONTEXT }}
70+
- name: Build & Push (dev) - Frontend
71+
if: github.event_name == 'push' && github.ref == 'refs/heads/dev'
72+
uses: docker/build-push-action@v2
73+
with:
74+
push: true
75+
tags: ${{ env.FRONTEND_DOCKER_IMAGE }}:dev
76+
context: ${{ env.FRONTEND_DOCKER_CONTEXT }}
77+
- name: Build & Push (Release) - Frontend
78+
if: github.event_name == 'release'
79+
uses: docker/build-push-action@v2
80+
with:
81+
push: true
82+
tags: ${{ env.FRONTEND_DOCKER_IMAGE }}:${{ github.event.release.tag_name }}
83+
context: ${{ env.FRONTEND_DOCKER_CONTEXT }}

Diff for: .gitignore

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.DS_Store
2+
3+
docker-compose.dev.yml
4+
5+
/frontend/.next
6+
/frontend/node_modules
7+
8+
/backend/.cache
9+
/backend/dist
10+
/backend/node_modules

Diff for: LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021- iamtakagi
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Diff for: README.md

+193
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
# dispotify
2+
🎧 Spotify to Discord Notifier Web アプリ
3+
4+
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/iamtakagi/dispotify)](https://github.com/iamtakagi/dispotify/releases)
5+
[![Check](https://github.com/iamtakagi/dispotify/actions/workflows/check.yml/badge.svg?branch=master)](https://github.com/iamtakagi/dispotify/actions/workflows/check.yml)
6+
[![license](https://img.shields.io/github/license/iamtakagi/dispotify)](https://github.com/iamtakagi/dispotify/blob/master/LICENSE)
7+
[![issues](https://img.shields.io/github/issues/iamtakagi/dispotify)](https://github.com/iamtakagi/dispotify/issues)
8+
[![pull requests](https://img.shields.io/github/issues-pr/iamtakagi/dispotify)](https://github.com/dispotify/pulls)
9+
10+
## 特徴
11+
- Spotify x Discord
12+
- 場所を選ばず、手軽にアクセス可能な、Webアプリ
13+
- ユーザーは設定不要
14+
- 誰でも、簡単なUIで設定可能
15+
- Dockerで簡単にセットアップ可能
16+
17+
## 概要・開発動機
18+
- 以前から公式のSpotifyアプリに再生履歴が無いことに不便さを感じており、開発しました。
19+
- このアプリを利用するメリット
20+
- Spotifyの再生履歴がわかる
21+
- Discordで共有できる
22+
- Discord Presence だと見逃しがちな他ユーザーの聴いた曲がわかる。(チャンネル非公開でも使えるので、プライベート利用もOK)
23+
- 等の点において便利な活用ができると考えました。
24+
- 素人が作ったWebアプリなので、不具合等、至らない点あると思いますが、改善や新機能を実装する開発を続けていくと思います。
25+
- 貢献について
26+
- 新機能提案・不具合報告は [Issues](https://github.com/iamtakagi/dispotify/issues) にお願いします。
27+
- [Pull Requests](https://github.com/dispotify/pulls) も歓迎しています。
28+
29+
## 使い方
30+
- [公開版](https://dispotify.iamtakagi.net) もありますが、ユーザー各自でインストールすることを推奨しています。
31+
- 多数ユーザーで利用されてしまうと、安定した動作が期待できません。そのため、できるだけ各自でインストールしてください。24時間継続的に動かせる環境がない等の事情がある方は [そちら](https://dispotify.iamtakagi.net) を利用してください。
32+
33+
## インストール
34+
```console
35+
touch docker-compose.yml
36+
# Database Url 設定
37+
touch backend/prisma/.env
38+
docker-compose up -d --build
39+
```
40+
41+
`docker-compose.yml`
42+
```yml
43+
version: '3.8'
44+
45+
services:
46+
nginx:
47+
build: nginx
48+
ports:
49+
- 80:80
50+
environment:
51+
TZ: Asia/Tokyo
52+
restart: always
53+
54+
db:
55+
container_name: db
56+
image: postgres
57+
environment:
58+
POSTGRES_USER: root
59+
POSTGRES_PASSWORD: root
60+
POSTGRES_DB: dispotify
61+
restart: always
62+
volumes:
63+
- ./db:/docker-entrypoint-initdb.d
64+
- postgres-data:/var/lib/postgresql/data
65+
networks:
66+
- db-network
67+
ports:
68+
- 5432:5432
69+
70+
backend:
71+
container_name: iamtakagi/dispotify_frontend:latest
72+
env_file: ./backend/prisma/.env
73+
environment:
74+
TZ: Asia/Tokyo
75+
HOST: 0.0.0.0
76+
PORT: 3001
77+
BASE_URI: /api
78+
FRONTEND_BASE_URI: http://localhost:3000
79+
SPOTIFY_REDIRECT_URI: http://localhost:3001/api/auth/callback
80+
# 入力必須
81+
SPOTIFY_CLIENT_ID: xxx
82+
SPOTIFY_CLIENT_SECRET: xxx
83+
# 再生中の音楽を検知するタスクのインターバル: 25秒以上を推奨 (それ以下にすると SpotifyAPI のRateLimit に引っ掛かり Too Many Request 429 の応答エラーが発生する可能性有)
84+
PLAYER_WATCH_INTERVAL: 25000
85+
restart: always
86+
networks:
87+
- db-network
88+
ports:
89+
- 3001:3001
90+
links:
91+
- db
92+
depends_on:
93+
- db
94+
95+
frontend:
96+
container_name: iamtakagi/dispotify_frontend:latest
97+
environment:
98+
TZ: Asia/Tokyo
99+
HOST: 0.0.0.0
100+
PORT: 3000
101+
BACKEND_BASE_URI: http://localhost:3001/api
102+
restart: always
103+
ports:
104+
- 3000:3000
105+
106+
volumes:
107+
postgres-data:
108+
109+
networks:
110+
db-network:
111+
driver: bridge
112+
```
113+
114+
## 開発
115+
```console
116+
cd backend && yarn
117+
cd frontend && yarn && yarn prisma:generate
118+
```
119+
120+
`docker-compose.yml`
121+
```yml
122+
version: '3.8'
123+
124+
services:
125+
nginx:
126+
build: nginx
127+
ports:
128+
- 80:80
129+
environment:
130+
TZ: Asia/Tokyo
131+
restart: always
132+
133+
db:
134+
container_name: db
135+
image: postgres
136+
environment:
137+
POSTGRES_USER: root
138+
POSTGRES_PASSWORD: root
139+
POSTGRES_DB: dispotify
140+
restart: always
141+
volumes:
142+
- ./db:/docker-entrypoint-initdb.d
143+
- postgres-data:/var/lib/postgresql/data
144+
networks:
145+
- db-network
146+
ports:
147+
- 5432:5432
148+
149+
backend:
150+
container_name: backend
151+
build: backend
152+
env_file: ./backend/prisma/.env
153+
environment:
154+
TZ: Asia/Tokyo
155+
HOST: 0.0.0.0
156+
PORT: 3001
157+
BASE_URI: /api
158+
FRONTEND_BASE_URI: http://localhost:3000
159+
SPOTIFY_REDIRECT_URI: http://localhost:3001/api/auth/callback
160+
# 入力必須
161+
SPOTIFY_CLIENT_ID: xxx
162+
SPOTIFY_CLIENT_SECRET: xxx
163+
# 再生中の音楽を検知するタスクのインターバル: 25秒以上を推奨 (それ以下にすると SpotifyAPI のRateLimit に引っ掛かり Too Many Request 429 の応答エラーが発生する可能性有)
164+
PLAYER_WATCH_INTERVAL: 25000
165+
restart: always
166+
networks:
167+
- db-network
168+
ports:
169+
- 3001:3001
170+
links:
171+
- db
172+
depends_on:
173+
- db
174+
175+
frontend:
176+
container_name: frontend
177+
build: frontend
178+
environment:
179+
TZ: Asia/Tokyo
180+
HOST: 0.0.0.0
181+
PORT: 3000
182+
BACKEND_BASE_URI: http://localhost:3001/api
183+
restart: always
184+
ports:
185+
- 3000:3000
186+
187+
volumes:
188+
postgres-data:
189+
190+
networks:
191+
db-network:
192+
driver: bridge
193+
```

Diff for: backend/.prettierignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/.cache
2+
/node_modules/
3+
/prisma/
4+
/dist

Diff for: backend/.prettierrc

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"semi": false,
3+
"singleQuote": true
4+
}

0 commit comments

Comments
 (0)