Skip to content

Commit

Permalink
Merge pull request #33 from metabrainz/fix-build
Browse files Browse the repository at this point in the history
Fix building from Solr 7.7.2 with Alpine Linux
  • Loading branch information
yvanzo authored Jun 20, 2019
2 parents 3c62b07 + 7a7726c commit a617b7d
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mb-solr/target*
.idea/
*.iml
/build-*.log
45 changes: 31 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
FROM solr:7.7.2-alpine
ARG MAVEN_TAG=3.6.1-jdk-8
ARG SOLR_NAME=metabrainz/solr
ARG SOLR_TAG=7.7.2-alpine

# Resetting value set in the parent image
USER root

RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories && \
apk add --update-cache --no-cache \
bash \
git \
maven \
openjdk8 \
openssh
FROM maven:${MAVEN_TAG} AS builder

# Caching the maven dependencies so that these are built only if
# the dependencies are changed and not the source code.
Expand All @@ -26,9 +19,33 @@ COPY ./mb-solr mb-solr
RUN cd brainz-mmd2-jaxb && \
mvn install && \
cd ../mb-solr && \
mvn package -DskipTests && \
mkdir -p /opt/solr/lib && \
cp target/mb-solr-0.0.1-SNAPSHOT-jar-with-dependencies.jar /opt/solr/lib
mvn package -DskipTests

FROM ${SOLR_NAME}:${SOLR_TAG}

ARG MAVEN_TAG
ARG SOLR_NAME
ARG SOLR_TAG

ARG MB_SOLR_VERSION
ARG BUILD_DATE
ARG VCS_REF

LABEL org.label-schema.build-date="${BUILD_DATE}" \
org.label-schema.schema-version="1.0.0-rc1" \
org.label-schema.vcs-ref="${VCS_REF}" \
org.label-schema.vcs-url="https://github.com/metabrainz/mb-solr.git" \
org.label-schema.vendor="MetaBrainz Foundation" \
org.metabrainz.based-on-image="${SOLR_NAME}:${SOLR_TAG}" \
org.metabrainz.builder-image="maven:${MAVEN_TAG}" \
org.metabrainz.mb-solr.version="${MB_SOLR_VERSION}"

# Resetting value set in the parent image
USER root

COPY --from=builder \
mb-solr/target/mb-solr-0.0.1-SNAPSHOT-jar-with-dependencies.jar \
/opt/solr/lib/

ENV SOLR_HOME /opt/solr/server/solr
COPY ./mbsssss $SOLR_HOME/mycores/mbsssss
Expand Down
66 changes: 63 additions & 3 deletions push.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,64 @@
#!/bin/sh
#!/bin/bash
#
# Build image from the currently checked out version of
# MusicBrainz Solr search server (mb-solr)
# and push it to Docker Hub, tagged with versions and variants.
#
# Examples:
# - working tree at git tag v3.1.1 will push docker tags :3.1.1 :3.1 and :3
# - working tree at git tag v3.1.1-rc.1 will push docker tag :3.1.1-rc.1 only
# - untagged working tree v3.1-1-gbfe66e3 will push docker tag 3.1.1-gbfe66e3 only
# - uncommitted/dirty working tree v3.1-dirty will push docker tag :3.1-dirty only
#
# Usage:
# $ ./push.sh

docker build -t metabrainz/solr .
docker push metabrainz/solr
set -e -u

image_name='metabrainz/mb-solr'

cd "$(dirname "${BASH_SOURCE[0]}")/"

vcs_ref=`git describe --always --broken --dirty --tags`
version=${vcs_ref#v}

# enforce version format major.minor.patch if possible
if [[ $version =~ ^[0-9]+$ ]]; then
version="${version}.0.0"
echo "$0: appended .0.0 to version"
elif [[ $version =~ ^[0-9]+\.[0-9]+$ ]]; then
version="${version}.0"
echo "$0: appended .0 to version"
fi

# add aliases if version is of format major.minor.patch
if [[ $version =~ ^([0-9]+)\.([0-9]+)\.[0-9]\+$ ]]; then
major=${BASH_REMATCH[1]}
minor=${BASH_REMATCH[2]}
version_aliases=( "${major}.${minor}" "${major}" )
echo "$0: building version '$version' with aliases:"
for version_alias in ${version_aliases[@]}; do
echo "$0: - '$version_alias'"
done
else
version_aliases=()
echo "$0: building version '$version' without alias"
fi

tag=${version}
tag_aliases=${version_aliases[@]}
timestamp=`date -u +"%Y-%m-%dT%H:%M:%SZ"`

docker build \
--build-arg MB_SOLR_VERSION=${version} \
--build-arg BUILD_DATE=${timestamp} \
--build-arg VCS_REF=${vcs_ref} \
--tag ${image_name}:${tag} . \
| tee ./"build-${version}-at-${timestamp}.log"

docker push ${image_name}:${tag}

for tag_alias in ${tag_aliases[@]}; do
docker tag ${image_name}:${tag} metabrainz/mb-solr:${tag_alias}
docker push ${image_name}:${tag_alias}
done

0 comments on commit a617b7d

Please # to comment.