Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dockerfiles for testing and for a working example #327

Merged
merged 4 commits into from
Nov 13, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions docker/README-Docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
gearmand Docker Images
======================

The Dockerfiles under the ```testing``` subdirectory are intended to be used to test building gearmand on various Linux distributions. They also quasi-document the prerequisite packages that need to be installed on these same Linux distributions in order to build gearmand from source.

The ```example``` gearmand Docker image can be built like this:

cd example/supervisord/ && make latest && cd ../gearmand/ && make latest

The ```testing``` gearmand Docker images can be built like this, e.g.:

cd testing/alpine/3.12.0 && make

Using SSL
---------

In order to use SSL with the ```example``` image, follow these steps before building the image using the above command:

1. Copy your certificate files to the ```gearmand``` subdirectory:

cp /path/to/your/certificates/your-certificate-authority.pem example/gearmand/gearmand-ca.pem
cp /path/to/your/certificates/gearmand.pem example/gearmand/gearmand.pem
cp /path/to/your/certificates/gearmand.key example/gearmand/gearmand.key

Or, better yet, use [Docker secrets](https://docs.docker.com/engine/swarm/secrets/).

2. Edit ```example/gearmand/Dockerfile``` and uncomment the line that copies these files to ```/var/lib/gearman/```.

3. Edit ```example/gearmand/gearmand.conf``` and uncomment the ```command``` line with the SSL-related arguments. Delete (or comment out) the ```command``` line on the next line in that file.
64 changes: 64 additions & 0 deletions docker/example/gearmand/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
FROM gearmand/supervisord:latest
esabol marked this conversation as resolved.
Show resolved Hide resolved

ARG version=1.1.19.1

LABEL description="Gearman Job Server Image"
LABEL maintainer="Gearmand Developers https://github.com/gearman/gearmand"
LABEL version="${version}"

# Install packages
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get -y upgrade \
&& apt-get -y install \
make \
gcc \
g++ \
gperf \
libboost-all-dev \
libevent-dev \
libhiredis-dev \
libssl-dev \
libtokyocabinet-dev \
uuid-dev \
wget \
&& apt-get clean autoclean \
&& apt-get -y autoremove \
&& rm -rf /var/lib/apt/lists/*

# Retrieve the source code and untar
WORKDIR /var/lib/gearman
RUN wget https://github.com/gearman/gearmand/releases/download/${version}/gearmand-${version}.tar.gz \
&& tar xzvf gearmand-${version}.tar.gz \
&& rm -f gearmand-${version}.tar.gz

# Configure, make, install, and clean up
RUN cd gearmand-${version}/ \
&& ./configure --prefix=/usr --enable-ssl 2>&1 | tee ../configure.log \
&& make 2>&1 | tee ../build.log \
&& make test 2>&1 | tee ../test.log \
&& make install 2>&1 | tee ../install.log \
&& cp -p test-suite.log .. \
&& cd .. \
&& gzip -9 *.log \
&& rm -rf gearmand-${version}*

# Copy SSL certificates
###COPY gearmand-ca.pem gearmand.pem gearmand.key /var/lib/gearman/

# Configure service
RUN groupadd gearman \
&& useradd -r -d /var/lib/gearman -g gearman -G supervisor gearman
RUN touch /var/log/gearmand.log \
&& chown gearman:gearman /var/log/gearmand.log
COPY gearmand.conf /etc/supervisor/conf.d/gearmand.conf

# Links
RUN ln /usr/sbin/gearmand /sbin/gearmand \
&& ln /usr/bin/gearman /bin/gearman \
&& ln /usr/bin/gearadmin /bin/gearadmin

HEALTHCHECK --interval=5m --timeout=3s --retries=2 \
CMD test $(supervisorctl status gearmand | awk '{print $2}' | grep 'RUNNING' | wc -l) -eq 1 || exit 1

EXPOSE 4730
11 changes: 11 additions & 0 deletions docker/example/gearmand/gearmand.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[program:gearmand]
user = gearman
priority = 100
###command = /sbin/gearmand --port 4730 --ssl --ssl-ca-file /var/lib/gearman/gearmand-ca.pem --ssl-certificate /var/lib/gearman/gearmand.pem --ssl-key /var/lib/gearman/gearmand.key --verbose INFO -l /var/log/gearmand.log
command = /sbin/gearmand --port 4730 --verbose INFO -l /var/log/gearman.log
redirect_stderr = true
stdout_logfile = /var/log/supervisor/gearman.log
stdout_logfile_maxbytes = 50MB
stdout_logfile_backups = 10
startsecs = 5
autorestart = true
1 change: 1 addition & 0 deletions docker/example/supervisord/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Makefile
38 changes: 38 additions & 0 deletions docker/example/supervisord/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
FROM ubuntu:latest

ARG version=1.0

LABEL description="Supervisord Base Image for Gearmand"
LABEL maintainer="Gearmand Developers https://github.com/gearman/gearmand"
LABEL version="${version}"

# Configure timezone
ENV DEBIAN_FRONTEND=noninteractive \
TZ=America/New_York \
HOME=/root
RUN (echo $TZ > /etc/timezone) \
&& dpkg-reconfigure tzdata

# Install packages
RUN apt-get update \
&& apt-get -y upgrade \
&& apt-get -y install \
supervisor \
&& apt-get clean autoclean \
&& apt-get -y autoremove \
&& rm -rf /var/lib/apt/lists/*

# Configure service
RUN mkdir -p /var/log/supervisor \
&& mkdir -p /var/run/supervisor \
&& mkdir -p /etc/supervisor/conf.d

COPY supervisord.conf /etc/supervisor/supervisord.conf

RUN ln -s /etc/supervisor/supervisord.conf /etc/supervisord.conf \
&& groupadd supervisor \
&& chgrp supervisor /etc/supervisor/supervisord.conf \
&& chmod 640 /etc/supervisor/supervisord.conf

# Default command
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]
21 changes: 21 additions & 0 deletions docker/example/supervisord/supervisord.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[unix_http_server]
file=/var/run/supervisor/supervisor.sock ; (the path to the socket file)
chmod=0770 ; socket file mode (default 0700)
chown=root:supervisor ; socket file uid:gid owner

[supervisord]
nodaemon=true
logfile=/var/log/supervisor/supervisord.log
pidfile=/var/run/supervisor/supervisord.pid
stdout_logfile_maxbytes = 50MB
stdout_logfile_backups = 10
loglevel=info ; (default: info; others: debug, warn, trace)

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///var/run/supervisor/supervisor.sock

[include]
files = /etc/supervisor/conf.d/*.conf
43 changes: 43 additions & 0 deletions docker/testing/alpine/3.12/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
ARG version=3.12
FROM alpine:${version}

ARG version
ARG GEARMAN_REPO=https://github.com/gearman/gearmand

LABEL description="Gearman Job Server Image (Alpine ${version})"
LABEL maintainer="Gearmand Developers https://github.com/gearman/gearmand"
LABEL version="${version}"

# Install packages
RUN apk add --no-cache \
make \
gcc \
g++ \
autoconf \
automake \
m4 \
git \
libtool \
bash \
file \
py3-sphinx \
util-linux-dev \
libuuid \
libevent-dev \
gperf \
boost-dev \
openssl-dev

# Switch to a non-root user
RUN adduser --disabled-password --shell /bin/bash gearman
USER gearman

# Clone the GitHub repository master branch
RUN cd /tmp && git clone --depth 1 --branch master ${GEARMAN_REPO}.git

# Bootstrap, configure, make, and make test
WORKDIR /tmp/gearmand
RUN ./bootstrap.sh -a
RUN ./configure --enable-ssl 2>&1 | tee ./configure.log
RUN make 2>&1 | tee ./build.log
RUN make test 2>&1 | tee ./test.log
43 changes: 43 additions & 0 deletions docker/testing/alpine/3.13/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
ARG version=3.13
FROM alpine:${version}

ARG version
ARG GEARMAN_REPO=https://github.com/gearman/gearmand

LABEL description="Gearman Job Server Image (Alpine ${version})"
LABEL maintainer="Gearmand Developers https://github.com/gearman/gearmand"
LABEL version="${version}"

# Install packages
RUN apk add --no-cache \
make \
gcc \
g++ \
autoconf \
automake \
m4 \
git \
libtool \
bash \
file \
py3-sphinx \
util-linux-dev \
libuuid \
libevent-dev \
gperf \
boost-dev \
openssl-dev

# Switch to a non-root user
RUN adduser --disabled-password --shell /bin/bash gearman
USER gearman

# Clone the GitHub repository master branch
RUN cd /tmp && git clone --depth 1 --branch master ${GEARMAN_REPO}.git

# Bootstrap, configure, make, and make test
WORKDIR /tmp/gearmand
RUN ./bootstrap.sh -a
RUN ./configure --enable-ssl 2>&1 | tee ./configure.log
RUN make 2>&1 | tee ./build.log
RUN make test 2>&1 | tee ./test.log
49 changes: 49 additions & 0 deletions docker/testing/centos/7-32bit/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
ARG version=7
FROM i386/centos:${version}

ARG version
ARG GEARMAN_REPO=https://github.com/gearman/gearmand

LABEL description="Gearman Job Server Image (CentOS ${version}/i686/32-bit)"
LABEL maintainer="Gearmand Developers https://github.com/gearman/gearmand"
LABEL version="https://github.com/gearman/gearmand/tree/master CentOS ${version}/i686/32-bit"

# Install packages
RUN yum install -y \
rpm-build \
make \
boost-devel \
boost-thread \
gcc-c++ \
gperf \
gperftools-devel \
libevent-devel \
libmemcached-devel \
memcached \
libuuid-devel \
openssl-devel \
sqlite-devel \
tokyocabinet-devel \
zlib-devel \
git \
libtool \
python-sphinx

### Not available:
# libpq-devel \
# hiredis-devel \
# mariadb-connector-c-devel \

# Switch to a non-root user
RUN adduser -M --shell /bin/bash gearman
USER gearman

# Clone the GitHub repository master branch
RUN cd /tmp && git clone --depth 1 --branch master ${GEARMAN_REPO}.git

# Bootstrap, configure, make, and make test
WORKDIR /tmp/gearmand
RUN ./bootstrap.sh -a
RUN ./configure --enable-ssl 2>&1 | tee ./configure.log
RUN make 2>&1 | tee ./build.log
RUN make test 2>&1 | tee ./test.log
49 changes: 49 additions & 0 deletions docker/testing/centos/7/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
ARG version=7
FROM centos:${version}

ARG version
ARG GEARMAN_REPO=https://github.com/gearman/gearmand

LABEL description="Gearman Job Server Image (CentOS ${version}/x86_64)"
LABEL maintainer="Gearmand Developers https://github.com/gearman/gearmand"
LABEL version="https://github.com/gearman/gearmand/tree/master CentOS ${version}/x86_64"

# Install packages
RUN yum install -y \
rpm-build \
make \
boost-devel \
boost-thread \
gcc-c++ \
gperf \
gperftools-devel \
libevent-devel \
libmemcached-devel \
memcached \
libuuid-devel \
openssl-devel \
sqlite-devel \
tokyocabinet-devel \
zlib-devel \
git \
libtool \
python-sphinx

### Not available:
# libpq-devel \
# hiredis-devel \
# mariadb-connector-c-devel \

# Switch to a non-root user
RUN adduser -M --shell /bin/bash gearman
USER gearman

# Clone the GitHub repository master branch
RUN cd /tmp && git clone --depth 1 --branch master ${GEARMAN_REPO}.git

# Bootstrap, configure, make, and make test
WORKDIR /tmp/gearmand
RUN ./bootstrap.sh -a
RUN ./configure --enable-ssl 2>&1 | tee ./configure.log
RUN make 2>&1 | tee ./build.log
RUN make test 2>&1 | tee ./test.log
Loading