Skip to content

Commit

Permalink
DipDup version
Browse files Browse the repository at this point in the history
  • Loading branch information
igorsereda committed Dec 21, 2024
1 parent d6c482c commit c664fca
Show file tree
Hide file tree
Showing 7 changed files with 2,995 additions and 6,015 deletions.
86 changes: 39 additions & 47 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,81 +1,73 @@
ARG PYTHON_VERSION=3.12
ARG PYTHON_VERSION=3.12-slim-bookworm
ARG SOURCE_DIR=bridge_indexer
ARG POETRY_PATH=/opt/poetry
ARG VENV_PATH=/opt/venv
ARG APP_PATH=/opt/app
ARG APP_USER=dipdup

FROM python:${PYTHON_VERSION}-slim AS builder-base

ARG VENV_PATH
ARG POETRY_PATH
ENV PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
POETRY_HOME="$POETRY_PATH" \
VIRTUAL_ENV=$VENV_PATH \
PATH="$POETRY_PATH/bin:$VENV_PATH/bin:$PATH"

RUN apt-get update \
&& apt-get install --no-install-recommends -y \
# deps for installing poetry
curl \
FROM python:${PYTHON_VERSION} AS builder-base

SHELL ["/bin/bash", "-exc"]

RUN apt-get update -qy \
&& apt-get install --no-install-recommends --no-install-suggests -qyy \
# deps for building python deps
build-essential \
# pytezos deps
libsodium-dev libgmp-dev pkg-config \
\
# install poetry
&& curl -sSL https://install.python-poetry.org | python - \
\
# configure poetry & make a virtualenv ahead of time since we only need one
&& python -m venv $VENV_PATH \
&& poetry config virtualenvs.create false \
\
# cleanup
# cleanup \
&& apt-get clean \
&& rm -rf /tmp/* \
&& rm -rf /var/tmp/* \
&& rm -rf /root/.cache \
&& rm -rf `find /usr/local/lib $POETRY_PATH/venv/lib $VENV_PATH/lib -name __pycache__` \
&& rm -rf /var/lib/apt/lists/*

ARG APP_PATH
ENV UV_PROJECT_ENVIRONMENT=$APP_PATH


FROM builder-base AS builder-production

COPY ["poetry.lock", "pyproject.toml", "./"]
RUN --mount=from=ghcr.io/astral-sh/uv,source=/uv,target=/bin/uv \
--mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --frozen --exact --no-install-project --no-editable --no-dev --no-installer-metadata

RUN poetry install --only main --sync --no-root --no-interaction --no-ansi -vvv \
&& rm -rf /tmp \
&& rm -rf /root/.cache \
&& rm -rf $VIRTUAL_ENV/src \
&& rm -rf `find $VIRTUAL_ENV/lib -name __pycache__`

FROM python:${PYTHON_VERSION} AS runtime-base

FROM python:${PYTHON_VERSION}-slim AS runtime-base
SHELL ["/bin/bash", "-exc"]

ARG VENV_PATH
ENV PATH="$VENV_PATH/bin:$PATH"
RUN apt-get update -qy \
&& apt-get install --no-install-recommends --no-install-suggests -qyy \
# pytezos deps
libsodium-dev libgmp-dev pkg-config \
\
# cleanup \
&& apt-get clean \
&& rm -rf /tmp/* \
&& rm -rf /var/tmp/* \
&& rm -rf /root/.cache \
&& rm -rf /var/lib/apt/lists/*

ARG APP_PATH
ENV PATH=$APP_PATH/bin:$PATH

WORKDIR $APP_PATH

ARG APP_USER
RUN useradd -ms /bin/bash $APP_USER

FROM runtime-base AS runtime

RUN apt-get update \
&& apt-get install --no-install-recommends -y \
libsodium-dev libgmp-dev pkg-config \
# cleanup
&& rm -rf /tmp/* \
&& rm -rf /root/.cache \
&& rm -rf /var/lib/apt/lists/*

ARG VENV_PATH
COPY --from=builder-production ["$VENV_PATH", "$VENV_PATH"]
FROM runtime-base AS runtime

ARG APP_USER
ARG APP_PATH
COPY --from=builder-production --chown=$APP_USER ["$APP_PATH", "$APP_PATH"]

USER $APP_USER
ARG SOURCE_DIR
ENV DIPDUP_PACKAGE_PATH=$APP_PATH/$SOURCE_DIR
COPY --chown=$APP_USER $SOURCE_DIR ./$SOURCE_DIR

ENTRYPOINT ["dipdup"]
Expand Down
2 changes: 1 addition & 1 deletion bridge_indexer/handlers/etherlink/on_deposit.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async def on_deposit(
ctx: HandlerContext,
event: EvmEvent[DepositPayload],
) -> None:
ctx.logger.info(f'Etherlink Deposit Event found: 0x{event.data.transaction_hash}')
ctx.logger.info(f'Etherlink Deposit Event found: {event.data.transaction_hash}')

try:
await _validate_ticket(event.payload.ticket_hash)
Expand Down
2 changes: 1 addition & 1 deletion bridge_indexer/handlers/etherlink/on_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async def on_transfer(
ctx: HandlerContext,
event: EvmEvent[TransferPayload],
) -> None:
ctx.logger.info(f'Etherlink Token Transfer Event found: 0x{event.data.transaction_hash}')
ctx.logger.info(f'Etherlink Token Transfer Event found: {event.data.transaction_hash}')

amount = event.payload.value
if not amount:
Expand Down
2 changes: 1 addition & 1 deletion bridge_indexer/handlers/rollup_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ async def _handle_outbox_level(self, outbox_level):
try:
parameters_hash = await OutboxParametersHash(outbox_message).from_outbox_message(self._ticket_service)
except ValueError as e:
self._logger.warning(f'Skip hashing outbox message. {str(e)}')
self._logger.warning(f'Skip hashing outbox message. {e!s}')
continue

self._create_outbox_batch.append(
Expand Down
Loading

0 comments on commit c664fca

Please sign in to comment.