-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
53 lines (47 loc) · 1.49 KB
/
Dockerfile
File metadata and controls
53 lines (47 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Reference on Poetry in Docker: https://stackoverflow.com/a/54763270/265508
FROM python:3.10-slim
LABEL maintainer="erik.westrup@gmail.com"
LABEL vendor="tardsquad"
# Python
ENV \
PYTHONFAULTHANDLER=1 \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1
# pip
ENV \
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100
# Poetry
ENV \
POETRY_VERSION=1.1.11 \
POETRY_NO_INTERACTION=1 \
#POETRY_VIRTUALENVS_CREATE=false \
# Required as Google Cloud Run runs docker commands in a separate context,
# meaning that $(poetry run) won't find the existing virtualenv
# and the execution fails with module import errors.
# Reference: https://stackoverflow.com/q/68683913/265508
POETRY_VIRTUALENVS_IN_PROJECT=true \
PATH="$PATH:/root/.local/bin"
# System dependencies
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install --no-install-recommends -y \
bash \
build-essential \
curl \
# Installing `poetry` package manager:
&& pip install "poetry==$POETRY_VERSION" \
# Official way is with curl, but it has cons as well..
#&& curl -sSL 'https://install.python-poetry.org' | python - \
&& poetry --version \
# Cleaning cache
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*
WORKDIR /code
# Project initialization:
COPY poetry.lock pyproject.toml ./
RUN poetry install --no-dev --no-ansi
COPY . .
# Start bot
ENTRYPOINT ["poetry", "run", "tardsquad-discord-bot"]