Skip to content

Commit 26dd303

Browse files
author
Anze
committed
Merge branch 'master' of gitlab.com:grafolean/grafolean-collector-ping
2 parents 71221aa + 255652f commit 26dd303

File tree

6 files changed

+83
-25
lines changed

6 files changed

+83
-25
lines changed

.gitlab-ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ deploy_to_docker_hub:
3333
- docker build -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG" -t "$CI_REGISTRY_IMAGE:latest" --build-arg VERSION=$CI_COMMIT_TAG --build-arg VCS_REF=$CI_COMMIT_SHA --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') .
3434
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG"
3535
- docker push "$CI_REGISTRY_IMAGE:latest"
36-
- docker rmi grafolean/grafolean-worker-ping:$CI_COMMIT_TAG
37-
- docker rmi grafolean/grafolean-worker-ping:latest
36+
- docker rmi grafolean/grafolean-collector-ping:$CI_COMMIT_TAG
37+
- docker rmi grafolean/grafolean-collector-ping:latest
3838

Dockerfile

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,36 @@
1-
FROM python:3.6-alpine
1+
FROM python:3.6-slim-stretch as python-requirements
2+
COPY ./Pipfile ./Pipfile.lock /pingcollector/
3+
WORKDIR /pingcollector
4+
RUN \
5+
pip install pipenv && \
6+
pipenv lock -r > /requirements.txt
27

3-
COPY requirements.txt grafolean-worker-ping.py /opt/
4-
RUN pip install -r /opt/requirements.txt
5-
RUN echo -e "* * * * * source /etc/environment; export BACKEND_URL BOT_TOKEN; python /opt/grafolean-worker-ping.py > /proc/1/fd/1 2> /proc/1/fd/2\n" > /etc/crontabs/root
8+
FROM python:3.6-slim-stretch as build-backend
9+
COPY ./ /pingcollector/
10+
WORKDIR /pingcollector
11+
RUN \
12+
find ./ ! -name '*.py' -type f -exec rm '{}' ';' && \
13+
rm -rf tests/ .vscode/ .pytest_cache/ __pycache__/ && \
14+
python3.6 -m compileall -b ./ && \
15+
find ./ -name '*.py' -exec rm '{}' ';'
616

7-
# https://stackoverflow.com/a/47960145/593487
8-
ENTRYPOINT ["crond", "-f", "-d", "8"]
17+
18+
FROM python:3.6-slim-stretch
19+
ARG VERSION
20+
ARG VCS_REF
21+
ARG BUILD_DATE
22+
LABEL org.label-schema.vendor="Grafolean" \
23+
org.label-schema.url="https://grafolean.com/" \
24+
org.label-schema.name="Grafolean Ping Collector" \
25+
org.label-schema.description="Ping collector for Grafolean" \
26+
org.label-schema.version=$VERSION \
27+
org.label-schema.vcs-url="https://gitlab.com/grafolean/grafolean-collector-ping/" \
28+
org.label-schema.vcs-ref=$VCS_REF \
29+
org.label-schema.build-date=$BUILD_DATE \
30+
org.label-schema.docker.schema-version="1.0"
31+
COPY --from=python-requirements /requirements.txt /requirements.txt
32+
RUN pip install --no-cache-dir -r /requirements.txt
33+
COPY --from=build-backend /pingcollector/ /pingcollector/
34+
WORKDIR /pingcollector
35+
USER root
36+
CMD ["python", "-m", "pingcollector"]

Pipfile.lock

Lines changed: 32 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docker-compose.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,22 @@ services:
55
# BACKEND_URL=... # backend API base url (the part before "/api/...")
66
# BOT_TOKEN=... # bot token
77

8-
grafolean-worker-ping:
8+
grafolean-collector-ping:
99
# If you wish to load an explicit version, change the next line. For example:
10-
# image: grafolean/grafolean-worker-ping:v1.0.0
11-
image: grafolean/grafolean-worker-ping
10+
# image: grafolean/grafolean-collector-ping:v1.0.0
11+
image: grafolean/grafolean-collector-ping
12+
container_name: grafolean-collector-ping
1213
build:
1314
context: .
1415
dockerfile: Dockerfile
15-
volumes:
16-
- .env:/etc/environment
16+
environment:
17+
# Backend url must be set to the address of the Grafolean backend, for example this uses Grafolean hosted service:
18+
# - BACKEND_URL=https://grafolean.com/api
19+
# IMPORTANT: '127.0.0.1' and 'localhost' are _never_ correct addresses for Grafolean backend, because they translate
20+
# to container, not host.
21+
- BACKEND_URL=${BACKEND_URL}
22+
# To use PING Collector, a bot with the protocol "ping" must be added via user interface, then the token needs to be copied here:
23+
- BOT_TOKEN=${BOT_TOKEN}
24+
# Interval between fetching information about jobs:
25+
- JOBS_REFRESH_INTERVAL=${JOBS_REFRESH_INTERVAL:-60}
26+
restart: always
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from colors import color
55
import logging
66
from multiping import multi_ping
7-
from pytz import utc
87
import requests
98
import socket
109
import dotenv

requirements.txt

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)