Browse Source

Added docker-related stuff

pull/1/head
Mykyta Solomko 6 years ago
parent
commit
cdd3146c1f
  1. 40
      .dockerignore
  2. 1
      .gitignore
  3. 36
      Dockerfile
  4. 13
      entrypoint.sh

40
.dockerignore

@ -0,0 +1,40 @@
### OS-specific
# Linux
*~
*.swp
.fuse_hidden*
.directory
# Windows
Thumbs.db
ehthumbs.db
ehthumbs_vista.db
*.stackdump
[Dd]esktop.ini
$RECYCLE.BIN/
*.lnk
### Python
__pycache__/
*.py[cod]
*$py.class
.env
.venv
env/
venv/
ENV/
*.egg
dist/
build/
### Pycharm
.idea/
# Misc
*log
*.bak
### Git repo
.git*
*.md

1
.gitignore

@ -2,6 +2,7 @@
# Linux
*~
*.swp
.fuse_hidden*
.directory

36
Dockerfile

@ -0,0 +1,36 @@
FROM python:3-alpine AS builder
COPY . /bot
WORKDIR /bot
RUN apk upgrade --no-cache \
&& apk add --no-cache alpine-sdk \
openssl openssl-dev \
libffi libffi-dev \
&& python -m venv venv \
&& . ./venv/bin/activate \
&& pip install -r requirements.txt
# ===
FROM python:3-alpine
RUN apk upgrade --no-cache \
&& apk add --no-cache bash openssl libffi \
&& adduser potato --disabled-password \
--shell /bin/false \
--home /bot \
--no-create-home
WORKDIR /bot
COPY --from=builder /bot/entrypoint.sh .
COPY --from=builder /bot/bot.py .
COPY --from=builder /bot/venv venv
COPY --from=builder /bot/LICENSE .
USER potato
ENTRYPOINT ["/bot/entrypoint.sh"]

13
entrypoint.sh

@ -0,0 +1,13 @@
#!/usr/bin/env bash
# Send SIGTERM to all running processes on exit
trap "/bin/kill -s TERM -1" SIGTERM SIGQUIT
case "${1}" in
'')
source /bot/venv/bin/activate
python /bot/bot.py
;;
*) exec ${@} ;;
esac
Loading…
Cancel
Save