-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dockerfile to build a portable testing environment #324
base: dev
Are you sure you want to change the base?
Conversation
6d1542e
to
1653b8a
Compare
1653b8a
to
b2f8189
Compare
@leophys as mentioned in #317 I've already worked on the docker files. You can find my previous work about docker integration on my docker repo: https://github.com/ael-code/libreant/tree/docker. I understand that starting from scratch is a good learning opportunity. In any case I would like to work together on this issue and investigate the best docker integration approach. I've followed an approach that present a big difference from yours. In fact according to the docker best practice 1 it is suggested to put each service on its own container. In our case we are just using two services: elasticsearch and libreant; that will result in two different container. The advantages with respect to your "all-in-one" container are:
The downside is that the command sequence to lunch libreant tests would be a little more complicated. |
Dockerfile
Outdated
# | ||
# To start the container and operate inside it run: | ||
# | ||
# docker run --privileged --rm -ti libreant-box |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why --priviledged
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we have to launch the services via service elasticsearch start
and service libreantd start
.
# Coping the SysVint script to appropriate directory | ||
RUN mv libreantd /etc/init.d/ | ||
# Installing libreant | ||
RUN virtualenv -p $(which python2) ve && ./ve/bin/pip install -e . &&\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why using a virtualenv if we are on an ephemeral container? There won't be any conflict with other python packages version since there will be only libreant installed.
Blallo:
+# docker run --privileged --rm -ti libreant-box
Because we have to launch the services via ```service elasticsearch start``` and ```service libreantd start```.
so what? is --privileged needed for this? I'm not 100% sure, but I don't
think so.
|
Dear @ael-code 😊 |
I thougth so, but it seems you can also without that flag 😄 |
b2f8189
to
814a997
Compare
It seems that we have mostly 2 doubts: compose or notI'm not sure I fully understand the pro and con of each solution. @ael-code has been clear on why he developed using the "compose approach". What is @leophys reply on this? Why is a single container better for a development usecase? virtualenv or not?On this I have a clearer idea. Yes, the doc tells us to use virtualenv, so we should. However, the doc assumes a generic underlying box, on which dependency hello could happen. On docker we don't have this, because we control the underlying machine. I don't see how a virtualenv could be dangerous, though, so "sticking to the doc" might be fine for me, so to keep it all very coherent. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's a-ok, but want to evaluate your solution against @ael-code one
start_libreant_daemon(){ | ||
if [ -f /libreant/ve/bin/libreant ]; | ||
then | ||
/libreant/ve/bin/libreant --fsdb-path /fsdb-store & |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't we just inline this command /libreant/ve/bin/libreant --fsdb-path /fsdb-store &
(which by the way doesn't create a daemon) in Dockerfile
RUN
section?
I don't see when/why stop will ever be called
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a Dockerfile each RUN
is a separate container. The changes made by each RUN
are saved in a temporary container during the build and, if the build is successful, such temporary containers are then discarded. If you invoke a
RUN /libreant/ve/bin/libreant --fsdb-path /fsdb-store &
the following RUN will not have any libreant service up. This is why I wrote the daemon and put in the ENTRYPOINT
the service libreantd start
.
I'd be more comfortable with a systemd unit but AFAIK it (still) does not work (^)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, I just meant .ENTRYPOINT
ENTRYPOINT /libreant/ve/bin/libreant --fsdb-path /fsdb-store & && bash -i
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think we could do it but I liked the idea of having a service
to start|stop|restart
libreant 😄
To clear up my point of view: I don't like Docker as a mean to let people forget how to install and deploy a server. The compose approach that @ael-code proposes to stick to is awesome in its simplicity. Indeed, I think it is the future and that we could think to support such workflow, providing our containerized libreant installation, allowing the happy developer to develop in such an easy environment. └── containers
├── compose
│ ├── docker-compose.yml
│ └── Dockerfile
└── strecth
├── Dockerfile
└── libreantd IIRC, from the root of the project it is then possible to launch the build as $ docker build -ti libreant-oldway containers/stretch As far as I understood (*) there is a way to launch |
Blallo, I think I am missing something. Specifically, I understand well that you want to provide a Dockerfile as a developer tool, not as a deployment tool. That's fine. Still, I don't know why is your solution more fit to this case than the I honestly find it hard to even understand docker strengths as a developer tool, so please be slow :) |
It does not fit more for mere developing purposes, but I would say it stands as a typical installation case for the average developer/sysadmin and can be both a test for us to verify that a tipical installation reaches the end successfully and be used as development environment.
Docker on linux is nothing more than a cool chroot with namespaces and lots of automatic management. The success of Docker is that on macOS/Windows it offers the very same interface to developers/users but is based on different virtualization techniques. Therefore the developer on macOS can use the same command line of the linux developer. |
Blallo:
> Blallo, I think I am missing something. Specifically, I understand well that you want to provide a Dockerfile as a developer tool, not as a deployment tool. That's fine.
> Still, I don't know why is your solution more fit to this case than the docker-compose one.
It does not fit more for mere developing purposes, but I would say it stands as a _typical installation case_ for the average developer/sysadmin and can be both a test for us to verify that a tipical installation reaches the end successfully **and** be used as development environment.
is the Dockerfile proposed by @ael-code less good at this? Please let me
understand, as I think I am not understanding your point.
Can we verify the installation procedure with @ael-code approach?
Can we use it as a development environment?
If both answers are YES, could you highlight any other pro/con?
> I honestly find it hard to even understand docker strengths as a developer tool, so please be slow :)
Docker on linux is nothing more than a cool chroot with namespaces and lots of automatic management. The success of Docker is that on macOS/Windows it offers the very same interface to developers/users but is based on different virtualization techniques. Therefore the developer on macOS can use the same command line of the linux developer.
Running libreant is typically done with "libreant", so I doubt that this
can be much harder on any other OS. Which we don't support, btw.
Elasticsearch installation *can*, instead, be harder, especially with
regard to versions. But in that case, just running a docker container
for elasticsearch which will expose itself on the appropriate port is
enough.
Anyway, I think that having more development tools (and more deployment
tools, too) can only be a good thing.
|
After out-of-band chat, I think we reached this agreement:
Any other idea like
are good ideas, but are deferred to a separate issue (already have some ideas here) So?So, coming back to the issue, it seems to me that the approach using
on which I ask for clarifications. What would be the typical command sequence in both scenarios? |
Claim: Some of the problems that I've encountered:
I think that the best approach to use containers to run tests is to use still two separate imaages for libreant and Elasticsearch and a simple bash script. It would be something like this:
|
Hi @ael-code
Again, why decouple the elasticsearch instance from the container hosting libreant? I could imagine that the speed of building/starting up the services is significantly faster with the decoupled strategy, but then there appear the dependency problem. |
Blallo:
Again, why decouple the elasticsearch instance from the container
hosting libreant? I could imagine that the speed of building/starting
up the services is significantly faster with the decoupled strategy,
but then there appear the _dependency_ problem.
well, on my computer, elasticsearch took not so few to startup.
Something like 20seconds.
That's ok if it's a one-time wait before starting testing, but if we're
tearing it up and down every time, then developing with it doesn't feel
good.
I think I really need testing those to understand how that will really
work, but could you provide an estimate of the duration of the
development iteration? If changing one line and re-running tests (which
AFAIU requires redoing all the installation) takes more than 5 seconds,
I think this can't be called a practical development environment.
…--
boyska
|
My proposal is to "decompose" this PR into two different issues.
What do you think? |
I agree. |
@leophys in any case did you successfully build the the container and run it? I think you are missing the |
@leophys wrote:
Oke I found the trick....
The elasticsearch package does not mention Now the question is: why do we need systemd ?? |
the Travis part is on progress, meaning that #333 has provided scripts to build docker containers based on docs instructions, run unit tests inside them, and do basic integration tests. When it will be merged, it would just need to be integrated into Travis. The "docker for developers" part has never started, I think |
Let't try this again. It is only one commit. Two simple files :)