Skip to content

Commit

Permalink
Add package data image.
Browse files Browse the repository at this point in the history
  • Loading branch information
dnephin committed Jul 30, 2015
1 parent 61ac6a4 commit 0d0cd58
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
repo/
packages/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.*.swp
packages/
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

#
# Run lighttpd to serve apk packages
#
FROM alpine:3.2
MAINTAINER Daniel Nephin <dnephin@gmail.com>

Expand Down
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ BUILD_ID ?= ${USER}
.PHONY: build
build:
docker build -t alpine-package-mirror:${BUILD_ID} .
@echo Image tag: alpine-package-mirror:${BUILD_ID}

.PHONY: build_repo
build_repo:
docker build -t alpine-package-data:${BUILD_ID} repo/
@echo Image tag: alpine-package-data:${BUILD_ID}
16 changes: 14 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,17 @@ To build the image:
make build


To run a private package registry add your packages to
``/var/www/localhost/htdocs/alpine/``.
To run the mirror, provide the package directory tree as a volume from the host, or
another container. In this example the host directory `./repo` contains the
packages:

docker run -ti \
-v $PWD/repo:/var/www/localhost/htdocs/alpine/ \
alpine-package-mirror:$USER


To run the mirror with a companion container which takes care of pulling updates
with rsync, you can use the provided ``docker-compose.yml``:

BUILD_ID=latest make build build_repo
docker-compose up -d
7 changes: 7 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

mirror:
image: alpine-package-mirror:latest
volumes_from: ['data']

data:
image: alpine-package-data:latest
15 changes: 15 additions & 0 deletions repo/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#
# Run rsync to periodically update package data, and share it as a volume
#
FROM alpine:3.2
MAINTAINER Daniel Nephin <dnephin@gmail.com>

RUN apk update && apk add rsync
RUN mkdir -p /var/www/localhost/htdocs/alpine

ADD rsync.sh /etc/periodic/hourly/package-rsync
RUN echo "echo doing stuff" > /etc/periodic/15min/doit
RUN chmod +x /etc/periodic/15min/doit

VOLUME /var/www/localhost/htdocs/alpine
CMD ["crond", "-f", "-d", "6"]
22 changes: 22 additions & 0 deletions repo/rsync.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh

set -eu

# make sure we never run 2 rsync at the same time
lockfile="/tmp/alpine-mirror.lock"
if [ -z "$flock" ] ; then
exec env flock=1 flock -n $lockfile $0 "$@"
fi

src=rsync://rsync.alpinelinux.org/alpine/
dest=/var/www/localhost/htdocs/alpine/

/usr/bin/rsync -prua \
--exclude "v2.[1-9]" \
--exclude "v3.0" \
--exclude "v3.1" \
--delete \
--timeout=120 \
--delay-updates \
--delete-after \
"$src" "$dest"

0 comments on commit 0d0cd58

Please sign in to comment.