Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Run Portus using docker-compose #212

Merged
merged 1 commit into from
Jul 10, 2015
Merged

Run Portus using docker-compose #212

merged 1 commit into from
Jul 10, 2015

Conversation

flavio
Copy link
Member

@flavio flavio commented Jul 8, 2015

This commit adds the possibility to run Portus and its database using docker-compose. This is a different take for issue #81.

I'll add the documentation tomorrow. In the meantime feel free to comment on it.

@djdefi
Copy link
Contributor

djdefi commented Jul 8, 2015

Cool!

I had to add MYSQL_DATABASE: portus_development to the environment variables for the DB container inside of the docker-compose.yml

I then ran docker exec -it portus_web_1 rake db:migrate RAILS_ENV=development which setup the DB.

@jordimassaguerpla
Copy link
Member

It is simpler than #116 and I like that!

I see this is for development, right? Otherwise we should think about SSL and secrets configuration and apache+passenger.

DB configuration: What's the plan there? Should the user add the portus user and the database to the mariadb container manually?

Add "RUN rake db:migrate"

I think you are missing installing docker-distribution ,right?

may it be this line?

RUN apt-get update -qq && apt-get install -y

and then I would also add a

RUN apt-get update && apt-get upgrade

so that there are the latest security fixes

but the idea looks great!

@djdefi
Copy link
Contributor

djdefi commented Jul 8, 2015

I would say this is pretty sufficient for getting this off the ground for development. Having the ability to specify DB host, user, port, and name secrets via ENV variables on the Portus container would be a nice next step towards making it closer to production ready.

SSL maybe could be accomplished by adding haproxy, or nginx reverse proxy in front. Otherwise just documenting how to mount in certs (via docker -v) and providing a config for SSL is fine. Maybe even generate a pair of self signed certs that are used if custom certs are not specified.

By adding the MYSQL_DATABASE ENV variable to the mariadb section of docker-compose.yml it bring the DB setup one step closer.

The rake db:migrate would likely need to be added to an init script for the portus container image if you want to setup the rest automatically. It wouldn't work in a RUN during build of the portus image, as the DB container would not be linked at that time.

Per https://docs.docker.com/articles/dockerfile_best-practices/ doing apt-get upgrade in a Dockerfile is not reccomended.

@jordimassaguerpla
Copy link
Member

regarding migrations, we could reuse this

https://github.com/SUSE/Portus/blob/master/config/environments/production.rb#L80

we should make sure thought database is configured when we start rails....

I wasnt' aware of running apt-get upgrade is not recommended but now I understand why so many images in docker hub have insecure packages...

How would you set the ENV variables in production?

@flavio
Copy link
Member Author

flavio commented Jul 9, 2015

I see this is for development, right? Otherwise we should think about SSL and secrets
configuration and apache+passenger.

Yes this is for development purposes right now. We can iterate later over it to make it ready for production.

DB configuration: What's the plan there? Should the user add the portus user and the database to > the mariadb container manually?

The mariadb automatically creates a root user with the password mentioned inside of the docker-compose.yml file. Then the db is setup up manually by the user. This is part of the documentation I'm writing.

Add "RUN rake db:migrate"

We cannot do that because at build time the ports container is not linked against the db one. This has to be run manually. This is part of the doc I'm writing.

I think you are missing installing docker-distribution ,right?

No, that's on purpose. We can take advantage of the official registry container for that. I have to figure out how to add it to the mix.

may it be this line?
RUN apt-get update -qq && apt-get install -y
and then I would also add a
RUN apt-get update && apt-get upgrade
so that there are the latest security fixes

These are leftovers , I'm going to drop them as proposed inside of another comment.

@flavio
Copy link
Member Author

flavio commented Jul 9, 2015

I would say this is pretty sufficient for getting this off the ground for development. Having the ability > to specify DB host, user, port, and name secrets via ENV variables on the Portus container would > be a nice next step towards making it closer to production ready.

Yep, we can focus on that with a dedicated iteration.

By adding the MYSQL_DATABASE ENV variable to the mariadb section of docker-compose.yml it > bring the DB setup one step closer.

What would be the purpose of that?

Per https://docs.docker.com/articles/dockerfile_best-practices/ doing apt-get upgrade in a Dockerfile is not reccomended.

Point taken, I'm going to drop them

@flavio
Copy link
Member Author

flavio commented Jul 9, 2015

I then ran docker exec -it portus_web_1 rake db:migrate RAILS_ENV=development which setup the DB.

You aren't supposed to do that. You should use:

docker-compose run web db:migrate

This is documented inside of the doc I'm currently writing.

@flavio
Copy link
Member Author

flavio commented Jul 9, 2015

Added documentation and asciicast

asciicast

This commit adds the possibility to run Portus and its database using
docker-compose
@djdefi
Copy link
Contributor

djdefi commented Jul 9, 2015

I missed that there was a db:create available. The MYSQL_DATABASE variable was just how I pre-setup the Portus db in the mariadb container.

docker-compose run web db:migrate makes sense, exec was just how I did it before your docs were available.

So all is good here ;)

@kevinsimper
Copy link

Do you imagine that it would be possible also to start the registry:2.0 in docker-compose as well?

@mssola
Copy link
Collaborator

mssola commented Jul 10, 2015

LGTM

@flavio
Copy link
Member Author

flavio commented Jul 10, 2015

Do you imagine that it would be possible also to start the registry:2.0 in docker-compose as well?

Yes, I plan to do that with a separate pull request

flavio added a commit that referenced this pull request Jul 10, 2015
Run Portus using docker-compose
@flavio flavio merged commit c456e63 into master Jul 10, 2015
@flavio flavio deleted the docker-compose branch July 10, 2015 07:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants