Add docker things
This commit is contained in:
parent
028d51af18
commit
028c1ac91d
37
Dockerfile
Normal file
37
Dockerfile
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
ARG PYTHON_VERSION=3.10
|
||||||
|
FROM python:${PYTHON_VERSION}-slim
|
||||||
|
|
||||||
|
# avoid .pyc and buffering stdout/stderr
|
||||||
|
ENV PYTHONDONTWRITEBYTECODE=1
|
||||||
|
ENV PYTHONUNBUFFERED=1
|
||||||
|
|
||||||
|
# add non-root user
|
||||||
|
ARG UID=1000
|
||||||
|
RUN adduser \
|
||||||
|
--disabled-password \
|
||||||
|
--no-create-home \
|
||||||
|
--uid "${UID}" \
|
||||||
|
--home "/app" \
|
||||||
|
bot
|
||||||
|
|
||||||
|
# install requirements
|
||||||
|
RUN --mount=type=cache,target=/root/.cache/pip \
|
||||||
|
--mount=type=bind,source=requirements.txt,target=requirements.txt \
|
||||||
|
pip install -r requirements.txt
|
||||||
|
|
||||||
|
# copy i18n files
|
||||||
|
COPY --chown=bot i18n.yaml i18n/i18n.yaml
|
||||||
|
VOLUME i18n/
|
||||||
|
|
||||||
|
# copy default configs
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --chown=bot mybot mybot
|
||||||
|
|
||||||
|
# preapre environment
|
||||||
|
ENV SS_TYPE=memory
|
||||||
|
ENV I18N_PATH=/i18n/i18n.yaml
|
||||||
|
|
||||||
|
# set user
|
||||||
|
USER bot
|
||||||
|
|
||||||
|
CMD ["python3", "-m", "mybot"]
|
||||||
30
docker-compose.yml
Normal file
30
docker-compose.yml
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
version: "3.0"
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
i18n: {}
|
||||||
|
redis-config: {}
|
||||||
|
redis-data: {}
|
||||||
|
|
||||||
|
services:
|
||||||
|
bot:
|
||||||
|
build:
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
context: .
|
||||||
|
depends_on: [redis]
|
||||||
|
restart: unless-stopped
|
||||||
|
volumes:
|
||||||
|
- i18n:/i18n
|
||||||
|
env_file: .env
|
||||||
|
environment:
|
||||||
|
- SS_TYPE=memory # redis currently is broken
|
||||||
|
- SS_REDIS_HOST=redis
|
||||||
|
- SS_REDIS_PORT=6379
|
||||||
|
- SS_REDIS_PASSWORD=bot
|
||||||
|
|
||||||
|
redis:
|
||||||
|
image: redis
|
||||||
|
restart: unless-stopped
|
||||||
|
volumes:
|
||||||
|
- redis-config:/etc/redis
|
||||||
|
- redis-data:/data
|
||||||
|
command: redis-server --save 20 1 --loglevel warning --requirepass bot
|
||||||
Loading…
x
Reference in New Issue
Block a user