mirror of
https://github.com/luzifer-docker/teamspeak3.git
synced 2024-12-20 14:41:17 +00:00
Add automated update script and more tests
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
8822d75848
commit
a179f77777
5 changed files with 108 additions and 14 deletions
13
.travis.yml
13
.travis.yml
|
@ -1,16 +1,5 @@
|
||||||
language: bash
|
language: bash
|
||||||
services: docker
|
services: docker
|
||||||
|
|
||||||
install:
|
|
||||||
- git clone https://github.com/docker-library/official-images.git ~/official-images
|
|
||||||
|
|
||||||
before_script:
|
|
||||||
- env | sort
|
|
||||||
- image="luzifer/teamspeak3:latest"
|
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- travis_retry docker build -t "$image" .
|
- make test
|
||||||
- ~/official-images/test/run.sh "$image"
|
|
||||||
|
|
||||||
after_script:
|
|
||||||
- docker images
|
|
||||||
|
|
|
@ -6,8 +6,8 @@ LABEL maintainer Knut Ahlers <knut@ahlers.me>
|
||||||
ENV TEAMSPEAK_VERSION=3.5.0 \
|
ENV TEAMSPEAK_VERSION=3.5.0 \
|
||||||
TEAMSPEAK_SHA256=9bd56e115afea19351a6238a670dc93e365fe88f8a6c28b5b542ef6ae2ca677e
|
TEAMSPEAK_SHA256=9bd56e115afea19351a6238a670dc93e365fe88f8a6c28b5b542ef6ae2ca677e
|
||||||
|
|
||||||
RUN set -ex \
|
SHELL ["/bin/bash", "-exo", "pipefail", "-c"]
|
||||||
&& apt-get update \
|
RUN apt-get update \
|
||||||
&& apt-get install -y curl bzip2 ca-certificates --no-install-recommends \
|
&& apt-get install -y curl bzip2 ca-certificates --no-install-recommends \
|
||||||
&& curl -sSfLo teamspeak3-server_linux-amd64.tar.bz2 \
|
&& curl -sSfLo teamspeak3-server_linux-amd64.tar.bz2 \
|
||||||
"http://dl.4players.de/ts/releases/${TEAMSPEAK_VERSION}/teamspeak3-server_linux_amd64-${TEAMSPEAK_VERSION}.tar.bz2" \
|
"http://dl.4players.de/ts/releases/${TEAMSPEAK_VERSION}/teamspeak3-server_linux_amd64-${TEAMSPEAK_VERSION}.tar.bz2" \
|
||||||
|
|
30
Makefile
Normal file
30
Makefile
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
default: test
|
||||||
|
|
||||||
|
build:
|
||||||
|
# Build image
|
||||||
|
docker build -t "luzifer/teamspeak3:latest" .
|
||||||
|
|
||||||
|
hadolint:
|
||||||
|
# Execute hadolint on Dockerfile
|
||||||
|
docker run --rm -i \
|
||||||
|
-v "$(CURDIR):$(CURDIR)" \
|
||||||
|
-w "$(CURDIR)" \
|
||||||
|
hadolint/hadolint \
|
||||||
|
hadolint --ignore=DL3008 Dockerfile
|
||||||
|
|
||||||
|
official-tests: build
|
||||||
|
# Execute official docker-image tests
|
||||||
|
git clone https://github.com/docker-library/official-images.git /tmp/official-images
|
||||||
|
/tmp/official-images/test/run.sh "luzifer/teamspeak3:latest"
|
||||||
|
rm -rf /tmp/official-images
|
||||||
|
|
||||||
|
test: hadolint official-tests
|
||||||
|
|
||||||
|
update: teamspeaki_version_update test
|
||||||
|
|
||||||
|
teamspeaki_version_update:
|
||||||
|
docker run --rm -i \
|
||||||
|
-v "$(CURDIR):$(CURDIR)" \
|
||||||
|
-w "$(CURDIR)" \
|
||||||
|
python:3-alpine \
|
||||||
|
sh -c "pip install -r patcher/requirements.txt && python3 patcher/index.py"
|
73
patcher/index.py
Normal file
73
patcher/index.py
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from bs4 import BeautifulSoup
|
||||||
|
import re
|
||||||
|
import requests
|
||||||
|
|
||||||
|
|
||||||
|
def get_page():
|
||||||
|
return BeautifulSoup(
|
||||||
|
requests.get('https://www.teamspeak.com/en/downloads/').text,
|
||||||
|
'html.parser',
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def filter_file(tag):
|
||||||
|
# We are searching for div.file
|
||||||
|
if not tag.has_attr('class') or 'file' not in tag['class']:
|
||||||
|
return False
|
||||||
|
|
||||||
|
# We only care for the 64-bit server version
|
||||||
|
if 'Server 64-bit' not in tag.find('h3').text:
|
||||||
|
return False
|
||||||
|
|
||||||
|
# We only care for the linux version
|
||||||
|
if 'linux_amd64' not in tag.find('a')['href']:
|
||||||
|
return False
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def latest_version():
|
||||||
|
page = get_page()
|
||||||
|
fd = page.body.find(filter_file)
|
||||||
|
|
||||||
|
version = fd.find('span', 'version').text.strip()
|
||||||
|
checksum = fd.find('p', 'checksum').text.split(' ')[1]
|
||||||
|
|
||||||
|
return (version, checksum)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
(version, checksum) = latest_version()
|
||||||
|
|
||||||
|
lines = []
|
||||||
|
|
||||||
|
with open('Dockerfile', 'r') as f:
|
||||||
|
for line in f:
|
||||||
|
lines.append(substitute(line, {
|
||||||
|
'TEAMSPEAK_VERSION': version,
|
||||||
|
'TEAMSPEAK_SHA256': checksum,
|
||||||
|
}).strip('\n'))
|
||||||
|
|
||||||
|
lines.append('')
|
||||||
|
|
||||||
|
with open('Dockerfile', 'w') as f:
|
||||||
|
f.write('\n'.join(lines))
|
||||||
|
|
||||||
|
|
||||||
|
def substitute(line, attrs):
|
||||||
|
for k, v in attrs.items():
|
||||||
|
if k not in line:
|
||||||
|
continue
|
||||||
|
line = re.sub(
|
||||||
|
r'({})=[^ ]+'.format(k),
|
||||||
|
r'\1={}'.format(v),
|
||||||
|
line
|
||||||
|
)
|
||||||
|
return line
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
2
patcher/requirements.txt
Normal file
2
patcher/requirements.txt
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
beautifulsoup4==4.6.3
|
||||||
|
requests==2.20.0
|
Loading…
Reference in a new issue