From ee7ad9f3830097d6bd85f7fa616436cad510e22b Mon Sep 17 00:00:00 2001 From: felixboehm Date: Wed, 7 Oct 2020 15:57:09 +0200 Subject: [PATCH] add eos-ocis docker images --- ocis/docker/eos-ocis-dev/Dockerfile | 24 ++++++++ ocis/docker/eos-ocis-dev/README.md | 90 +++++++++++++++++++++++++++++ ocis/docker/eos-ocis-dev/entrypoint | 4 ++ ocis/docker/eos-ocis-dev/start-ldap | 14 +++++ ocis/docker/eos-ocis/Dockerfile | 37 ++++++++++++ ocis/docker/eos-ocis/README.md | 32 ++++++++++ ocis/docker/eos-ocis/entrypoint | 41 +++++++++++++ ocis/docker/eos-ocis/setup | 23 ++++++++ ocis/docker/eos-ocis/user.go | 13 +++++ 9 files changed, 278 insertions(+) create mode 100644 ocis/docker/eos-ocis-dev/Dockerfile create mode 100644 ocis/docker/eos-ocis-dev/README.md create mode 100755 ocis/docker/eos-ocis-dev/entrypoint create mode 100755 ocis/docker/eos-ocis-dev/start-ldap create mode 100644 ocis/docker/eos-ocis/Dockerfile create mode 100644 ocis/docker/eos-ocis/README.md create mode 100755 ocis/docker/eos-ocis/entrypoint create mode 100755 ocis/docker/eos-ocis/setup create mode 100644 ocis/docker/eos-ocis/user.go diff --git a/ocis/docker/eos-ocis-dev/Dockerfile b/ocis/docker/eos-ocis-dev/Dockerfile new file mode 100644 index 000000000..01163fc2a --- /dev/null +++ b/ocis/docker/eos-ocis-dev/Dockerfile @@ -0,0 +1,24 @@ +FROM owncloud/eos-base:4.6.5 + +ENV CGO_ENABLED=1 +ENV GOOS=linux + +RUN rpm --rebuilddb && yum -y install \ + wget \ + time \ + make \ + gcc \ + git + +RUN wget -q https://dl.google.com/go/go1.14.2.linux-amd64.tar.gz +RUN mkdir -p /usr/local/bin +RUN tar xf go1.14.2.linux-amd64.tar.gz -C /usr/local +RUN ln -s /usr/local/go/bin/* /usr/local/bin + +COPY entrypoint /entrypoint +COPY start-ldap /start-ldap + +VOLUME [ "/ocis" ] +WORKDIR /ocis + + diff --git a/ocis/docker/eos-ocis-dev/README.md b/ocis/docker/eos-ocis-dev/README.md new file mode 100644 index 000000000..69bc68830 --- /dev/null +++ b/ocis/docker/eos-ocis-dev/README.md @@ -0,0 +1,90 @@ +# Docker image for ocis development with eos + +Image is based on [owncloud/eos-base](https://hub.docker.com/r/owncloud/eos-base) from [eos-stack](https://github.com/owncloud-docker/eos-stack) + +## Build +``` +docker build -t owncloud/eos-ocis-dev:latest . +``` + +## Publish +``` +docker push owncloud/eos-ocis-dev:latest +``` + +## Maintainer + +- [Felix Böhm](https://github.com/felixboehm) + +## Disclaimer +Use only for development or testing. Setup is not secured nor tested. + +# oCIS development on eos + +## Setup oCIS + +To build and run your local ocis code with default storage driver + +``` +docker run --rm -ti --name ocis -v $PWD:/ocis -p 9200:9200 owncloud/eos-ocis-dev +``` + +ocis will use the owncloud storage driver and store files in the container at /var/tmp/reva/data//files + +Data is here: `docker exec -it ocis ll /var/tmp/reva/` + +Alternative: With the [docker-compose.yml file in ocis repo](https://github.com/owncloud/ocis/blob/master/docker-compose.yml) you can also start ocis via compose: + +``` +docker-compose up -d ocis +``` + +Now try to list the running services + +``` +docker-compose exec ocis ./bin/ocis list +``` + +## Setup eos storage + +1. Start the eos cluster and ocis via the compose stack + +``` +docker-compose up -d +``` + +2. Start the ldap authentication + +``` +docker-compose exec -d ocis /start-ldap +``` + +3. Configure to use eos storage driver instead of default storage driver + +- kill the home storage and data providers. we need to switch them to the eoshome driver: + +``` +docker-compose exec ocis ./bin/ocis kill reva-storage-home +docker-compose exec ocis ./bin/ocis kill reva-storage-home-data +``` + +- restart them with the eoshome driver and a new layout: + +``` +docker-compose exec -e REVA_STORAGE_EOS_LAYOUT="{{substr 0 1 .Username}}/{{.Username}}" -e REVA_STORAGE_HOME_DRIVER=eoshome -d ocis ./bin/ocis run reva-storage-home +docker-compose exec -e REVA_STORAGE_EOS_LAYOUT="{{substr 0 1 .Username}}/{{.Username}}" -e REVA_STORAGE_HOME_DATA_DRIVER=eoshome -d ocis ./bin/ocis run reva-storage-home-data +``` + +- restart the reva frontend with a new namespace (pointing to the eos storage provider) for the dav files endpoint + +``` +docker-compose exec ocis ./bin/ocis kill reva-frontend +docker-compose exec -e DAV_FILES_NAMESPACE="/eos/" -d ocis ./bin/ocis run reva-frontend +``` + +- login with `einstein / relativity`, upload a file to einsteins home and verify the file is there using + +``` +docker-compose exec ocis eos ls -l /eos/dockertest/reva/users/e/einstein/ +-rw-r--r-- 1 einstein users 10 Jul 1 15:24 newfile.txt +``` diff --git a/ocis/docker/eos-ocis-dev/entrypoint b/ocis/docker/eos-ocis-dev/entrypoint new file mode 100755 index 000000000..88e02157b --- /dev/null +++ b/ocis/docker/eos-ocis-dev/entrypoint @@ -0,0 +1,4 @@ +#!/bin/sh + +make build +exec bin/ocis server \ No newline at end of file diff --git a/ocis/docker/eos-ocis-dev/start-ldap b/ocis/docker/eos-ocis-dev/start-ldap new file mode 100755 index 000000000..6d8d30768 --- /dev/null +++ b/ocis/docker/eos-ocis-dev/start-ldap @@ -0,0 +1,14 @@ +#!/bin/sh + +echo "Waiting for EOS MGM" +echo "until nc -z -w 3 $EOS_MGM_ALIAS 1094; do sleep 2; done;" > /wait-for-mgm +chmod +x /wait-for-mgm + +/wait-for-mgm; +echo "----- [ocis] LDAP setup -----"; +authconfig --enableldap --enableldapauth --ldapserver=${EOS_LDAP_HOST} --ldapbasedn="dc=example,dc=org" --update; +sed -i "s/#binddn cn=.*/binddn ${LDAP_BINDDN}/" /etc/nslcd.conf +sed -i "s/#bindpw .*/bindpw ${LDAP_BINDPW}/" /etc/nslcd.conf +# start in debug mode; + +nslcd -d diff --git a/ocis/docker/eos-ocis/Dockerfile b/ocis/docker/eos-ocis/Dockerfile new file mode 100644 index 000000000..ca0b431b1 --- /dev/null +++ b/ocis/docker/eos-ocis/Dockerfile @@ -0,0 +1,37 @@ +FROM centos:7 as build +ARG BRANCH=master + +ENV CGO_ENABLED=1 +ENV GOOS=linux +RUN rpm --rebuilddb && yum -y install \ + wget \ + time \ + make \ + gcc \ + git +RUN wget -q https://dl.google.com/go/go1.14.2.linux-amd64.tar.gz +RUN mkdir -p /usr/local/bin +RUN tar xf go1.14.2.linux-amd64.tar.gz -C /usr/local +RUN ln -s /usr/local/go/bin/* /usr/local/bin +RUN git clone https://github.com/owncloud/ocis.git +RUN cd ocis && git checkout ${BRANCH} +RUN cd ocis && git log -n 1 +RUN cd ocis && go build -v -o bin/ocis -toolexec '/usr/bin/time -v' ./cmd/ocis +# RUN cd ocis && make generate bin/ocis + +# build user lookup test program +RUN mkdir -p /build +ADD user.go /build/user.go +RUN cd /build && go build -o user user.go + + +FROM owncloud/eos-base:4.6.5 +RUN mkdir -p /usr/local/bin +COPY --from=build ocis/bin/ocis /usr/local/bin/ +RUN chmod +x /usr/local/bin/ocis + +COPY --from=build /build/user /usr/local/bin/user +RUN chmod +x /usr/local/bin/user + +COPY setup /setup +COPY entrypoint /entrypoint diff --git a/ocis/docker/eos-ocis/README.md b/ocis/docker/eos-ocis/README.md new file mode 100644 index 000000000..17a669080 --- /dev/null +++ b/ocis/docker/eos-ocis/README.md @@ -0,0 +1,32 @@ +# Docker image for ocis running on eos + +Image is based on [owncloud/eos-base](https://hub.docker.com/r/owncloud/eos-base) from [eos-stack](https://github.com/owncloud-docker/eos-stack) + +## Build +Build owncloud/ocis master branch +``` +docker build -t owncloud/eos-ocis:latest . +``` + +Or build a certain branch / tag +``` +docker build -t owncloud/eos-ocis:1.0.0 --build-arg BRANCH=v1.0.0./eos-ocis +``` + +## Publish +``` +docker push owncloud/eos-ocis:latest +``` + +## Maintainer + +- [Felix Böhm](https://github.com/felixboehm) + +## Disclaimer +Use only for development or testing. Setup is not secured nor tested. + +## Example Usage + +See https://github.com/owncloud-docker/compose-playground/tree/master/examples/eos-compose + + diff --git a/ocis/docker/eos-ocis/entrypoint b/ocis/docker/eos-ocis/entrypoint new file mode 100755 index 000000000..326b517e2 --- /dev/null +++ b/ocis/docker/eos-ocis/entrypoint @@ -0,0 +1,41 @@ +#!/bin/sh + +# todo: log all ocis services to stdout + +echo "Waiting for EOS MGM" +echo "until nc -z -w 3 $EOS_MGM_ALIAS 1094; do sleep 2; done;" > /wait-for-mgm +chmod +x /wait-for-mgm +mkdir -p /var/log/ocis + +(/wait-for-mgm; /setup > /var/log/ocis/setup.log; cat /var/log/ocis/setup.log ) & + +echo "----- [ocis] DOMAIN setup -----" +echo "Domain / IP: $OCIS_DOMAIN" +mkdir -p /etc/ocis +sed -e "s|@IPADDR@|${OCIS_DOMAIN}|g" /config/identifier-registration.yml.tmpl > /etc/ocis/identifier-registration.yml + +# TODO do we still need to precreate this folder? +mkdir -p /var/tmp/reva + +echo "----- [ocis] Starting oCIS -----" +# todo start ocis as daemon not as root +ocis reva-storage-home & +ocis reva-storage-home-data & +ocis reva-storage-eos & +ocis reva-storage-eos-data & +ocis reva-storage-public-link & +ocis micro & +ocis glauth & +ocis graph-explorer & +ocis graph & +ocis konnectd & +ocis phoenix & +ocis thumbnails & +ocis webdav & +ocis reva-auth-basic & +ocis reva-auth-bearer & +ocis reva-frontend & +ocis reva-gateway & +ocis reva-sharing & +ocis reva-users & +exec ocis proxy diff --git a/ocis/docker/eos-ocis/setup b/ocis/docker/eos-ocis/setup new file mode 100755 index 000000000..b146fbbf4 --- /dev/null +++ b/ocis/docker/eos-ocis/setup @@ -0,0 +1,23 @@ +#!/bin/bash + +set -x + +echo "----- [ocis] LDAP setup -----" +authconfig --enableldap --enableldapauth --ldapserver=${EOS_LDAP_HOST} --ldapbasedn="dc=example,dc=org" --update +sed -i "s/#binddn cn=.*/binddn ${LDAP_BINDDN}/" /etc/nslcd.conf +sed -i "s/#bindpw .*/bindpw ${LDAP_BINDPW}/" /etc/nslcd.conf +# start in debug mode +nslcd -d & + +# echo "----- [ocis] eos setup -----" +# eos -r 0 0 -b vid set membership daemon -uids adm +# eos -r 0 0 -b vid set membership daemon -gids adm +# eos -r 0 0 -b vid set membership daemon +sudo +# eos -r 0 0 -b vid set map -unix "" vuid:0 vgid:0 +# # eos -r 0 0 -b vid add gateway ocis.testnet +# eos -r 0 0 -b vid add gateway ocis + +# todo start ocis as daemon not as root +# eos -r 0 0 -b vid set membership root -uids adm +# eos -r 0 0 -b vid set membership root -gids adm +# eos -r 0 0 -b vid set membership root +sudo diff --git a/ocis/docker/eos-ocis/user.go b/ocis/docker/eos-ocis/user.go new file mode 100644 index 000000000..7b9319004 --- /dev/null +++ b/ocis/docker/eos-ocis/user.go @@ -0,0 +1,13 @@ +package main + +import ( + "fmt" + "os" + gouser "os/user" +) + +func main() { + username := os.Args[1] + user, err := gouser.Lookup(username) + fmt.Printf("User %#v %#v %#v\n", username, user, err) +}