Skip to content

Commit c4d757f

Browse files
committed
Add image build and push job to CI
This job is intended to only run on pushes to `master` or by manual dispatch. Pull requests should not trigger this job and it should instead be skipped automatically.
1 parent 7ce2388 commit c4d757f

4 files changed

Lines changed: 232 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,31 @@ jobs:
7272
run: >
7373
SKIP=no-commit-to-branch
7474
pre-commit run --all-files --show-diff-on-failure
75+
build:
76+
name: Build Image
77+
needs: lint
78+
if: ${{ github.base_ref == '' }}
79+
runs-on: ubuntu-latest
80+
steps:
81+
- name: Checkout repository
82+
uses: actions/checkout@v4.2.2
83+
84+
- name: Log into registry
85+
uses: docker/login-action@v3.4.0
86+
with:
87+
registry: ghcr.io
88+
username: scioly
89+
password: ${{ secrets.GITHUB_TOKEN }}
90+
91+
- name: Docker meta
92+
id: meta
93+
uses: docker/metadata-action@v5.7.0
94+
with:
95+
images: ghcr.io/scioly/pi-bot
96+
97+
- name: Build and push image
98+
uses: docker/build-push-action@v6
99+
with:
100+
file: prod.Dockerfile
101+
push: true
102+
tags: scioly/pi-bot:${{ github.sha }}

docker-compose-prod.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
services:
3+
bot:
4+
image: pi-bot:prod # ghcr.io/scioly.org/pi-bot
5+
secrets:
6+
- pibot_env
7+
entrypoint: [
8+
'/bin/sh',
9+
'-c',
10+
'cp /run/secrets/pibot_env /usr/src/app/.env; python3 -u bot.py'
11+
]
12+
depends_on:
13+
- mongodb
14+
networks:
15+
- pibot_internal
16+
17+
mongodb:
18+
image: docker.io/mongo:5.0.10
19+
volumes:
20+
- mongodata:/data/db
21+
environment:
22+
MONGO_INITDB_ROOT_USERNAME: ${MONGO_ROOT_USER}
23+
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_ROOT_PASS}
24+
MONGO_INITDB_DATABASE: data
25+
MONGO_DATA_DIR: /data/db
26+
MONGODB_LOG_DIR: /dev/null
27+
networks:
28+
- pibot_internal
29+
30+
secrets:
31+
pibot_env:
32+
file: ./.env
33+
volumes:
34+
mongodata:
35+
networks:
36+
pibot_internal:

prod.Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM python:3.10
2+
3+
# Set working directory
4+
WORKDIR /usr/src/app
5+
6+
# Install dependencies
7+
COPY requirements.txt /usr/src/app/requirements.txt
8+
RUN ["pip3", "install", "--no-cache-dir", "-r", "requirements.txt"]
9+
10+
# Copy all bot code over
11+
COPY . .
12+
13+
# Run the bot when container is run
14+
CMD ["python3", "-u", "bot.py"]

prod.dockerignore

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
# NEVER DELETE - FILES ASSOCIATED WITH PI-BOT
2+
service_account.json
3+
pywikibot.lwp
4+
throttle.ctrl
5+
apicache-py3/
6+
*password*
7+
.DS_Store
8+
met.png
9+
embed_export.json
10+
resultstemplate.txt
11+
*.svg
12+
mongodata/
13+
14+
# Python gitignore template
15+
# Byte-compiled / optimized / DLL files
16+
__pycache__/
17+
*.py[cod]
18+
*$py.class
19+
20+
# C extensions
21+
*.so
22+
23+
# Distribution / packaging
24+
.Python
25+
build/
26+
develop-eggs/
27+
dist/
28+
downloads/
29+
eggs/
30+
.eggs/
31+
lib/
32+
lib64/
33+
parts/
34+
sdist/
35+
var/
36+
wheels/
37+
share/python-wheels/
38+
*.egg-info/
39+
.installed.cfg
40+
*.egg
41+
MANIFEST
42+
43+
# PyInstaller
44+
# Usually these files are written by a python script from a template
45+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
46+
*.manifest
47+
*.spec
48+
49+
# Installer logs
50+
pip-log.txt
51+
pip-delete-this-directory.txt
52+
53+
# Unit test / coverage reports
54+
htmlcov/
55+
.tox/
56+
.nox/
57+
.coverage
58+
.coverage.*
59+
.cache
60+
nosetests.xml
61+
coverage.xml
62+
*.cover
63+
*.py,cover
64+
.hypothesis/
65+
.pytest_cache/
66+
cover/
67+
68+
# Translations
69+
*.mo
70+
*.pot
71+
72+
# Django stuff:
73+
*.log
74+
local_settings.py
75+
db.sqlite3
76+
db.sqlite3-journal
77+
78+
# Flask stuff:
79+
instance/
80+
.webassets-cache
81+
82+
# Scrapy stuff:
83+
.scrapy
84+
85+
# Sphinx documentation
86+
docs/_build/
87+
88+
# PyBuilder
89+
.pybuilder/
90+
target/
91+
92+
# Jupyter Notebook
93+
.ipynb_checkpoints
94+
95+
# IPython
96+
profile_default/
97+
ipython_config.py
98+
99+
# pyenv
100+
# For a library or package, you might want to ignore these files since the code is
101+
# intended to run in multiple environments; otherwise, check them in:
102+
# .python-version
103+
104+
# pipenv
105+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
106+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
107+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
108+
# install all needed dependencies.
109+
#Pipfile.lock
110+
111+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
112+
__pypackages__/
113+
114+
# Celery stuff
115+
celerybeat-schedule
116+
celerybeat.pid
117+
118+
# SageMath parsed files
119+
*.sage.py
120+
121+
# Environments
122+
.env
123+
.venv
124+
env/
125+
venv/
126+
ENV/
127+
env.bak/
128+
venv.bak/
129+
130+
# Spyder project settings
131+
.spyderproject
132+
.spyproject
133+
134+
# Rope project settings
135+
.ropeproject
136+
137+
# mkdocs documentation
138+
/site
139+
140+
# mypy
141+
.mypy_cache/
142+
.dmypy.json
143+
dmypy.json
144+
145+
# Pyre type checker
146+
.pyre/
147+
148+
# pytype static type analyzer
149+
.pytype/
150+
151+
# Cython debug symbols
152+
cython_debug/
153+
154+
.vscode

0 commit comments

Comments
 (0)