Skip to content

Commit 9e86909

Browse files
author
Henrik Adamski
committed
ITADMIN-2378 - Remove netcat and use simple python solution
1 parent b1e606d commit 9e86909

File tree

8 files changed

+91
-30
lines changed

8 files changed

+91
-30
lines changed

.github/workflows/nightly.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
name: nightly
2-
2+
33
on:
44
schedule:
5-
- cron: 0 0 * * *
6-
5+
- cron: 0 0 * * 1
6+
77
jobs:
88
nightly:
99
timeout-minutes: 30
1010
runs-on: ubuntu-latest
11-
11+
1212
steps:
1313
- name: checkout
14-
uses: actions/checkout@v1
15-
14+
uses: actions/checkout@v2
15+
1616
- name: get-project-version
1717
id: get_project_version
1818
uses: avides/actions-project-version-check@v1
1919
with:
2020
token: ${{ secrets.GITHUB_TOKEN }}
2121
file-to-check: version.txt
2222
only-return-version: true
23-
23+
2424
- name: build-image
2525
env:
2626
PROJECT_VERSION: ${{ steps.get_project_version.outputs.version }}

.github/workflows/release.yml

+27-7
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
name: release
2-
2+
33
on:
44
push:
55
branches:
6-
- master
7-
6+
- ITADMIN-2378
7+
88
jobs:
99
release:
1010
timeout-minutes: 30
1111
env:
1212
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1313
runs-on: ubuntu-latest
14-
14+
1515
steps:
1616
- name: checkout
17-
uses: actions/checkout@v1
18-
17+
uses: actions/checkout@v2
18+
1919
- name: get-project-version
2020
id: get_project_version
2121
uses: avides/actions-project-version-check@v1
2222
with:
2323
token: ${{ secrets.GITHUB_TOKEN }}
2424
file-to-check: version.txt
2525
only-return-version: true
26-
26+
2727
- name: push-image
2828
env:
2929
PROJECT_VERSION: ${{ steps.get_project_version.outputs.version }}
@@ -34,3 +34,23 @@ jobs:
3434
if [[ "$PROJECT_VERSION" != *"SNAPSHOT"* || "$PROJECT_VERSION" != *"RC"* ]]; then
3535
docker push ${{ secrets.DOCKER_REGISTRY }}/${GITHUB_REPOSITORY}:latest
3636
fi
37+
38+
- name: setup-github-release
39+
id: setup_github_release
40+
env:
41+
PROJECT_VERSION: ${{ steps.get_project_version.outputs.version }}
42+
run: |
43+
echo ::set-output name=gitcommitmessage::$(git log --no-merges -1 --oneline)
44+
if [[ "$PROJECT_VERSION" == *"SNAPSHOT"* || "$PROJECT_VERSION" == *"RC"* ]]; then
45+
echo ::set-output name=isprerelease::true
46+
fi
47+
48+
- name: github-release
49+
uses: actions/create-release@v1
50+
env:
51+
GITHUB_TOKEN: ${{ secrets.GPR_TOKEN }}
52+
with:
53+
tag_name: ${{ steps.get_project_version.outputs.version }}
54+
release_name: ${{ steps.get_project_version.outputs.version }}
55+
body: ${{ steps.setup_github_release.outputs.gitcommitmessage }}
56+
prerelease: ${{ steps.setup_github_release.outputs.isprerelease }}

.github/workflows/review.yml

