Skip to content

Commit 01d4181

Browse files
committed
Cleanup docker before 2.3.0b1 release
scripts/Docker/Dockerfile Document/implement pip_sdist source mode for testing the source distribution. Change from multiple if's to case statement. Disable verbose tracing of shells script. Use --build-arg="VERBOSE=1" to enable set -xv. scripts/Docker/roundup_start Report error if demo mode is used with 2.2.0. This catches the easiest case where build is done using pypi before 2.3.0 final is released. Indent demo mode PORT_8080 doc block so it's not lost in a wall of text. doc/installation.txt Document all source --build-args including how to build from pypi using a version specifier. Break out other uses of --build-arg into code blocks. Reference docker compose section rather than referencing docker-compose.yml. Clarify docker hub tagging for devel releases. Minor formatting fixes.
1 parent 42502d1 commit 01d4181

File tree

3 files changed

+121
-42
lines changed

3 files changed

+121
-42
lines changed

doc/installation.txt

Lines changed: 64 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1641,9 +1641,9 @@ However running cron in a container is problematic (running
16411641
busybox crond as root vs. non-root, requiring setgrp privs
16421642
etc). Patches for implementing email support are welcome.
16431643

1644-
If you want to use a MySQL backend, the `docker-compose.yml` file will
1645-
deploy a Roundup container and a MySQL container backend for use with
1646-
Roundup.
1644+
If you want to use a MySQL backend, see `Docker-compose
1645+
Deployment`_ to deploy a Roundup container and a MySQL container
1646+
backend for use with Roundup.
16471647

16481648
We recommend you follow the `OSWAP Docker Security practices`_ for your
16491649
production Roundup instance.
@@ -1654,24 +1654,65 @@ production Roundup instance.
16541654
Building a Docker Container
16551655
---------------------------
16561656

1657-
To build a docker container using the code in the current directory,
1658-
run this build command from the top of the source tree::
1657+
You can build a docker container in one of 4 modes defined by the
1658+
``source`` build-arg.
1659+
1660+
``--build-arg="source=local"``
1661+
the default if no source is defined. Build using the version in
1662+
the source tree by running ``setup.py install``.
1663+
1664+
``--build-arg="source=pypi"``
1665+
build the newest production release version deployed to pypi.
1666+
If you want to build using a pre-release, you can append
1667+
`pip version specifiers
1668+
<https://peps.python.org/pep-0440/#version-specifiers>`_ to
1669+
`pypi` without embedding any spaces. For example::
1670+
1671+
# install 2.2.0 if available or 2.2.0b1 or 2.2.0b2 etc.
1672+
--build-arg="source=pypi~=2.2.0b1"
1673+
1674+
# install only a 2.2.0 beta
1675+
--build-arg="source=pypi~=2.2.0b1,!=2.2.0"
1676+
1677+
Note that versions of Roundup before 2.2 may not run correctly
1678+
in a Docker container.
1679+
1680+
``--build-arg="source=pip_local"``
1681+
Build using the version in the source tree by running ``pip
1682+
install``. This places some files (e.g. man pages, templates) in
1683+
different directories from the `local` install but is preferred
1684+
by some Python users.
1685+
1686+
``--build-arg="source=pip_sdist"``
1687+
This is meant for maintainer/developer use. It installs using
1688+
pip from a source distribution (sdist) tarball built by
1689+
following the RELEASE.txt. It is meant for testing
1690+
releases. Normal users/admins should not use it.
1691+
1692+
Build a docker container using the code in the current directory,
1693+
with this build command from the top of the source tree::
16591694

16601695
docker build -t roundup-app -f scripts/Docker/Dockerfile .
16611696

1662-
You can also build a container using the newest Roundup release on
1663-
PyPI, by running::
1697+
Build a container using the newest production (non pre-release)
1698+
Roundup release on PyPI, by running::
16641699

16651700
docker build -t roundup-app --build-arg="source=pypi" \
16661701
-f scripts/Docker/Dockerfile .
16671702

