Update Dockerfile
Browse files- Dockerfile +19 -36
Dockerfile
CHANGED
@@ -1,42 +1,25 @@
|
|
1 |
-
|
2 |
-
FROM python:3.10-slim
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
|
|
|
|
|
|
|
7 |
|
8 |
-
|
9 |
-
RUN apt-get update && apt-get install -y \
|
10 |
-
build-essential \
|
11 |
-
libpq-dev \
|
12 |
-
redis-server \
|
13 |
-
postgresql \
|
14 |
-
postgresql-contrib \
|
15 |
-
&& rm -rf /var/lib/apt/lists/*
|
16 |
|
17 |
-
|
18 |
-
WORKDIR /app
|
19 |
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
-
|
24 |
-
RUN pip install --no-cache-dir -r requirements.txt
|
25 |
|
26 |
-
|
27 |
-
RUN service postgresql start && \
|
28 |
-
psql -U postgres -c "CREATE USER tgbot WITH PASSWORD 'tgbotpassword';" && \
|
29 |
-
psql -U postgres -c "CREATE DATABASE bot_db OWNER tgbot;" && \
|
30 |
-
service postgresql stop
|
31 |
-
|
32 |
-
# Start Redis
|
33 |
-
RUN echo "supervised no" >> /etc/redis/redis.conf
|
34 |
-
|
35 |
-
# Expose ports
|
36 |
-
EXPOSE 5000
|
37 |
-
EXPOSE 8080
|
38 |
-
|
39 |
-
# Start services and run the bot
|
40 |
-
CMD service postgresql start && \
|
41 |
-
redis-server /etc/redis/redis.conf --daemonize yes && \
|
42 |
-
python -m bot.__main__
|
|
|
1 |
+
FROM python:3.10.13-alpine3.18
|
|
|
2 |
|
3 |
+
ENV POETRY_NO_INTERACTION=1 \
|
4 |
+
POETRY_VIRTUALENVS_IN_PROJECT=1 \
|
5 |
+
POETRY_VIRTUALENVS_CREATE=0 \
|
6 |
+
POETRY_HOME="/etc/poetry" \
|
7 |
+
POETRY_CACHE_DIR="/tmp/poetry_cache" \
|
8 |
+
POETRY_VERSION=1.8.3
|
9 |
|
10 |
+
WORKDIR /usr/src/app
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
+
COPY . .
|
|
|
13 |
|
14 |
+
RUN pip install --no-cache-dir "poetry==$POETRY_VERSION" \
|
15 |
+
&& poetry install --without admin --without dev --no-root \
|
16 |
+
&& pip uninstall -y poetry \
|
17 |
+
&& pybabel compile -d bot/locales \
|
18 |
+
&& rm -rf /home/appuser/.cache \
|
19 |
+
&& rm -rf $POETRY_CACHE_DIR \
|
20 |
+
&& adduser -D appuser \
|
21 |
+
&& chown -R appuser:appuser .
|
22 |
|
23 |
+
USER appuser
|
|
|
24 |
|
25 |
+
CMD ["python", "-m", "bot"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|