DiUS / pact_broker-docker

'Dockerised' pact broker
http://pact.io
MIT License
76 stars 102 forks source link

Dockerfile does not work for OpenShift image ruby-23-rhel7 #61

Closed MeadowValley closed 6 years ago

MeadowValley commented 6 years ago

I'm trying to run pact_broker-docker on OpenShift for several days now, but I have to use the ruby-23-rhel7 image (or another OpenShift ruby image...). Of course that makes everything a bit more complicated. Maybe it's possible for you to provide a Dockerfile for an OpenShift image (e.g. for ruby-23-rhel7)? It seems I'm not talented enough to create one by my own.

bethesque commented 6 years ago

I feel like there was someone else who was trying this. I'll see if I can find out who it was.

bethesque commented 6 years ago

Yes, I've found them. https://gitter.im/realestate-com-au/pact?at=5a5496e96117191e61432b55

@jawu are you able to send us your docker file so we can make a build on docker hub for it?

jawu commented 6 years ago

@bethesque sure, here it is:

FROM 1and1internet/ubuntu-16-nginx-passenger-ruby-2.3 ENV APP_HOME=/home/app/pact_broker/ RUN apt-get update && apt-get install libpq-dev --yes && \ rm -f /etc/service/nginx/down /etc/nginx/sites-enabled/default

COPY container / RUN gem update --system COPY pact_broker/config.ru pact_broker/Gemfile pact_broker/Gemfile.lock $APP_HOME RUN chgrp -R 0 $APP_HOME && chmod -R g=u $APP_HOME RUN gem install bundler && \ cd $APP_HOME && bundle install --deployment --without='development test'

COPY pact_broker/ $APP_HOME/ RUN chgrp -R 0 $APP_HOME && chmod -R g=u $APP_HOME

EXPOSE 8080