1668-
The docker declares a single volume mounted at
1669-
``/usr/src/app/tracker`` inside the container. You will mount your
1670-
tracker home directory at this location. The ``/usr/src/app`` path can
1671-
be changed by using ``--build-arg="appdir=/new/path"``.
1703+
Change the ``build-arg`` for building in other modes.
1704+
1705+
The Dockerfile declares a single volume mounted at
1706+
``/usr/src/app/tracker`` inside the container. You will mount
1707+
your tracker home directory at this location. The
1708+
``/usr/src/app`` path can be changed by adding::
1709+
1710+
--build-arg="appdir=/new/path"
1711+
1712+
You can also add additional modules to the docker container by
1713+
using::
16721714

1673-
You can also add additional modules to the docker container by using
1674-
`--build-arg="pip_mod=requests setproctitle"`.
1715+
--build-arg="pip_mod=requests setproctitle"
16751716

16761717
Because of deficiencies in the docker program (see:
16771718
https://github.com/moby/moby/issues/29110#issuecomment-1100676306),
@@ -1683,7 +1724,8 @@ suggested ``--build-arg`` to the ``docker build`` command line.
16831724
.. _UID at image build time:
16841725

16851726
By default the container runs Roundup using UID 1000. By setting
1686-
`--build-arg="roundup_uid=2000"` you can change the UID.
1727+
``--build-arg="roundup_uid=2000"`` you can change the UID and
1728+
GID.
16871729

16881730
Configuring Roundup in the Container
16891731
------------------------------------
@@ -1885,9 +1927,10 @@ Tags for Dockerhub Docker Images
18851927
--------------------------------
18861928

18871929
The docker images available from
1888-
https://hub.docker.com/r/rounduptracker/roundup
1889-
are tagged with: version-build, version, and ``latest`` tags.
1890-
For example, the tags when 2.3.0 is released will be:
1930+
https://hub.docker.com/r/rounduptracker/roundup are tagged with:
1931+
version-build, version, and ``latest`` tags. Only production
1932+
releases (not pre-releases) are tagged this way. For example, the
1933+
tags when 2.3.0 is released will be:
18911934

18921935
``rounduptracker/roundup:latest``
18931936
is a moving tag that tracks the latest build
@@ -1910,11 +1953,12 @@ For example, the tags when 2.3.0 is released will be:
19101953

19111954
In addition to the release tags, there may be one or more
19121955
development tags available. All tags will start with `devel`. For
1913-
example: ``rounduptracker/roundup:devel``.
1956+
example: ``rounduptracker/roundup:2.3.0b1-devel``,
1957+
``rounduptracker/roundup:devel``
19141958

1915-
You should not assume that any ``devel`` tag is static. They ae
1959+
You should not assume that any ``devel`` tag is static. They are
19161960
mainly for use by Roundup developer/maintainer for testing. There
1917-
may be alternate tags starting with ``devel-`` to indicate builds
1961+
may be alternate tags ending with ``-devel`` to indicate builds
19181962
from specific Mercurial versions/hashes. Also the tag may be
19191963
overwritten to change the underlying Python libraries or
19201964
images. Unless you like the bleeding edge, these should not be

scripts/Docker/Dockerfile

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@
1010

1111

1212
# Global vars for all build stages
13+
ARG VERBOSE=
1314

1415
# application directory
1516
ARG appdir=/usr/src/app
1617

1718
# support roundup install from 'local' directory,
18-
# 'local_pip' local directory using pip to install or
19-
# latest release from 'pypi'
19+
# 'pypi' to install latest final or version specified release
20+
# from PyPI,
21+
# 'pip_local' local directory using pip to install, or
22+
# 'pip_sdist' to install dist/newest_version-tarball
2023
ARG source=local
2124

2225
# Python version as a.b Used for installation directory and
@@ -68,7 +71,10 @@ COPY scripts/Docker/sphinxdeps.txt .
6871
ENV PIP_ROOT_USER_ACTION=ignore
6972

7073
SHELL ["/bin/ash", "-eo", "pipefail", "-c"]
71-
RUN set -xv && CWD=$PWD && \
74+
ARG VERBOSE
75+
76+
RUN [ -z "${VERBOSE}" ] || set -xv; \
77+
CWD=$PWD && \
7278
upgrades=$(python3 -m pip --no-cache --disable-pip-version-check \
7379
list --outdated | awk 'NR > 2 {print $1}'); \
7480
if [ -n "$upgrades" ]; then \
@@ -106,25 +112,43 @@ COPY frontends install/frontends/
106112
COPY locale install/locale/
107113
COPY roundup install/roundup/
108114
COPY share install/share/
115+
# dist is optional so include README.txt so we don't get an error
116+
COPY README.txt dist/* install/dist/
109117

110118
# verify source has one of two valid values then
111119
# install in python3 standard directories from local copy
112120
# or install in python3 standard directories from pypi using pip
113121
# import from global/command line
114122
ARG source
115-
RUN set -xv && if [ "$source" = "local" ] || \
116-
[ "$source" = "pypi" ] || \
117-
[ "$source" = "local_pip" ]; then :; \
118-
else echo "invalid value for source: $source"; \
119-
echo "must be local or pypi"; exit 1; fi; \
120-
if [ "$source" = "local" ]; then cd install && ./setup.py install; fi; \
121-
if [ "$source" = "local_pip" ]; then cd install && \
122-
pip -V && \
123-
pip install --no-cache-dir . ; \
124-
fi; \
125-
if [ "$source" = "pypi" ]; then pip install --no-cache-dir roundup; \
126-
cp -ril /usr/local/lib/"python${pythonversion}"/site-packages/usr/local/share/* \
127-
/usr/local/share; fi
123+
124+
RUN [ -z "${VERBOSE}" ] || set -xv; \
125+
case "$source" in \
126+
"local") \
127+
cd install && ./setup.py install;; \
128+
"pypi"*) \
129+
version_spec=$( printf "%s" "$source" | \
130+
sed -ne 's/^pypi\([~=!<>].*\)/\1/p'); \
131+
pip install --no-cache-dir roundup${version_spec}; \
132+
cp -ril /usr/local/lib/"python${pythonversion}"/site-packages/usr/local/share/* \
133+
/usr/local/share;; \
134+
"pip_local") \
135+
cd install && \
136+
pip -V && \
137+
pip install --no-cache-dir . ;; \
138+
"pip_sdist") \
139+
dist=$(ls install/dist | sed -ne '/roundup-[0-9].*\.tar\.gz$/p' | tail -n 1); \
140+
if [ -z "$dist" ] ; then \
141+
printf "Unable to find a source distribution file in dist\n"; \
142+
printf "Exiting\n"; \
143+
exit 1; \
144+
fi; \
145+
printf "Building with distribution: %s\n" "$dist"; \
146+
pip install --no-cache-dir install/dist/$dist;; \
147+
*) \
148+
echo "invalid value for source: $source"; \
149+
echo "must be local, pypi, pip_local or pip_sdist"; \
150+
exit 1;; \
151+
esac
128152

129153
# Allow user to add more modules during build
130154
ARG pip_mod

scripts/Docker/roundup_start

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,24 @@ for tracker_spec in "$@"; do
3434
# if it's a request to start in demo/shell mode:
3535
case "$tracker" in
3636
demo)
37+
version=$(roundup-admin -v | grep 2.2.0)
38+
if [ -n "$version" ]; then
39+
printf "\nRoundup version: %s does not support docker demo mode\n" "$version"
40+
printf "Try building with a version newer than 2.2.0.\n"
41+
printf "For example:\n"
42+
printf " docker build --build-arg=\"source=pypi~=2.3.0a1\" ...\n"
43+
exit 3
44+
fi
45+
3746
if [ -z "$PORT_8080" ]; then
38-
PORT_8080=8917
39-
printf "If docker reports a bind error, you can set the\n"
40-
printf "Docker environment variable PORT_8080 to fix it.\n"
41-
printf "Please add -e PORT_8080=port_number. The\n"
42-
printf "port_number must match the first value to -p \n"
43-
printf "which must be an unused port on your server.\n"
47+
PORT_8080=8917
48+
printf " If docker reports a bind error, you can set the\n"
49+
printf " Docker environment variable PORT_8080 to\n"
50+
printf " fix it.\n\n"
51+
printf " Add -e PORT_8080=port_number to the docker run\n"
52+
printf " command. The port_number must match the first\n"
53+
printf " value to -p which must be an unused port\n"
54+
printf " on your server.\n\n"
4455
fi
4556
template=classic
4657
backend=sqlite

0 commit comments

Comments
 (0)