mirror of
https://github.com/Balshgit/gpt_chat_bot.git
synced 2025-12-15 16:10:39 +03:00
microservices are able to run (#5)
This commit is contained in:
18
deploy/Caddyfile
Normal file
18
deploy/Caddyfile
Normal file
@@ -0,0 +1,18 @@
|
||||
# Telegram bot. Redirects to bot-service
|
||||
:8083 {
|
||||
reverse_proxy bot_service:8080
|
||||
header Strict-Transport-Security max-age=31536000;
|
||||
|
||||
# Removing some headers for improved security:
|
||||
header -Server
|
||||
}
|
||||
|
||||
# Telegram bot. Redirects to test-server ip
|
||||
:8084 {
|
||||
reverse_proxy chat_service:1338
|
||||
header Strict-Transport-Security max-age=31536000;
|
||||
|
||||
# Removing some headers for improved security:
|
||||
header -Server
|
||||
|
||||
}
|
||||
@@ -1,43 +1,31 @@
|
||||
FROM python:3.11.5
|
||||
FROM python:3.11.5 AS compile-image
|
||||
|
||||
ARG USER
|
||||
|
||||
ENV USER=${USER} \
|
||||
PYTHONFAULTHANDLER=1 \
|
||||
PYTHONUNBUFFERED=1 \
|
||||
PYTHONHASHSEED=random \
|
||||
PYTHONDONTWRITEBYTECODE=1 \
|
||||
# pip:
|
||||
PIP_NO_CACHE_DIR=off \
|
||||
PIP_DISABLE_PIP_VERSION_CHECK=on \
|
||||
PIP_DEFAULT_TIMEOUT=100 \
|
||||
POETRY_VIRTUALENVS_CREATE=false \
|
||||
POETRY_CACHE_DIR='/var/cache/pypoetry' \
|
||||
PATH="$PATH:/root/.poetry/bin" \
|
||||
DOCKER_CONTAINER=1 \
|
||||
POETRY_VERSION=1.6.1
|
||||
ENV PYTHONUNBUFFERED=1 \
|
||||
PIP_DISABLE_PIP_VERSION_CHECK=on \
|
||||
DOCKER_CONTAINER=1 \
|
||||
POETRY_VERSION=1.6.1
|
||||
|
||||
|
||||
RUN printf "================\n\nStart build app. USER is: "${USER}"\n\n===============\n" \
|
||||
RUN printf "================ Start build base service. with USER: ${USER} ===============" \
|
||||
&& apt-get update \
|
||||
&& apt-get install --no-install-recommends -y \
|
||||
bash \
|
||||
build-essential \
|
||||
curl \
|
||||
iputils-ping \
|
||||
gettext \
|
||||
git \
|
||||
libpq-dev \
|
||||
libffi-dev \
|
||||
cmake \
|
||||
libcurl4-openssl-dev \
|
||||
bash \
|
||||
curl \
|
||||
git \
|
||||
nano \
|
||||
&& pip install --upgrade pip \
|
||||
# Installing `poetry` package manager:
|
||||
&& pip install poetry==$POETRY_VERSION wheel \
|
||||
# Cleaning cache:
|
||||
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
|
||||
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
|
||||
WORKDIR /app
|
||||
WORKDIR /app/
|
||||
|
||||
RUN if [ "$USER" != "root" ]; then \
|
||||
mkdir /home/"$USER" \
|
||||
@@ -45,22 +33,53 @@ RUN if [ "$USER" != "root" ]; then \
|
||||
&& chown "$USER":"$USER" -R /home/"$USER"; \
|
||||
fi
|
||||
|
||||
COPY --chown="$USER":"$USER" ./poetry.lock ./pyproject.toml /app/
|
||||
COPY --chown=${USER}:${USER} ../poetry.lock ../pyproject.toml /app/
|
||||
|
||||
# Installing requirements
|
||||
RUN poetry --version \
|
||||
&& poetry run pip install -U pip \
|
||||
&& poetry install \
|
||||
$(if [ "$USER" != 'root' ]; then echo '--only main'; fi) \
|
||||
--no-interaction --no-ansi \
|
||||
# Cleaning poetry installation's cache for production:
|
||||
&& if [ "$USER" != 'root' ]; then rm -rf "$POETRY_CACHE_DIR"; fi
|
||||
RUN pip install --upgrade pip && pip install poetry==$POETRY_VERSION
|
||||
RUN poetry config virtualenvs.in-project true && \
|
||||
poetry config virtualenvs.create true && \
|
||||
poetry install --only main --no-interaction --no-ansi && \
|
||||
rm -rf $POETRY_CACHE_DIR
|
||||
|
||||
COPY --chown="$USER":"$USER" ./app /app/
|
||||
COPY ./scripts/start-bot.sh .
|
||||
|
||||
#==================== bot-service =================================
|
||||
FROM compile-image as bot-service
|
||||
|
||||
RUN printf "================ Start build bot-service. with USER: ${USER} ==============="
|
||||
|
||||
WORKDIR /app/
|
||||
|
||||
# Copying bot service
|
||||
COPY --chown=${USER}:${USER} ../bot_microservice /app/
|
||||
|
||||
COPY ./scripts/start-bot.sh /app/
|
||||
RUN chmod +x ./start-bot.sh
|
||||
|
||||
USER "$USER"
|
||||
COPY --from=compile-image /app/.venv /app/.venv
|
||||
|
||||
# Copying actuall application
|
||||
COPY --chown="$USER":"$USER" . /app/
|
||||
USER ${USER}
|
||||
|
||||
ENV PATH="/app/.venv/bin:$PATH"
|
||||
|
||||
|
||||
#===================== chat-service ================================
|
||||
FROM compile-image as chat-service
|
||||
|
||||
RUN printf "================ Start build chat-service. with USER: ${USER} ==============="
|
||||
|
||||
WORKDIR /app/
|
||||
|
||||
# Copying bot service
|
||||
COPY --chown=${USER}:${USER} ../chat_gpt_microservice /app/
|
||||
|
||||
COPY ./scripts/start-chat.sh /app/
|
||||
RUN chmod +x ./start-chat.sh
|
||||
|
||||
COPY --from=compile-image /app/.venv /app/.venv
|
||||
ENV PATH="/app/.venv/bin:$PATH"
|
||||
|
||||
USER ${USER}
|
||||
|
||||
RUN chmod -R 777 translations
|
||||
|
||||
CMD ["bash", "start-chat.sh"]
|
||||
Reference in New Issue
Block a user