+33-7
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,52 @@
11
name: review
2-
2+
33
on:
44
pull_request:
55
types: [opened, synchronize]
6-
6+
77
jobs:
88
review:
99
timeout-minutes: 30
1010
runs-on: ubuntu-latest
11-
11+
1212
steps:
1313
- name: checkout
14-
uses: actions/checkout@v1
15-
14+
uses: actions/checkout@v2
15+
with:
16+
ref: ${{ github.head_ref }}
17+
token: ${{ secrets.GPR_TOKEN }}
18+
fetch-depth: ''
19+
20+
- name: post-checkout
21+
run: git fetch --prune --unshallow
22+
23+
- name: action-configuration-autoupdate
24+
id: actions_action_configuration_autoupdate
25+
uses: avides/actions-action-configuration-autoupdate@v1
26+
with:
27+
token: ${{ secrets.GPR_TOKEN }}
28+
actions-configuration-files: plain-docker-application/nightly.yml,plain-docker-application/release.yml,plain-docker-application/review.yml
29+
source-repository: ${{ secrets.ACTIONS_CONFIG_AUTOUPDATE_REPO }}
30+
31+
- uses: stefanzweifel/git-auto-commit-action@v4
32+
with:
33+
file_pattern: .github/workflows/*.yml
34+
commit_user_name: ${{ secrets.ACTIONS_CONFIG_AUTOUPDATE_USER }}
35+
commit_user_email: ${{ secrets.ACTIONS_CONFIG_AUTOUPDATE_EMAIL }}
36+
commit_author: ${{ secrets.ACTIONS_CONFIG_AUTOUPDATE_AUTHOR }}
37+
commit_message: Update GitHub Action configuration
38+
39+
- name: action-configuration-updated
40+
if: ${{ steps.actions_action_configuration_autoupdate.outputs.updated }}
41+
run: exit 1;
42+
1643
- name: project-version-check
1744
id: project_version_check
1845
uses: avides/actions-project-version-check@v1
1946
with:
2047
token: ${{ secrets.GITHUB_TOKEN }}
2148
file-to-check: version.txt
22-
additional-files-to-check: README.md
23-
49+
2450
- name: build-image
2551
env:
2652
PROJECT_VERSION: ${{ steps.project_version_check.outputs.version }}

Dockerfile

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ FROM ubuntu:18.04
44
## Defaults
55
WORKDIR /root/
66

7-
## Install AWSCli & MySQL
8-
RUN apt-get update && apt-get install -y python python-pip mysql-client-5.7 && pip install awscli
7+
## Install Python 3, AWSCli, MySQL and Python simple HTTP Server
8+
RUN apt update && apt install -y python3 python3-pip mysql-client-5.7 && pip3 install awscli && pip3 install simple_http_server
99

10-
## Install netcat
11-
RUN apt-get install -y netcat
10+
## Setup HTTP Server
11+
COPY webserver.py /root/webserver.py
1212

1313
## Configure Crontab
1414
RUN apt-get install cron

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ docker run \
2828
--env MYSQL_BACKUP_USER="root" \
2929
--env MYSQL_BACKUP_PASS="MYSQL_BACKUP_PASS" \
3030
-p 9300:9300 \
31-
avides/mysql-s3-backup:2.5.3
31+
avides/mysql-s3-backup:2.6.0-SNAPSHOT
3232
```
3333

3434
### Build & Test
@@ -46,7 +46,7 @@ docker run \
4646
--env S3_ACCESS_KEY="AWS_ACCESS_KEY" \
4747
--env S3_SECRET_KEY="AWS_SECRET_KEY" \
4848
--env S3_REGION="AWS_REGION" \
49-
--env MYSQL_HOST_ALIAS="MYSQL_HOST_ALIAS (default: ${MYSQL_HOST}" \
49+
--env MYSQL_HOST_ALIAS="MYSQL_HOST_ALIAS (default: ${MYSQL_HOST})" \
5050
--env MYSQL_HOST="MYSQL_HOST" \
5151
--env MYSQL_PORT="MYSQL_PORT (default: 3306)" \
5252
--env MYSQL_BACKUP_USER="root" \

entrypoint.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ printenv | grep -E 'PATH|S3_BUCKET_NAME|S3_ACCESS_KEY|S3_SECRET_KEY|S3_REGION|MY
33
sed -i -e "s/CRON_EXPR/${CRON_EXPR}/g" /etc/cron.d/backup-cron
44

55
## Start metrics endpoint
6-
mkdir /var/log/netcat
7-
while true; do { printf 'HTTP/1.0 200 OK\r\nContent-Length: %d\r\n\r\n' "$(wc -c < /root/metrics.txt)"; cat /root/metrics.txt; } | nc -l -p 9300 >> /var/log/netcat/netcat.log; done &
6+
mkdir /var/log/webserver
7+
python3 /root/webserver.py > /var/log/webserver/webserver.log &
88

99
## Starting
1010
cron && touch /var/log/backup-cron/cron.log && tail -f /var/log/backup-cron/cron.log

version.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.5.3
1+
2.6.0-SNAPSHOT

webserver.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import simple_http_server.server as server
2+
3+
from simple_http_server import request_map
4+
from pathlib import Path
5+
6+
@request_map("/metrics")
7+
def metrics():
8+
return Path('/root/metrics.txt').read_text()
9+
10+
def main(*args):
11+
print("Server starting...")
12+
server.start(port=9300)
13+
print("Server started!")
14+
15+
main()

0 commit comments

Comments
 (0)