diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c5958a3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,63 @@ +#ARG NODE_VERSION=6.17.1 +#FROM mhart/alpine-node:${NODE_VERSION} +FROM fluent/fluentd:v1.11-1 + +LABEL \ + org.opencontainers.image.title="Docker Image of fluent4poc" \ + org.opencontainers.image.authors="Swarmlab.io " + +#ENV PATH=/usr/local/texlive/bin/x86_64-linuxmusl:/usr/local/texlive/2020/bin/x86_64-linuxmusl:${PATH} + +ENV dockeruser fluent + +ENV USERhome=${dockeruser} +ENV UID=12345 +ENV GID=23456 + +#RUN addgroup -S node \ +# && adduser -D -g "" -h "/home/${USERhome}" -G "${USERhome}" -u "${UID}" "${USERhome}" + +COPY \ + setup.sh \ + extrapackages \ + repositories \ + /root/ + +# -------- next line is in setup.sh ------ +# ----------edit if not alpine ---------- +# copy repositories /etc/apk/repositories +# -------------------------------------- + +RUN /root/setup.sh + + +# --- fluent ----- uncomment -------------------------- +ARG USER1=fluent +ARG NODEPROJECT1src=poc-datacollector/WriteToMongo/fluent/ +ARG NODEPROJECT1=fluent + +ENV USER1 ${USER1} +ENV NODEPROJECTSRC ${NODEPROJECT1src} +ENV NODEPROJECT ${NODEPROJECT1} + + +COPY ${NODEPROJECTSRC} /home/${USER1}/${NODEPROJECT} + +RUN chown -R ${USER1}.${USER1} /home/${USER1} + +RUN /home/${USER1}/${NODEPROJECT}/install-fluent.sh +USER ${USER1} + +WORKDIR /home/${USER1} + + +USER root +USER ${USER1} + +WORKDIR /home/${dockeruser} +VOLUME ["/home/${dockeruser}"] + +#EXPOSE 8080 + +CMD ["tail","-f","/dev/null"] +#CMD ["/home/node/playground-client/start-server.sh"] diff --git a/Dockerfile.build b/Dockerfile.build new file mode 100755 index 0000000..8ece17f --- /dev/null +++ b/Dockerfile.build @@ -0,0 +1,5 @@ + +git clone https://git.swarmlab.io:3000/swarmlab/poc-datacollector.git + + +docker build -f Dockerfile -t hub.swarmlab.io:5443/poc-datacollector-fluent . diff --git a/README.md b/README.md index d9ca392..8b13789 100644 --- a/README.md +++ b/README.md @@ -1,2 +1 @@ -# playground-poc-fluent diff --git a/extrapackages b/extrapackages new file mode 100644 index 0000000..5e8df6e --- /dev/null +++ b/extrapackages @@ -0,0 +1,3 @@ +curl +build-base +ruby-dev diff --git a/repositories b/repositories new file mode 100644 index 0000000..8c72039 --- /dev/null +++ b/repositories @@ -0,0 +1,2 @@ +http://dl-cdn.alpinelinux.org/alpine/v3.2/main @community http://dl-cdn.alpinelinux.org/alpine/edge/community + diff --git a/setup.sh b/setup.sh new file mode 100755 index 0000000..dc91db6 --- /dev/null +++ b/setup.sh @@ -0,0 +1,59 @@ +#!/bin/sh + +set -e +set -o pipefail + +scheme="$1" + +retry() { + retries=$1 + shift + + count=0 + until "$@"; do + exit=$? + wait="$(echo "2^$count" | bc)" + count="$(echo "$count + 1" | bc)" + if [ "$count" -lt "$retries" ]; then + echo "Retry $count/$retries exited $exit, retrying in $wait seconds..." + sleep "$wait" + else + echo "Retry $count/$retries exited $exit, no more retries left." + return "$exit" + fi + done +} + +# --------custom repos ------- +# alpine edit 4 ubuntu +#cp /root/repositories /etc/apk/repositories + +echo "==> Install system packages" +apk --no-cache add \ + bash \ + gnupg \ + tar \ + wget \ + make \ + xz + +extrap=/root/extrapackages +if [ -f $extrap ]; then + +while read -r line; do +extrapackages="$extrapackages $line" +done < $extrap + +apk --no-cache add $extrapackages + +else + echo "No extrapackages file" +fi + +#echo "==> Install pm2" + +echo "==> Clean up" +rm -rf \ + /root/.gnupg \ + /setup.sh \ + /extrapackages