Skip to content

Commit

Permalink
chore: updated dockerfile & docker-compose
Browse files Browse the repository at this point in the history
  • Loading branch information
akimrx committed Nov 8, 2023
1 parent 26ccdce commit 5170d2e
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 26 deletions.
15 changes: 15 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,18 @@ venv*
.idea
tests
.git


# Project

.env
.env.example
data-migrate.sh
Makefile
docker-compose.*
state.*
TODO.*
migrate
examples
docs
clickhouse
38 changes: 20 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
FROM python:3.10-slim as builder

WORKDIR /usr/src/app
COPY ./requirements.txt ./
RUN apt-get update && apt-get install -y --no-install-recommends build-essential \
&& pip install --no-cache-dir --prefix=/usr/src/app/dist -r requirements.txt \
&& apt-get purge -y --auto-remove build-essential \
&& rm -rf /var/lib/apt/lists/*


FROM python:3.10-slim
LABEL maintainer="[email protected]"
LABEL name="tools/tracker-exporter"

ENV DEBIAN_FRONTEND noninteractive
ENV TZ=Europe/Moscow
COPY --from=builder /usr/src/app/dist /usr/local
WORKDIR /opt/exporter

# Prepare environment & packages
RUN apt-get -qq update && \
apt-get install -yqq tzdata && \
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && \
COPY . .
RUN pip install --no-cache-dir .
RUN rm -rf /opt/exporter

ENV TZ=Europe/Moscow
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && \
echo $TZ > /etc/timezone && \
dpkg-reconfigure -f noninteractive tzdata && \
apt-get clean && \
apt-get update && \
apt-get install -y --no-install-recommends tzdata && \
rm -rf /var/lib/apt/lists/*

# Configure exporter
RUN mkdir -p /opt/exporter
COPY ./requirements.txt requirements.txt
COPY . /opt/exporter/

# Install exporter
WORKDIR /opt/exporter
RUN python3 setup.py install

CMD ["tracker-exporter"]
12 changes: 7 additions & 5 deletions examples/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3.1'

services:
clickhouse:
image: clickhouse/clickhouse-server:23.3
image: clickhouse/clickhouse-server:23.8
container_name: clickhouse
hostname: clickhouse
restart: unless-stopped
Expand All @@ -18,16 +18,18 @@ services:
hostname: tracker-exporter
restart: unless-stopped
environment:
EXPORTER_TRACKER__TOKEN: your_token
EXPORTER_TRACKER__CLOUD_ORG_ID: your_org_id
EXPORTER_CHANGELOG_EXPORT_ENABLED: "false"
EXPORTER_TRACKER__TOKEN: ${TRACKER_TOKEN}
EXPORTER_TRACKER__CLOUD_ORG_ID: ${TRACKER_ORG_ID}
EXPORTER_CLICKHOUSE__HOST: clickhouse
EXPORTER_CLICKHOUSE__PORT: 8123
EXPORTER_CHANGELOG_EXPORT_ENABLED: "true"
EXPORTER_CLICKHOUSE__ENABLE_UPLOAD: "true"
EXPORTER_STATEFUL: "true"
EXPORTER_STATEFUL_INITIAL_RANGE: "1d"
EXPORTER_STATE__STORAGE: jsonfile
EXPORTER_STATE__JSONFILE_STRATEGY: local
EXPORTER_STATE__JSONFILE_PATH: /opt/exporter/state.json
volumes:
- "./:/opt/exporter"
- "./exporter:/opt/exporter:rw"
depends_on:
- clickhouse
12 changes: 9 additions & 3 deletions tracker_exporter/etl.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,16 @@ def run(
else:
if all((stateful, self.state, possible_new_state)):
self.state.set(self.state_key, possible_new_state)
else:
logger.info(
"The state snapshot will not be saved. Not all conditions are met "
f"{stateful=} {self.state=} {possible_new_state=}"
)
monitoring.send_gauge_metric("last_update_timestamp", value=int(time.time()))
finally:
monitoring.send_gauge_metric("etl_upload_status", value=1 if success else 2)
else:
print(issues)
print(metrics)
print(changelogs)
logger.info("The state snapshot will not be saved because the upload to the storage is disabled.")
print(issues if issues else "Empty issues")
print(metrics if metrics else "Empty metrics")
print(changelogs if changelogs else "Empty changelogs")

0 comments on commit 5170d2e

Please sign in to comment.