The used base image is compatible to openshift and some changes were made to the access rights of the broker files (https://docs.openshift.org/1.5/creating_images/guidelines.html#openshift-specific-guidelines). Please note, that the exposed port is 8080 because you are not able to open port 80 with an unprivilegded user, which is used in openshift. I've not tested exactly this dockerfile because this is the cleaned up one but it should work. Please test it @DerKnecht

bethesque commented 6 years ago

Thanks @jawu. Let me know how it goes @DerKnecht, and I'll make Docker build for it.

MeadowValley commented 6 years ago

Thank you for your assistance. I don't like to bother you much, but I don't know the exact configuration of my OpenShift and I have no influence on it and it seems I have several other problems with my configuration or something. So this could be a bigger deal. I have a .yaml-file for configuration and I don't know whether it's even possible and how to use the image "1and1internet/ubuntu-16-nginx-passenger-ruby-2.3" in my .yaml where I currently have this strategy:

    strategy:
      dockerStrategy:
        env:
        - name: APP_NAME
          value: ${APP_NAME}
        from:
          kind: ImageStreamTag
          name: ruby:latest
          namespace: openshift
      type: Docker

When I use that strategy, sure I don't have the chance to use that nginx-passenger-ruby-image I obviously need. Maybe you can tell me how to edit my dockerStrategy so I can use that image?

bethesque commented 6 years ago

I would imagine that the name and namespace configuration above should be pointing to the name of the image that you built from the customized dockerfile. However, I know nothing about OpenShift, so take that with a grain of salt.

mefellows commented 6 years ago

ruby:latest certainly looks to be the name of a docker image

MeadowValley commented 6 years ago

I tried some things now... But it seems my OpenShift can't find that image.

Pulling image 1and1internet/ubuntu-16-nginx-passenger-ruby-2.3 ...
error: build error: failed to pull image: unknown: Not Found

I actually fear I have to use something like ruby-23-rhel7 and install passenger and nginx by my own. Also I'm sure that would take like an eternity... I would like to avoid that, so I'm trying to contact someone who has more experience with our OpenShift environment to find out more. I will let you know.

Edit: I found out there is a registry defined for our environment where all images I can access from OpenShift are stored. I will try to find out more about which images are stored there and whether it's possible to add passenger-ruby23 or ubuntu-16-nginx-passenger-ruby-2.3.

Edit2: The official answer is that we only use images from the redhat portfolio in our company. Do you think that image: https://access.redhat.com/containers/?tab=package-list#/registry.access.redhat.com/rhscl/passenger-40-rhel7/images/4.0-34 could even help me? I'm still not sure what exactly my problem is.

MeadowValley commented 6 years ago

@jawu can you provide some more informationen about what exactly you do to make it run on OpenShift? I see your Dockerfile... you put it as it is on your OpenShift and it just works? I expected a CMD-line as last line in your Dockerfile. I don't know which script I have to execute to make the pactbroker run on OpenShift.

jawu commented 6 years ago

The idea is, that someone of the pact team builds the image and pushes it to docker hub. Than you could load it from there and it will run out of the box, if you pass in the documented environment variables. But you must be sure, that you are able to pull images from docker hub. This question can only answer someone out of your team.

bethesque commented 6 years ago

I've created an openshift docker image from the dockerfile content you created @jasaw, thanks. The docker repo is here: https://hub.docker.com/r/dius/pact-broker-openshift/ The build hasn't finished yet, so hopefully it succeeds...

jawu commented 6 years ago

@bethesque It looks like the tests are executed and the --without flag is not interpreted during build.

MeadowValley commented 6 years ago

@bethesque as there is a line in the Dockerfile of this repository CMD ["/sbin/my_init"] and I can't find a file named "my_init" in the project - can you provide something like an example what should be in that "my_init"? I would expect a script that starts up the pactbroker but I'm wondering how that could look like.

bethesque commented 6 years ago

That my_init thing is a passenger thing. If you have a google for "passenter my_init" you should find some docs about it. Otherwise, docker exec -it into your docker container and see if you can find it.

bethesque commented 6 years ago

You shouldn't have to modify it.

bethesque commented 6 years ago

@jasaw I can't work out why it can't find bundler

[91m/var/www/._gems/bin/bundle:23:in `load': cannot load such file -- /usr/lib/ruby/gems/2.3.0/gems/bundler-1.16.1/exe/bundle (LoadError)
    from /var/www/._gems/bin/bundle:23:in `<main>'
jasaw commented 6 years ago

@bethesque Did you mean to address the comment to @jawu ?

bethesque commented 6 years ago

So sorry! Typo. @jawu, please see above comment.

bethesque commented 6 years ago

Weird. We haven't made any changes to the default Dockerfile and that one is failing for the same reason too now (though the previous one passed)

jawu commented 6 years ago

The same problem exists on both docker builds?

bethesque commented 6 years ago

I rebuilt the master one and is passing again, without me having changed anything. Sigh! I couldn't tell what the error was because docker hub is not showing me the logs.

The openshift one is still failing.

Does your internal build still work?

MeadowValley commented 6 years ago

That my_init thing is a passenger thing. If you have a google for "passenter my_init" you should find some docs about it. Otherwise, docker exec -it into your docker container and see if you can find it. You shouldn't have to modify it.

While it's true I don't have to modify it, though this is a precious information for setting up an image on base of ruby-23-rhel7. Thank you!

jawu commented 6 years ago

@bethesque I will check our internal docker build on monday.

bethesque commented 6 years ago

Thanks @jawu, that would be greatly appreciated.

jawu commented 6 years ago

@bethesque I have the same error on our build.

bethesque commented 6 years ago

Did it use to work? Has something changed to break it, and do you know when it broke?

jaimeniswonger commented 6 years ago

I was able to run the pact-broker on Openshift by using the Ruby s2i builder... I have attached an Openshift template. Obviously, you will need to run a Postgres container as well...this template sets the needed environment variables in the "dc"...modify them as needed for your postgres configuration.

I had to change the file extension to .txt to get it attached, but it is just a yaml file.

template.yml.txt

bethesque commented 6 years ago

Thank you @jaimeniswonger! So we don't need a custom docker image for Openshift then?

jawu commented 6 years ago

So there is no manipulation of the open-shift-dockerfile nedded?

jaimeniswonger commented 6 years ago

Correct... I was able to use the attached template to create a pact-broker container on Openshift 3.7...the standard s2i process works (no Dockerfile needed). I am NOT able to run it on Openshift 3.6, but not sure why yet... still looking at this.

jaimeniswonger commented 6 years ago

The template at https://github.com/jaimeniswonger/pact-broker-openshift works on both Openshift 3.6 and 3.7. It creates a postgres db as well...hope this helps someone.

bethesque commented 6 years ago

Thanks! We'll put a link to it in our docs.

MeadowValley commented 6 years ago

This is my (working) Dockerfile, based on ruby:latest:

FROM ruby:latest

USER default
RUN bash -c "gem install bundler"
COPY pact_broker /app/pact_broker
WORKDIR /app/pact_broker

USER root
RUN bash -c "yum -y update && yum clean all && rm -rf /var/cache/yum"
RUN chown -R default /app/pact_broker
RUN chmod -R 777 /app/pact_broker/log

USER default
RUN bash -c "bundle install"
CMD ["bash", "-c", "bundle exec puma -C puma.rb"]

EDIT: updated Dockerfile

MeadowValley commented 6 years ago

To all participants: Thank you for your assistance! This issue can be closed now if you like to.

bethesque commented 6 years ago

Thanks!