Merge pull request 'Dockerize the app' (#1) from kdh8219/misskey-random-sentence-bot:feature/dockerize into main
Reviewed-on: https://codeberg.org/sunwoo1524/misskey-random-sentence-bot/pulls/1
This commit is contained in:
commit
df18de95b8
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -3,3 +3,4 @@ setting.py
|
|||
google_api.json
|
||||
__pycache__/
|
||||
.env
|
||||
docker-compose.yml
|
||||
|
|
13
Dockerfile
Normal file
13
Dockerfile
Normal file
|
@ -0,0 +1,13 @@
|
|||
FROM python:bookworm
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY src src
|
||||
COPY main.py main.py
|
||||
COPY requirements.txt requirements.txt
|
||||
|
||||
# RUN python -m venv venv
|
||||
# RUN source ./venv/bin/activate
|
||||
RUN pip install -r requirements.txt
|
||||
|
||||
CMD ["python", "main.py"]
|
23
README.md
23
README.md
|
@ -2,6 +2,26 @@
|
|||
|
||||
[![no github badge](https://nogithub.codeberg.page/badge.svg)](https://nogithub.codeberg.page/)
|
||||
|
||||
## How to run with docker compose
|
||||
|
||||
1. clone repo
|
||||
2. change setting
|
||||
|
||||
```
|
||||
# copy example compose file
|
||||
cp docker-compose.example.yml docker-compose.env
|
||||
|
||||
# edit compose file
|
||||
vim .docker-compose
|
||||
```
|
||||
|
||||
3. RUN
|
||||
|
||||
```
|
||||
docker compose up
|
||||
docker compose down
|
||||
```
|
||||
|
||||
## How to run manually
|
||||
|
||||
1. clone repo
|
||||
|
@ -28,6 +48,7 @@ cp .example.env .env
|
|||
# edit setting file
|
||||
vim .env
|
||||
```
|
||||
|
||||
5. RUN
|
||||
|
||||
```
|
||||
|
@ -35,9 +56,11 @@ python main.py
|
|||
```
|
||||
|
||||
# Contribute
|
||||
|
||||
To contribute to this project is free!
|
||||
|
||||
## Contributors
|
||||
|
||||
**Thank you for your contribution!**
|
||||
|
||||
<a class="contributor" href="https://codeberg.org/kdh8219"><img src="https://codeberg.org/avatars/6529ee7f1f363a06741ed8851c08e94b77d27e83003d1a58f59e1e936087728c?size=512" alt="kdh8219" width="70" style="border-radius: 50%"></a>
|
||||
|
|
13
docker-compose.example.yml
Normal file
13
docker-compose.example.yml
Normal file
|
@ -0,0 +1,13 @@
|
|||
version: "3.9"
|
||||
|
||||
services:
|
||||
app:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./Dockerfile
|
||||
environment:
|
||||
- MISSKEY_INSTANCE_ADDRESS=worldc.one
|
||||
- MISSKEY_ACCESS_TOKEN=BWbGlK6lWuUgXQpFM7igtmbZ30g6BOIc
|
||||
- SENTENCES_FILE=/data/sentences.txt
|
||||
volumes:
|
||||
- ./data:/data
|
12
setup.md
Normal file
12
setup.md
Normal file
|
@ -0,0 +1,12 @@
|
|||
# Misskey api key 발급받기
|
||||
|
||||
1. 설정 - api 접속
|
||||
2. 엑세스 토큰 생성 - **"노트를 작성하거나 삭제합니다"** 켬
|
||||
|
||||
# docker compose crontab 설정하기
|
||||
|
||||
```
|
||||
docker compose -f 프로젝트경로/docker-compose.yml up
|
||||
```
|
||||
|
||||
을 crontab에 등록하시면 됩니다(아마도)
|
0
src/__init__.py
Normal file
0
src/__init__.py
Normal file
|
@ -8,8 +8,7 @@ load_dotenv()
|
|||
|
||||
try:
|
||||
with open(os.environ["SENTENCES_FILE"], "r") as f:
|
||||
_sentences: str = f.readlines()
|
||||
_sentences = _sentences.replace("\\n", "\n")
|
||||
_sentences = f.readlines()
|
||||
except:
|
||||
e = sys.exc_info()[1]
|
||||
_sentences = [f"에러발생(진짜임): {e}"]
|
||||
|
@ -17,5 +16,5 @@ except:
|
|||
# choose random sentence in google spread sheet
|
||||
def chooseSentence() -> str:
|
||||
# choice random sentence
|
||||
return random.choice(_sentences)
|
||||
return random.choice(_sentences).replace("\\n","\n")
|
||||
|
||||
|
|
Loading…
Reference in a new issue