Skip to content

Commit

Permalink
Merge pull request #110 from steven-gueguen/master
Browse files Browse the repository at this point in the history
Remove build stage
  • Loading branch information
stggn authored Oct 5, 2022
2 parents 508a032 + fdd3c45 commit a5f606d
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 58 deletions.
79 changes: 33 additions & 46 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,6 @@
# limitations under the License.
#


FROM adoptopenjdk:8-jdk-hotspot-bionic AS builder

ARG WARP10_VERSION=${WARP10_VERSION}

RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
git \
thrift-compiler \
; \
rm -rf /var/lib/apt/lists/*;

RUN set -eux; \
git clone https://github.com/senx/warp10-platform.git; \
cd warp10-platform; \
git checkout ${WARP10_VERSION}; \
./gradlew -Djava.security.egd=file:/dev/urandom createTarArchive;

############################################################################

FROM openjdk:8-jre-alpine

LABEL author="SenX S.A.S."
Expand All @@ -57,40 +36,48 @@ ENV WARP10_VOLUME=/data \
SENSISION_HOME=/opt/sensision \
SENSISION_DATA_DIR=/data/sensision

ARG WARP10_VERSION=${WARP10_VERSION}
ARG WARP10_VERSION=2.11.1
ARG WARP10_URL=https://github.com/senx/warp10-platform/releases/download/${WARP10_VERSION}/warp10-${WARP10_VERSION}.tar.gz
ENV WARP10_VERSION=${WARP10_VERSION}

ARG SENSISION_VERSION=1.0.24
ARG SENSISION_URL=https://github.com/senx/sensision/releases/download/${SENSISION_VERSION}/sensision-service-${SENSISION_VERSION}.tar.gz
ENV SENSISION_VERSION=${SENSISION_VERSION}

ARG WARPSTUDIO_VERSION=2.0.6
ARG WARPSTUDIO_URL=https://repo1.maven.org/maven2/io/warp10/warp10-plugin-warpstudio/${WARPSTUDIO_VERSION}
ARG WARPSTUDIO_URL=https://repo1.maven.org/maven2/io/warp10/warp10-plugin-warpstudio/${WARPSTUDIO_VERSION}/warp10-plugin-warpstudio-${WARPSTUDIO_VERSION}.jar
ENV WARPSTUDIO_VERSION=${WARPSTUDIO_VERSION}

ARG HFSTORE_VERSION=1.7.0
ARG HFSTORE_VERSION=2.0.0
ARG HFSTORE_URL=https://maven.senx.io/repository/senx-public/io/senx/warp10-ext-hfstore/${HFSTORE_VERSION}/warp10-ext-hfstore-${HFSTORE_VERSION}.jar

# Getting Warp 10
COPY --from=builder /warp10-platform/warp10/build/libs/warp10-*.tar.gz /opt
RUN cd /opt \
&& tar xzf warp10-*.tar.gz \
&& rm warp10-*.tar.gz \
&& ln -s /opt/warp10-* ${WARP10_HOME} \
&& adduser -D -s -H -h ${WARP10_HOME} -s /bin/bash warp10 \
&& chown -h warp10:warp10 ${WARP10_HOME} \
&& wget -q -P ${WARP10_HOME}/lib ${WARPSTUDIO_URL}/warp10-plugin-warpstudio-${WARPSTUDIO_VERSION}.jar \
&& wget -q -P ${WARP10_HOME}/lib ${HFSTORE_URL}
# Set up Warp 10
RUN set -eux; \
mkdir -p /opt; \
cd /opt; \
wget -q ${WARP10_URL}; \
tar xzf warp10-${WARP10_VERSION}.tar.gz; \
rm warp10-${WARP10_VERSION}.tar.gz; \
ln -s /opt/warp10-${WARP10_VERSION} ${WARP10_HOME}; \
wget -q -P ${WARP10_HOME}/lib ${WARPSTUDIO_URL}; \
wget -q -P ${WARP10_HOME}/lib ${HFSTORE_URL}; \
adduser -D -s -H -h ${WARP10_HOME} -s /bin/bash warp10; \
chown -h warp10:warp10 ${WARP10_HOME}; \
chown -RH warp10:warp10 ${WARP10_HOME}


ARG SENSISION_VERSION=1.0.24
ARG SENSISION_URL=https://github.com/senx/sensision/releases/download/${SENSISION_VERSION}
ENV SENSISION_VERSION=${SENSISION_VERSION}

# Getting Sensision
RUN cd /opt \
&& wget -q $SENSISION_URL/sensision-service-${SENSISION_VERSION}.tar.gz \
&& tar xzf sensision-service-${SENSISION_VERSION}.tar.gz \
&& rm sensision-service-${SENSISION_VERSION}.tar.gz \
&& ln -s /opt/sensision-${SENSISION_VERSION} ${SENSISION_HOME} \
&& adduser -D -s -H -h ${SENSISION_HOME} -s /bin/bash sensision \
&& addgroup sensision warp10 \
&& chown -h sensision:sensision ${SENSISION_HOME}
RUN set -eux; \
cd /opt; \
wget -q ${SENSISION_URL}; \
tar xzf sensision-service-${SENSISION_VERSION}.tar.gz; \
rm sensision-service-${SENSISION_VERSION}.tar.gz; \
ln -s /opt/sensision-${SENSISION_VERSION} ${SENSISION_HOME}; \
adduser -D -s -H -h ${SENSISION_HOME} -s /bin/bash sensision; \
addgroup sensision warp10; \
chown -h sensision:sensision ${SENSISION_HOME}; \
chown -RH sensision:sensision ${SENSISION_HOME}

ENV WARP10_JAR=${WARP10_HOME}/bin/warp10-${WARP10_VERSION}.jar \
WARP10_CONFIG_DIR=${WARP10_HOME}/etc/conf.d \
Expand All @@ -111,7 +98,7 @@ ENV PATH=$PATH:${WARP10_HOME}/bin

VOLUME ${WARP10_VOLUME}

# Exposing port
# Exposing port for Warp 10, Warp Studio, and HFStore
EXPOSE 8080 8081 4378

CMD ${WARP10_HOME}/bin/warp10.start.sh
39 changes: 27 additions & 12 deletions test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
#!/usr/bin/env sh
#
# Copyright 2021 SenX S.A.S.
# Copyright 2021-2022 SenX S.A.S.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -15,6 +15,8 @@
# limitations under the License.
#

set -eu

#CMD=docker run -d -p 8080:8080 -p 8081:8081 ${{ secrets.DOCKER_USERNAME }}/warp10:${TAG}-test
CMD=$1

Expand All @@ -25,33 +27,46 @@ echo "Wait for container to start-up"
sleep 10

echo "Get tokens"
READ_TOKEN=$(docker exec -i ${id} tail -n 1 /opt/warp10/etc/initial.tokens | sed -e 's/{"read":{"token":"//' -e 's/".*//')
WRITE_TOKEN=$(docker exec -i ${id} tail -n 1 /opt/warp10/etc/initial.tokens | sed -e 's/.*,"write":{"token":"//' -e 's/".*//')
READ_TOKEN=$(docker exec -i "${id}" tail -n 1 /opt/warp10/etc/initial.tokens | sed -e 's/{"read":{"token":"//' -e 's/".*//')
WRITE_TOKEN=$(docker exec -i "${id}" tail -n 1 /opt/warp10/etc/initial.tokens | sed -e 's/.*,"write":{"token":"//' -e 's/".*//')

