-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
41 lines (30 loc) · 2.93 KB
/
Dockerfile
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
# Использует официальный базовый образ Python Slim для создания своего образа.
# Slim версия содержит минимальный набор пакетов, необходимых для работы Python, что делает образ более легковесным.
FROM python:slim
# Копирует файл requirements.txt из локальной директории в файловую систему образа.
COPY requirements.txt requirements.txt
# Выполняет установку Python зависимостей из файла requirements.txt.
RUN pip install -r requirements.txt
# Дополнительно устанавливает gunicorn, популярный WSGI HTTP сервер для UNIX, используемый для развертывания Python веб-приложений.
# MySQL вместе с cryptography пакетом для аутентификации на сервере MySQL
RUN pip install gunicorn pymysql cryptography
# Копирует директорию app и migrations из локальной файловой системы в файловую систему образа.
COPY app app
COPY migrations migrations
# Копирует файлы microblog.py, config.py и boot.sh в корневую директорию файловой системы образа.
# boot.sh - скрипт для запуска приложения.
COPY microblog.py config.py boot.sh ./
# Делает для Windows скрипт boot.sh исполняемым - необходимо для того, чтобы можно было запустить приложение с помощью этого скрипта.
# Для прочих систем не требуется, но и не помешает.
RUN chmod a+x boot.sh
# Устанавливает переменную окружения FLASK_APP, указывая Flask, какой файл запускать в качестве приложения.
ENV FLASK_APP microblog.py
# Выполняет компиляцию переводов для приложения Flask.
# Это предполагает, что приложение использует систему интернационализации для поддержки множественных языков.
RUN flask translate compile
# Объявляет, что контейнер будет слушать порт 5000 во время выполнения.
# Это стандартный порт для Flask приложений, но его можно переопределить при запуске контейнера.
EXPOSE 5000
# Указывает Docker, какой командой (или скриптом) следует запустить контейнер.
# В данном случае используется скрипт boot.sh для запуска приложения.
ENTRYPOINT ["./boot.sh"]