mirror of
https://github.com/zrepl/zrepl.git
synced 2024-12-22 15:11:16 +01:00
Add Docker build image, modularize lazy.sh and adjust build from source instructions
refs #35
This commit is contained in:
parent
bc4b129536
commit
903fbff710
20
build.Dockerfile
Normal file
20
build.Dockerfile
Normal file
@ -0,0 +1,20 @@
|
||||
FROM golang:latest
|
||||
|
||||
# Docs deps
|
||||
RUN apt-get update && apt-get install -y \
|
||||
python3-pip
|
||||
|
||||
ADD lazy.sh /tmp/lazy.sh
|
||||
|
||||
RUN /tmp/lazy.sh builddep
|
||||
|
||||
ADD docs/requirements.txt /tmp/requirements.txt
|
||||
ENV ZREPL_LAZY_DOCS_REQPATH=/tmp/requirements.txt
|
||||
RUN /tmp/lazy.sh docdep
|
||||
|
||||
RUN mkdir -p /go/src/github.com/zrepl
|
||||
RUN ln -sf /zrepl /go/src/github.com/zrepl/zrepl
|
||||
|
||||
WORKDIR /go/src/github.com/zrepl/zrepl
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
.. _binary releases: https://github.com/zrepl/zrepl/releases
|
||||
|
||||
.. _installation:
|
||||
|
||||
Installation
|
||||
@ -18,8 +20,9 @@ However, until we get around documenting those setups, you will have to run zrep
|
||||
Packages
|
||||
--------
|
||||
|
||||
zrepl releases are signed & tagged by the author in the git repository.
|
||||
zrepl source releases are signed & tagged by the author in the git repository.
|
||||
Your OS vendor may provide binary packages of zrepl through the package manager.
|
||||
Additionally, `binary releases`_ are provided on GitHub.
|
||||
The following list may be incomplete, feel free to submit a PR with an update:
|
||||
|
||||
.. list-table::
|
||||
@ -33,45 +36,45 @@ The following list may be incomplete, feel free to submit a PR with an update:
|
||||
- `<https://www.freshports.org/sysutils/zrepl/>`_
|
||||
* - Others
|
||||
-
|
||||
- Install from source, see below
|
||||
- Use `binary releases`_ or build from source.
|
||||
|
||||
Compile From Source
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Go 1.9 or newer and a configured ``$GOPATH`` environment variable and a few build dependencies are required to build zrepl.
|
||||
A tutorial is available over at `golang.org <https://golang.org/doc/install>`_.
|
||||
If Go 1.9 is not available on your distro consider build in Docker (see below).
|
||||
Producing a release requires **Go 1.9** or newer and **Python 3** + **pip3** + ``docs/requirements.txt`` for the Sphinx documentation.
|
||||
A tutorial to install Go is available over at `golang.org <https://golang.org/doc/install>`_.
|
||||
Python and pip3 should probably be installed via your distro's package manager.
|
||||
|
||||
The following shell script checks out the zrepl project into your ``$GOPATH``,
|
||||
installs the build dependencies, installs dependencies using ``dep ensure`` and does a ``make release``.
|
||||
Build artifacts are placed into ``$GOPATH/github.com/zrepl/zrepl/artifacts/``.
|
||||
|
||||
When doing builds afterwards, it should be sufficient to checkout the new revision, run ``dep ensure`` and ``make release``.
|
||||
You may want to switch to a tagged commit (we use `semver <http://semver.org>`_) but master should generally be considered stable.
|
||||
|
||||
**Note**: it is your job to install the apropriate binary in the zrepl users's ``$PATH``, e.g. ``/usr/local/bin/zrepl``.
|
||||
Otherwise, the examples in the :ref:`tutorial` may need to be adjusted.
|
||||
|
||||
**You are encouraged to understand what happens by auditing the script.**
|
||||
|
||||
::
|
||||
|
||||
curl 'https://raw.githubusercontent.com/zrepl/zrepl/master/lazy.sh' | sh
|
||||
|
||||
You can also build in a Docker container if you want an isolated build environment or don't have a compatible Go version.
|
||||
Alternatively, you can use the Docker build process:
|
||||
it is used to produce the official zrepl `binary releases`_
|
||||
and serves as a reference for build dependencies and procedure:
|
||||
|
||||
::
|
||||
|
||||
git clone https://github.com/zrepl/zrepl.git
|
||||
cd zrepl
|
||||
sudo docker build -t zrepl_build -f build.Dockerfile .
|
||||
sudo docker run -it --rm \
|
||||
-v "${PWD}:/zrepl" \
|
||||
--user "$(id -u):$(id -g)" \
|
||||
golang:latest bash -c 'export CLONEPATH=/go/src/github.com/zrepl; mkdir -p "$CLONEPATH" && ln -s /zrepl $CLONEPATH/zrepl && ${CLONEPATH}/zrepl/lazy.sh'
|
||||
zrepl_build make release
|
||||
|
||||
.. literalinclude:: ../lazy.sh
|
||||
:language: sh
|
||||
Alternatively, you can install build dependencies on your local system and then build in your ``$GOPATH``:
|
||||
|
||||
::
|
||||
|
||||
mkdir -p "${GOPATH}/src/github.com/zrepl/zrepl"
|
||||
git clone https://github.com/zrepl/zrepl.git "${GOPATH}/src/github.com/zrepl/zrepl"
|
||||
cd "${GOPATH}/src/github.com/zrepl/zrepl"
|
||||
./lazy.sh devsetup
|
||||
make release
|
||||
|
||||
Build results are located in the ``artifacts/`` directory.
|
||||
|
||||
.. NOTE::
|
||||
|
||||
It is your job to install the apropriate binary in the zrepl users's ``$PATH``, e.g. ``/usr/local/bin/zrepl``.
|
||||
Otherwise, the examples in the :ref:`tutorial` may need to be adjusted.
|
||||
|
||||
.. _mainconfigfile:
|
||||
|
||||
|
28
docs/requirements.txt
Normal file
28
docs/requirements.txt
Normal file
@ -0,0 +1,28 @@
|
||||
Babel==2.5.1
|
||||
certifi==2017.11.5
|
||||
chardet==3.0.4
|
||||
click==6.7
|
||||
colorclass==2.2.0
|
||||
cryptography==1.7.1
|
||||
docutils==0.14
|
||||
idna==2.6
|
||||
imagesize==0.7.1
|
||||
Jinja2==2.10
|
||||
keyring==10.1
|
||||
keyrings.alt==1.3
|
||||
MarkupSafe==1.0
|
||||
pyasn1==0.1.9
|
||||
pycrypto==2.6.1
|
||||
Pygments==2.2.0
|
||||
pygobject==3.22.0
|
||||
pytz==2017.3
|
||||
pyxdg==0.25
|
||||
requests==2.18.4
|
||||
SecretStorage==2.3.1
|
||||
six==1.10.0
|
||||
snowballstemmer==1.2.1
|
||||
Sphinx==1.6.5
|
||||
sphinx-rtd-theme==0.2.4
|
||||
sphinxcontrib-versioning==2.2.1
|
||||
sphinxcontrib-websupport==1.0.1
|
||||
urllib3==1.22
|
104
lazy.sh
104
lazy.sh
@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
if [ ! -z "$TERM" ]; then
|
||||
if tty -s; then
|
||||
bold=$(tput bold)
|
||||
normal=$(tput sgr0)
|
||||
else
|
||||
@ -13,39 +13,91 @@ step() {
|
||||
echo "${bold}$1${normal}"
|
||||
}
|
||||
|
||||
if ! type go; then
|
||||
step "go binary not installed or not in \$PATH" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$GOPATH" ]; then
|
||||
step "Make sure you have your GOPATH configured correctly" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
step "Checkout sources to \$GOPATH/github.com/zrepl/zrepl"
|
||||
CHECKOUTPATH="${GOPATH}/src/github.com/zrepl/zrepl"
|
||||
if [ -e "$CHECKOUTPATH" ]; then
|
||||
echo "${CHECKOUTPATH} already exists"
|
||||
if [ ! -d "$CHECKOUTPATH" ]; then
|
||||
echo "${CHECKOUTPATH} is not a directory, aborting" 1>&2
|
||||
|
||||
clone() {
|
||||
step "Checkout sources to \$GOPATH/github.com/zrepl/zrepl"
|
||||
if [ -e "$CHECKOUTPATH" ]; then
|
||||
echo "${CHECKOUTPATH} already exists"
|
||||
if [ ! -d "$CHECKOUTPATH" ]; then
|
||||
echo "${CHECKOUTPATH} is not a directory, aborting" 1>&2
|
||||
else
|
||||
cd "$CHECKOUTPATH"
|
||||
fi
|
||||
else
|
||||
cd "$CHECKOUTPATH"
|
||||
mkdir -p "$GOPATH/src/github.com/zrepl"
|
||||
cd "$GOPATH/src/github.com/zrepl"
|
||||
git clone https://github.com/zrepl/zrepl.git
|
||||
cd zrepl
|
||||
fi
|
||||
else
|
||||
mkdir -p "$GOPATH/src/github.com/zrepl"
|
||||
cd "$GOPATH/src/github.com/zrepl"
|
||||
git clone https://github.com/zrepl/zrepl.git
|
||||
cd zrepl
|
||||
fi
|
||||
}
|
||||
|
||||
step "Install build depdencies using 'go get' to \$GOPATH/bin"
|
||||
go get -u golang.org/x/tools/cmd/stringer
|
||||
go get -u github.com/golang/dep/cmd/dep
|
||||
if ! type stringer || ! type dep; then
|
||||
echo "Installed dependencies but can't find them in \$PATH, adjust it to contain \$GOPATH/bin" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
builddep() {
|
||||
step "Install build depdencies using 'go get' to \$GOPATH/bin"
|
||||
go get -u golang.org/x/tools/cmd/stringer
|
||||
go get -u github.com/golang/dep/cmd/dep
|
||||
if ! type stringer || ! type dep; then
|
||||
echo "Installed dependencies but can't find them in \$PATH, adjust it to contain \$GOPATH/bin" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
step "Fetching dependencies using 'dep ensure'"
|
||||
dep ensure
|
||||
godep() {
|
||||
step "Fetching dependencies using 'dep ensure'"
|
||||
dep ensure
|
||||
}
|
||||
|
||||
step "Making release"
|
||||
make release-bins
|
||||
docdep() {
|
||||
if ! type pip3; then
|
||||
step "pip3 binary not installed or not in \$PATH" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
step "Installing doc build dependencies"
|
||||
local reqpath="${CHECKOUTPATH}/docs/requirements.txt"
|
||||
if [ ! -z "$ZREPL_LAZY_DOCS_REQPATH" ]; then
|
||||
reqpath="$ZREPL_LAZY_DOCS_REQPATH"
|
||||
fi
|
||||
pip3 install -r "$reqpath"
|
||||
}
|
||||
|
||||
release() {
|
||||
step "Making release"
|
||||
make release
|
||||
}
|
||||
|
||||
# precheck
|
||||
for cmd in "$@"; do
|
||||
case "$cmd" in
|
||||
clone|builddep|godep|docdep|release_bins|docs)
|
||||
continue
|
||||
;;
|
||||
devsetup)
|
||||
step "Installing development dependencies"
|
||||
builddep
|
||||
godep
|
||||
docdep
|
||||
step "Development dependencies installed"
|
||||
continue
|
||||
;;
|
||||
*)
|
||||
step "Invalid command ${cmd}, exiting"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
for cmd in "$@"; do
|
||||
step "Step ${cmd}"
|
||||
eval $cmd
|
||||
done
|
||||
|
||||
step "Release artifacts are available in $(pwd)/artifacts"
|
||||
|
Loading…
Reference in New Issue
Block a user