echo "Write data"
curl -s -H "X-Warp10-Token: ${WRITE_TOKEN}" http://127.0.0.1:8080/api/v0/update --data-binary '// test{} 42'
if ! curl -s -H "X-Warp10-Token: ${WRITE_TOKEN}" http://127.0.0.1:8080/api/v0/update --data-binary '// test{} 42'; then
echo "Failed to write data"
docker stop "${id}"
exit 1
fi

echo "Read data"
res=$(curl -s "http://127.0.0.1:8080/api/v0/fetch?token=${READ_TOKEN}&selector=~.*\{\}&now=now&timespan=-1" | cut -d ' ' -f3)
if [[ "${res}" != "42" ]]; then
if [ "${res}" != "42" ]; then
echo "Failed to compare write data with read data"
echo "Value read: ${res}"
docker stop ${id}
docker stop "${id}"
exit 1
fi

echo "Delete data"
res=$(curl -s -H "X-Warp10-Token:${WRITE_TOKEN}" "http://127.0.0.1:8080/api/v0/delete?selector=test%7B%7D&start=0&end=1611332350722909")
if [[ "${res::-1}" != "test{.app=io.warp10.bootstrap}{}" ]]; then
res=$(curl -s -H "X-Warp10-Token:${WRITE_TOKEN}" "http://127.0.0.1:8080/api/v0/delete?selector=test%7B%7D&deleteall" | cut -c -32)
if [ "${res}" != "test{.app=io.warp10.bootstrap}{}" ]; then
echo "Failed to delete data"
echo "Result: ${res::-1}"
docker stop ${id}
echo "Result: ${res}"
docker stop "${id}"
exit 1
fi

echo "Check if data was deleted"
res=$(curl -s "http://127.0.0.1:8080/api/v0/fetch?token=${READ_TOKEN}&selector=~.*\{\}&now=now&timespan=-1" | cut -d ' ' -f3)
if [ "${res}" != "" ]; then
echo "Data is still present"
echo "Value read: ${res}"
docker stop "${id}"
exit 1
fi

echo "Test WarpStudio"
res=$(curl -Is http://127.0.0.1:8081/ | head -1)
if [[ "${res%?}" != "HTTP/1.1 200 OK" ]]; then
if [ "${res%?}" != "HTTP/1.1 200 OK" ]; then
echo "Failed to test WarpStudio URL"
echo "Curl result: ${res}"
docker ps -a
Expand Down

0 comments on commit a5f606d

Please sign in to comment.