diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..46f69de --- /dev/null +++ b/Dockerfile @@ -0,0 +1,61 @@ +ARG NODE_VERSION=6.17.1 +FROM mhart/alpine-node:${NODE_VERSION} + +LABEL \ + org.opencontainers.image.title="Docker Image of nodejs4poc" \ + 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 node + +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 + + +# nodejs npm install --- opencv----- uncomment -------------------------- +ARG USER1=node +ARG NODEPROJECT1-src=playground-client/playground-client +ARG NODEPROJECT1=playground-client + +ENV USER1 ${USER1} +ENV NODEPROJECTSRC ${NODEPROJECT1-src} +ENV NODEPROJECT ${NODEPROJECT1} + + +COPY ${NODEPROJECTSRC} /home/${USER1}/${NODEPROJECT} + +RUN chown -R ${USER1}.${USER1} /home/${USER1} +USER ${USER1} + +RUN /home/${USER1}/${NODEPROJECT}/install-npm.sh + +WORKDIR /home/${USER1} + + +USER root +USER ${USER1} + +WORKDIR /home/${dockeruser} +VOLUME ["/home/${dockeruser}"] + +EXPOSE 8080 + +CMD ["tail","-f","/dev/null"] diff --git a/Dockerfile.build b/Dockerfile.build new file mode 100755 index 0000000..fa1d37a --- /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/opencv4nodejswebcam . diff --git a/README.md b/README.md index aa821c8..8b13789 100644 --- a/README.md +++ b/README.md @@ -1,2 +1 @@ -# playground-poc-node diff --git a/extrapackages b/extrapackages new file mode 100644 index 0000000..c8bd9a3 --- /dev/null +++ b/extrapackages @@ -0,0 +1,5 @@ +curl +cmake +zlib +unzip +build-base 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..8d4750b --- /dev/null +++ b/setup.sh @@ -0,0 +1,61 @@ +#!/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" + +npm install pm2@latest -g + +echo "==> Clean up" +rm -rf \ + /root/.gnupg \ + /setup.sh \ + /extrapackages