Skip to content

Commit 5d8a7f8

Browse files
dockerfile
1 parent d472a53 commit 5d8a7f8

9 files changed

+1484
-1482
lines changed

.dockerignore

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
README.md
2-
.github/
3-
.gitignore
4-
__pycache__/
1+
README.md
2+
.github/
3+
.gitignore
4+
__pycache__/
55
*.log

.github/workflows/deployment.yml

+32-32
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
name: Deploying to VPS
2-
3-
on:
4-
push:
5-
workflow_dispatch:
6-
7-
jobs:
8-
deploy:
9-
runs-on: ubuntu-latest
10-
steps:
11-
- name: Checkout repo
12-
uses: actions/checkout@v4
13-
with:
14-
fetch-depth: 1
15-
- name: Calculate short hash
16-
run: |
17-
shortHash=$(git rev-parse --short ${{ github.sha }})
18-
echo "COMMIT_SHORT_SHA=$shortHash" >> $GITHUB_ENV
19-
- name: SSH setup and run commands
20-
uses: appleboy/ssh-action@v1.0.3
21-
with:
22-
host: ${{ secrets.SSH_HOST }}
23-
key: ${{ secrets.SSH_KEY }}
24-
username: ${{ secrets.SSH_USER }}
25-
passphrase: ${{ secrets.SSH_PASSPHRASE }}
26-
script: |
27-
cd ./deploy/${{ github.event.repository.name }}
28-
git pull
29-
docker rm --force ${{ github.event.repository.name }}-deploy || true
30-
docker build -t ${{ github.event.repository.owner.name }}/${{ github.event.repository.name }}:${{ env.COMMIT_SHORT_SHA }} --quiet .
31-
docker run --detach --name ${{ github.event.repository.name }}-deploy ${{ github.event.repository.owner.name }}/${{ github.event.repository.name }}:${{ env.COMMIT_SHORT_SHA }}
32-
docker container prune --force && docker image prune --all --force
1+
name: Deploying to VPS
2+
3+
on:
4+
push:
5+
workflow_dispatch:
6+
7+
jobs:
8+
deploy:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout repo
12+
uses: actions/checkout@v4
13+
with:
14+
fetch-depth: 1
15+
- name: Calculate short hash
16+
run: |
17+
shortHash=$(git rev-parse --short ${{ github.sha }})
18+
echo "COMMIT_SHORT_SHA=$shortHash" >> $GITHUB_ENV
19+
- name: SSH setup and run commands
20+
uses: appleboy/ssh-action@v1.0.3
21+
with:
22+
host: ${{ secrets.SSH_HOST }}
23+
key: ${{ secrets.SSH_KEY }}
24+
username: ${{ secrets.SSH_USER }}
25+
passphrase: ${{ secrets.SSH_PASSPHRASE }}
26+
script: |
27+
cd ./deploy/${{ github.event.repository.name }}
28+
git pull
29+
docker rm --force ${{ github.event.repository.name }}-deploy || true
30+
docker build -t ${{ github.event.repository.owner.name }}/${{ github.event.repository.name }}:${{ env.COMMIT_SHORT_SHA }} --quiet .
31+
docker run --detach --name ${{ github.event.repository.name }}-deploy ${{ github.event.repository.owner.name }}/${{ github.event.repository.name }}:${{ env.COMMIT_SHORT_SHA }}
32+
docker container prune --force && docker image prune --all --force

.gitignore

