Skip to content

Commit

Permalink
Build docker image (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
tamalsaha authored Mar 7, 2017
1 parent bc29563 commit ab14ac0
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 5 deletions.
16 changes: 16 additions & 0 deletions hack/docker/restic/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM appscode/base:8.7

RUN set -x \
&& apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates cron \
&& apt-get purge -y --auto-remove ca-certificates \
&& rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man /tmp/*

COPY restic /restic
COPY restik /restik

# Setup runit scripts
COPY sv /etc/sv/
RUN ln -s /etc/sv /etc/service

ENTRYPOINT ["/runit.sh"]
35 changes: 35 additions & 0 deletions hack/docker/restic/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

set -o errexit
set -o nounset
set -o pipefail

GOPATH=$(go env GOPATH)
REPO_ROOT=$GOPATH/src/github.com/appscode/restik

source "$REPO_ROOT/hack/libbuild/common/lib.sh"
source "$REPO_ROOT/hack/libbuild/common/public_image.sh"

detect_tag $REPO_ROOT/dist/.tag

IMG=restic
RESTIC_VER=0.4.0

build() {
pushd $REPO_ROOT/hack/docker/restic

# Download restic
wget https://github.com/restic/restic/releases/download/v${RESTIC_VER}/restic_${RESTIC_VER}_linux_amd64.bz2
bzip2 -d restic_${RESTIC_VER}_linux_amd64.bz2
mv restic_${RESTIC_VER}_linux_amd64 restic

# Download restik
wget -O restik https://cdn.appscode.com/binaries/restik/$TAG/restik-linux-amd64
chmod +x restik
local cmd="docker build -t appscode/$IMG:${RESTIC_VER} ."
echo $cmd; $cmd
rm restik
popd
}

binary_repo $@
8 changes: 8 additions & 0 deletions hack/docker/restic/sv/cron/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
exec 1> >(logger -s -p daemon.info -t ${PWD##*/})
exec 2> >(logger -s -p daemon.error -t ${PWD##*/})
source /etc/envvars

echo "Starting cron..."
# sv start socklog-unix || exit 1
exec cron -f
7 changes: 7 additions & 0 deletions hack/docker/restic/sv/restik/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
exec 1> >(logger -s -p daemon.info -t ${PWD##*/})
exec 2> >(logger -s -p daemon.error -t ${PWD##*/})
source /etc/envvars

echo "Starting restik..."
exec /restik watch
9 changes: 4 additions & 5 deletions hack/docker/setup.sh → hack/docker/restik/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ set -o pipefail
GOPATH=$(go env GOPATH)
SRC=$GOPATH/src
BIN=$GOPATH/bin
ROOT=$GOPATH
REPO_ROOT=$GOPATH/src/github.com/appscode/restik

source "$REPO_ROOT/hack/libbuild/common/lib.sh"
Expand All @@ -16,28 +15,28 @@ source "$REPO_ROOT/hack/libbuild/common/public_image.sh"
APPSCODE_ENV=${APPSCODE_ENV:-dev}
IMG=restik

DIST=$GOPATH/src/github.com/appscode/restik/dist
DIST=$REPO_ROOT/dist
mkdir -p $DIST
if [ -f "$DIST/.tag" ]; then
export $(cat $DIST/.tag | xargs)
fi

clean() {
pushd $GOPATH/src/github.com/appscode/restik/hack/docker
pushd $REPO_ROOT/hack/docker/restik
rm restik Dockerfile
popd
}

build_binary() {
pushd $GOPATH/src/github.com/appscode/restik
pushd $REPO_ROOT
./hack/builddeps.sh
./hack/make.py build restik
detect_tag $DIST/.tag
popd
}

build_docker() {
pushd $GOPATH/src/github.com/appscode/restik/hack/docker
pushd $REPO_ROOT/hack/docker/restik
cp $DIST/restik/restik-linux-amd64 restik
chmod 755 restik

Expand Down

0 comments on commit ab14ac0

Please sign in to comment.