Skip to content
This repository has been archived by the owner on Jul 2, 2023. It is now read-only.

Commit

Permalink
enable daily build
Browse files Browse the repository at this point in the history
  • Loading branch information
Bill Wang committed Aug 25, 2019
1 parent 140a31e commit 27f8a09
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
report
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
sudo: required

services:
- docker

script:
- bash ./build.sh
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM alpine
FROM alpine:edge

RUN apk --no-cache add socat
ARG VERSION=1.7.3.2

RUN apk --no-cache add socat=${VERSION}

ENTRYPOINT ["socat"]
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ Run socat command in alpine container

[![DockerHub Badge](http:https://dockeri.co/image/alpine/socat)](https://hub.docker.com/r/alpine/socat/)

Auto-trigger docker build for [socat](https://pkgs.alpinelinux.org/package/edge/main/x86/socat) when new version is released.

### Repo:

https://github.com/alpine-docker/socat

### Daily build logs:

https://travis-ci.org/alpine-docker/socat

### Docker iamge tags:

https://hub.docker.com/r/alpine/socat/tags/

## Use Case: Expose a tcp socket for accessing docker API on macOS

Expand Down Expand Up @@ -43,3 +56,10 @@ $ docker run \
* To run the container in the background insert ```--detach``` after ```docker run```.
* To automatically start the container on restart insert ```--restart always``` after ```docker run```.
* To automatically start the container unless it has been stopped explicitly insert ```--restart unless-stopped``` after ```docker run```.

# The Processes to build this image

* Enable Travis CI cronjob on this repo to run build daily on master branch
* Check if there are new tags/releases announced via Alpine package url (https://hub.docker.com/r/alpine/socat/)
* Match the exist docker image tags via Hub.docker.io REST API
* If not matched, build the image with latest version as tag and push to hub.docker.com
45 changes: 45 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env bash

# Prerequisite
# Make sure you set secret enviroment variables in Travis CI
# DOCKER_USERNAME
# DOCKER_PASSWORD

set -ex

Usage() {
echo "$0 [rebuild]"
}

image="alpine/socat"

#curl -s https://pkgs.alpinelinux.org/package/edge/main/x86/socat |tee output
#docker run -i --rm -v output:/apps/output alpine/html2text -nobs < output > report

curl -s https://pkgs.alpinelinux.org/package/edge/main/x86/socat | docker run -i --rm -v output:/apps/output alpine/html2text -nobs > report

latest=$(awk '/^Version/ {print $2}' report)

sum=0
echo "Lastest release is: ${latest}"

tags=`curl -s https://hub.docker.com/v2/repositories/${image}/tags/ |jq -r .results[].name`

for tag in ${tags}
do
if [ ${tag} == ${latest} ];then
sum=$((sum+1))
fi
done

if [[ ( $sum -ne 1 ) || ( $1 == "rebuild" ) ]];then
docker build --build-arg VERSION=${latest} --no-cache -t ${image}:${latest} .
docker tag ${image}:${latest} ${image}:latest

if [[ "$TRAVIS_BRANCH" == "master" ]]; then
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
docker push ${image}:${latest}
docker push ${image}:latest
fi

fi

0 comments on commit 27f8a09

Please sign in to comment.