go-ceph/Dockerfile
Niels de Vos 86a3a66849 tests: parameterize Ceph version for container build and build-tags
Pass `CEPH_VERSION=minic` (or 'luminous') on the `make test-docker`
command to select building a container with a different Ceph version and
running the tests in it.

This passes the given CEPH_VERSION on to the `docker build` command as a
--build-arg, which gets used for selecting the Ceph repository during
container build.

It also sets the environment variable CEPH_VERSION, which in turn is
consumed by `entrypoint.sh` to set the `go build -tags ${CEPH_VERSION}`
option that includes/excludes certain *.go files.

See-also: https://golang.org/pkg/go/build/#hdr-Build_Constraints
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-02-12 13:48:21 -05:00

39 lines
1.0 KiB
Docker

FROM ubuntu:xenial
RUN apt-get update && apt-get install -y \
apt-transport-https \
git \
software-properties-common \
uuid-runtime \
wget
ARG CEPH_VERSION
ENV CEPH_VERSION=${CEPH_VERSION:-nautilus}
ARG CEPH_REPO_URL=https://download.ceph.com/debian-${CEPH_VERSION}/
RUN wget -q -O- 'https://download.ceph.com/keys/release.asc' | apt-key add -
RUN true && \
apt-add-repository "deb ${CEPH_REPO_URL} xenial main" && \
apt-get update && \
apt-get install -y ceph libcephfs-dev librados-dev librbd-dev curl gcc g++
ENV GOTAR=go1.12.16.linux-amd64.tar.gz
RUN true && \
curl -o /tmp/${GOTAR} https://dl.google.com/go/${GOTAR} && \
tar -x -C /opt/ -f /tmp/${GOTAR} && \
rm -f /tmp/${GOTAR}
# add user account to test permissions
RUN groupadd -g 1010 bob
RUN useradd -u 1010 -g bob -M bob
ENV PATH="${PATH}:/opt/go/bin"
ENV GOROOT=/opt/go
ENV GO111MODULE=on
ENV GOPATH /go
WORKDIR /go/src/github.com/ceph/go-ceph
VOLUME /go/src/github.com/ceph/go-ceph
COPY micro-osd.sh /
COPY entrypoint.sh /
ENTRYPOINT ["/entrypoint.sh"]