Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Elektra Web - docker images #2100

Merged
merged 8 commits into from
Jun 19, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions scripts/docker/web/base/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM ubuntu:16.04

# elektra deps
RUN apt-get update -y
RUN apt-get install -y cmake git build-essential

# elektra web deps
RUN apt-get install -y libyajl-dev curl nodejs-legacy npm
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
RUN apt-get install -y nodejs

# pull latest libelektra
RUN mkdir /home/elektra
WORKDIR /home/elektra
RUN git clone https://github.com/omnidan/libelektra.git
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you want to use ElektraInitiative's repo here?
you also want git clone --branch my_abc http://git.abc.net/git/abc.git and probably a shallow clone.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right, I will do that now that the other PR is merged and rebuild the images

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like to get .tar.gz archives from github. This removes the need to install git and it makes it very easy to insert a build-arg that represents the version I want to build.

WORKDIR /home/elektra/libelektra
RUN git checkout elektra-web1.5

# build & install libelektra
RUN mkdir /home/elektra/libelektra/build
WORKDIR /home/elektra/libelektra/build
RUN cmake .. -DTOOLS="kdb;web"
RUN make
RUN make install

# prepare user and home dir
RUN groupadd -r elektra && useradd --no-log-init -r -g elektra elektra
RUN chown -R elektra:elektra /home/elektra

52 changes: 52 additions & 0 deletions scripts/docker/web/elektrad-demo/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
FROM elektra/web-base:latest

WORKDIR /home/elektra

# prepare demo environment

# mount copy of /etc/hosts to user/hosts

# mount as root user
RUN kdb mount --with-recommends hosts user/hosts hosts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will that work? shouldn't you be the elektra user when inheriting from your base image?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, USER is not called in the base image


# then switch to elektra user
USER elektra
RUN mkdir /home/elektra/.config
RUN cp /etc/hosts /home/elektra/.config/hosts

# create user/app structure
RUN kdb set user/app

RUN kdb set user/app/peers
RUN kdb set user/app/peers/#0 "192.168.0.43"
RUN kdb setmeta user/app/peers/#0 check/validation "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"
RUN kdb setmeta user/app/peers/#0 check/validation/message "invalid ip address"
RUN kdb setmeta user/app/peers/#1 check/validation "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"
RUN kdb setmeta user/app/peers/#1 check/validation/message "invalid ip address"
RUN kdb set user/app/peers/#1 "192.168.0.44"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are the ip addresses used here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they are just an example for the demo, they have no meaning

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in that case: you could provide a file containing the demo data and mount that inside the container. would reduce image layers by a lot and is probably easier to maintain in the long run (maybe you can even use something that is around in the repository for tests)

RUN kdb setmeta user/app/peers array 2
RUN kdb setmeta user/app/peers visibility "advanced"

RUN kdb set user/app/database "production"
RUN kdb setmeta user/app/database check/type "enum"
RUN kdb setmeta user/app/database check/enum/#0 "production"
RUN kdb setmeta user/app/database check/enum/#1 "staging"
RUN kdb setmeta user/app/database check/enum/#2 "development"

RUN kdb set user/app/host "192.168.0.42"
RUN kdb setmeta user/app/host check/validation "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"
RUN kdb setmeta user/app/host check/validation/message "invalid ip address"
RUN kdb setmeta user/app/host visibility "advanced"

RUN kdb set user/app/maxConnections "1"
RUN kdb setmeta user/app/maxConnections check/type "unsigned_long"
RUN kdb setmeta user/app/maxConnections check/range "1-999"

RUN kdb set user/app/running "1"
RUN kdb setmeta user/app/running check/type "boolean"
RUN kdb setmeta user/app/running restrict/write "1"

# run elektrad
EXPOSE 33333
CMD ["kdb","run-elektrad"]

9 changes: 9 additions & 0 deletions scripts/docker/web/elektrad/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM elektra/web-base:latest

WORKDIR /home/elektra
USER elektra

# run elektrad
EXPOSE 33333
CMD ["kdb","run-elektrad"]

14 changes: 14 additions & 0 deletions scripts/docker/web/web/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM elektra/web-base:latest

WORKDIR /home/elektra
USER elektra

# create start script
RUN printf "#!/bin/bash\nkdb run-elektrad &\nkdb run-web" > start
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought you will split this up into two containers?

Please give a description about the individual dockerfiles. (as comments and in the README.md)

Copy link
Contributor Author

@omnidan omnidan Jun 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@markus2330 I explained this in the PR description, elektra/web contains both so that you can quickly test elektra web (quickstart guide in README)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the description to a README file

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Please always keep all information within the repo (and not in the PR description).

RUN chmod +x start

# run elektrad and webd in one container
EXPOSE 33333
EXPOSE 33334
CMD ["/home/elektra/start"]

9 changes: 9 additions & 0 deletions scripts/docker/web/web/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Elektra Web docker images

- `elektra/web-base` - base image for elektra web, all other images build upon this (builds elektra with `yajl` and `kdb`)
- `elektra/elektrad` - image that only starts elektrad
- `elektra/webd` - image that only starts webd
- `elektra/elektrad-demo` - same as `elektrad`, but with a KDB config set up (for demo, should run on http://elektrad-demo.libelektra.org)
- `elektra/webd-demo` - same as `webd`, but with 2 instances already created, they both connect to http://elektrad-demo.libelektra.org with different visibility levels (for demo, should run on http://webui.libelektra.org)
- `elektra/web` - image that starts elektrad & webd (for those who just want to try out Elektra Web locally, also mentioned in quickstart in README of #2099)

13 changes: 13 additions & 0 deletions scripts/docker/web/webd-demo/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM elektra/web-base:latest

WORKDIR /home/elektra
USER elektra

# prepare demo environment
COPY --chown=elektra:elektra demo.kdb /home/elektra/
RUN kdb import user/sw < /home/elektra/demo.kdb

# run webd (serves client)
EXPOSE 33334
CMD ["kdb","run-web"]

Binary file added scripts/docker/web/webd-demo/demo.kdb
Binary file not shown.
9 changes: 9 additions & 0 deletions scripts/docker/web/webd/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM elektra/web-base:latest

WORKDIR /home/elektra
USER elektra

# run webd (serves client)
EXPOSE 33334
CMD ["kdb","run-web"]