+116-116
Original file line numberDiff line numberDiff line change
@@ -1,117 +1,117 @@
1-
testing.py
2-
Pipfile
3-
Pipfile.lock
4-
5-
*.env
6-
*.log
7-
*.py[ci]
8-
*.csv
9-
*.json
10-
*.db
11-
members.txt
12-
13-
__pycache__/
14-
.mypy_cache/
15-
.vscode/
16-
log/
17-
flask_session/
18-
19-
# Byte-compiled / optimized / DLL files
20-
__pycache__/
21-
*.py[cod]
22-
*$py.class
23-
24-
# C extensions
25-
*.so
26-
27-
# Distribution / packaging
28-
.Python
29-
build/
30-
develop-eggs/
31-
dist/
32-
downloads/
33-
eggs/
34-
.eggs/
35-
lib/
36-
lib64/
37-
parts/
38-
sdist/
39-
var/
40-
wheels/
41-
share/python-wheels/
42-
*.egg-info/
43-
.installed.cfg
44-
*.egg
45-
MANIFEST
46-
47-
# PyInstaller
48-
# Usually these files are written by a python script from a template
49-
# before PyInstaller builds the exe, so as to inject date/other infos into it.
50-
*.manifest
51-
*.spec
52-
53-
# Installer logs
54-
pip-log.txt
55-
pip-delete-this-directory.txt
56-
57-
# Unit test / coverage reports
58-
htmlcov/
59-
.tox/
60-
.nox/
61-
.coverage
62-
.coverage.*
63-
.cache
64-
nosetests.xml
65-
coverage.xml
66-
*.cover
67-
*.py,cover
68-
.hypothesis/
69-
.pytest_cache/
70-
cover/
71-
72-
# Translations
73-
*.mo
74-
*.pot
75-
76-
# Django stuff:
77-
*.log
78-
local_settings.py
79-
db.sqlite3
80-
db.sqlite3-journal
81-
82-
# Flask stuff:
83-
instance/
84-
.webassets-cache
85-
86-
# Scrapy stuff:
87-
.scrapy
88-
89-
# Sphinx documentation
90-
docs/_build/
91-
92-
# PyBuilder
93-
.pybuilder/
94-
target/
95-
96-
# Environments
97-
.env
98-
.venv
99-
env/
100-
venv/
101-
ENV/
102-
env.bak/
103-
venv.bak/
104-
105-
# mypy
106-
.mypy_cache/
107-
.dmypy.json
108-
dmypy.json
109-
110-
# Pyre type checker
111-
.pyre/
112-
113-
# pytype static type analyzer
114-
.pytype/
115-
116-
# Cython debug symbols
1+
testing.py
2+
Pipfile
3+
Pipfile.lock
4+
5+
*.env
6+
*.log
7+
*.py[ci]
8+
*.csv
9+
*.json
10+
*.db
11+
members.txt
12+
13+
__pycache__/
14+
.mypy_cache/
15+
.vscode/
16+
log/
17+
flask_session/
18+
19+
# Byte-compiled / optimized / DLL files
20+
__pycache__/
21+
*.py[cod]
22+
*$py.class
23+
24+
# C extensions
25+
*.so
26+
27+
# Distribution / packaging
28+
.Python
29+
build/
30+
develop-eggs/
31+
dist/
32+
downloads/
33+
eggs/
34+
.eggs/
35+
lib/
36+
lib64/
37+
parts/
38+
sdist/
39+
var/
40+
wheels/
41+
share/python-wheels/
42+
*.egg-info/
43+
.installed.cfg
44+
*.egg
45+
MANIFEST
46+
47+
# PyInstaller
48+
# Usually these files are written by a python script from a template
49+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
50+
*.manifest
51+
*.spec
52+
53+
# Installer logs
54+
pip-log.txt
55+
pip-delete-this-directory.txt
56+
57+
# Unit test / coverage reports
58+
htmlcov/
59+
.tox/
60+
.nox/
61+
.coverage
62+
.coverage.*
63+
.cache
64+
nosetests.xml
65+
coverage.xml
66+
*.cover
67+
*.py,cover
68+
.hypothesis/
69+
.pytest_cache/
70+
cover/
71+
72+
# Translations
73+
*.mo
74+
*.pot
75+
76+
# Django stuff:
77+
*.log
78+
local_settings.py
79+
db.sqlite3
80+
db.sqlite3-journal
81+
82+
# Flask stuff:
83+
instance/
84+
.webassets-cache
85+
86+
# Scrapy stuff:
87+
.scrapy
88+
89+
# Sphinx documentation
90+
docs/_build/
91+
92+
# PyBuilder
93+
.pybuilder/
94+
target/
95+
96+
# Environments
97+
.env
98+
.venv
99+
env/
100+
venv/
101+
ENV/
102+
env.bak/
103+
venv.bak/
104+
105+
# mypy
106+
.mypy_cache/
107+
.dmypy.json
108+
dmypy.json
109+
110+
# Pyre type checker
111+
.pyre/
112+
113+
# pytype static type analyzer
114+
.pytype/
115+
116+
# Cython debug symbols
117117
cython_debug/

Dockerfile

+32-30
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,33 @@
1-
FROM python:3.11.7-slim AS base-image
2-
3-
ENV PYTHONUNBUFFERED=1
4-
5-
RUN ["pip","install","poetry>=1.7,<1.8","--upgrade"]
6-
7-
RUN ["poetry","self","add","poetry-plugin-export"]
8-
9-
WORKDIR /export
10-
11-
COPY pyproject.toml poetry.lock ./
12-
13-
RUN ["poetry","export","--format","requirements.txt","--output","requirements.txt"]
14-
15-
FROM python:3.11.7-slim AS runtime-image
16-
17-
LABEL description="CYSCOM VIT's discord bot"
18-
19-
COPY --from=base-image /export/requirements.txt requirements.txt
20-
21-
RUN ["useradd","--create-home","cyscom-docker"]
22-
23-
USER cyscom-docker
24-
25-
RUN ["pip","install","--requirement","requirements.txt"]
26-
27-
WORKDIR /home/cyscom-docker/discord-bot
28-
29-
COPY . .
30-
1+
FROM python:3.11.7-slim AS requirements-image
2+
3+
ENV PYTHONUNBUFFERED=1
4+
5+
RUN ["pip","install","poetry>=1.7,<1.8"]
6+
7+
RUN ["poetry","self","add","poetry-plugin-export"]
8+
9+
WORKDIR /export
10+
11+
COPY pyproject.toml poetry.lock ./
12+
13+
RUN ["poetry","export","--format","requirements.txt","--output","requirements.txt"]
14+
15+
FROM python:3.11.7-slim AS runtime-image
16+
17+
LABEL description="CYSCOM VIT's discord bot"
18+
19+
ENV PYTHONUNBUFFERED=1
20+
21+
COPY --from=requirements-image /export/requirements.txt requirements.txt
22+
23+
RUN ["useradd","--create-home","cyscom-docker"]
24+
25+
USER cyscom-docker
26+
27+
RUN ["pip","install","--user","--requirement","requirements.txt"]
28+
29+
WORKDIR /home/cyscom-docker/discord-bot
30+
31+
COPY . .
32+
3133
CMD python3 bot.py

LICENSE

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

0 commit comments

Comments
 (0)