Skip to content
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

Docker Hub Automated Build #4

Merged
merged 12 commits into from
Nov 2, 2018
Merged

Conversation

alexanderilyin
Copy link
Contributor

RELEASE NOTES

  • Ignore PHPSorm IDE configuration files.
  • Improved formatting in README.md.
  • Created configuration for docker-compose for more convenient development of Dockerfiles.
  • Use Pinba2 sources from current context instead of cloning latest master.
  • Planned next iteration of improvements for Dockerfile.

ADDITIONAL INFORMATION

The goal of this change is to clean up existing Dockerfile so ready-to-use docker images could be provided by using existing Docker Hub infrastructure. You can see a configured example of Docker Hub repository at https://hub.docker.com/r/alexanderilyin/pinba2/

screen shot 2018-10-10 at 00 19 15

Here are build settings I would recommend:

screen shot 2018-10-10 at 00 21 23

Copy link
Contributor Author

@alexanderilyin alexanderilyin left a comment

Choose a reason for hiding this comment

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

OPEN SOURCE FTW

README.md Outdated
- [Mariadb/debian](docker/debian-mariadb/) (unfinished)
### Fedora 25

Kinda works. [`Dockerfile`](docker/fedora-25/)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Once #2 is resolved this description should be updated.

README.md Outdated

### MariaDB

Unfinished. [`Dockerfile`](docker/debian-mariadb/).
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 would recommend using WIP or Work In Progress instead.

@@ -2,7 +2,7 @@ FROM mariadb:10.1

MAINTAINER Anton Povarov "anton.povarov@gmail.com"

COPY build-from-source.sh /opt/
COPY ./docker/build-from-source.sh /opt/
COPY 10-pinba-init.sh /docker-entrypoint-initdb.d/
Copy link
Contributor Author

Choose a reason for hiding this comment

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

BTW 10-pinba-init.sh is missing in the repository, could someone add it, please?

@@ -1,13 +1,15 @@
FROM fedora:25
MAINTAINER Anton Povarov "anton.povarov@gmail.com"

# TODO: Use multi-stage builds https://docs.docker.com/develop/develop-images/multistage-build/#use-multi-stage-builds
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using multi-stage Dockerfile will allow removing cleanup which does not work as expected because of nature of layers :

 RUN         dnf remove -y git-core gcc gcc-c++ boost-devel cmake autoconf automake libtool mariadb-devel && \
 			dnf autoremove -y && \
 			dnf clean all

git clone https://github.com/anton-povarov/pinba2 && \
git clone https://github.com/anton-povarov/meow && \
git clone https://github.com/nanomsg/nanomsg ;
git clone --branch master --single-branch --depth 1 https://github.com/anton-povarov/meow && \
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, https://github.com/anton-povarov/meow/releases has no releases so we have to use master which is no the best option.

@@ -45,12 +46,14 @@ if [ $1 = "mysqld" ]; then
EOSQL

# install plugin and create default db
# TODO: Use --init-file https://mariadb.com/kb/en/library/server-system-variables/#init_file
mysql --protocol=socket -uroot <<-EOSQL
INSTALL PLUGIN pinba SONAME 'libpinba_engine2.so';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

--init-file is designed for his purpose. I will allow storing all related init queries in the dedicated *.sql file.

services:

fedora-25:
image: anton-povarov/pinba2:fedora-25
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will allow you to build & push images with predefined names without providing them every time on command line, for example:

$ docker-compose build fedora-25
Building fedora-25
Step 1/13 : FROM        fedora:25
 ---> 9cffd21a45e3
Step 2/13 : MAINTAINER  Anton Povarov "anton.povarov@gmail.com"
 ---> Using cache
...
$ docker-compose push fedora-25
The push refers to repository [docker.io/anton-povarov/pinba2]
...

@alexanderilyin
Copy link
Contributor Author

BTW I have a question why MariaDB was used and not a Percona?

@anton-povarov
Copy link
Contributor

Mariadb and not Percona is not a requirement, just something i had easy access to at the time.
Will happily test with Percona (and generally mysql api versions 5.7/8.0+).

@anton-povarov
Copy link
Contributor

Thing is - as pinba is a plugin - it depends on mysql/mariadb/percona internals that tend to change between versions.
So need to adapt the codebase as new versions are released.

@anton-povarov
Copy link
Contributor

Using multi-stage Dockerfile will allow removing cleanup which does not work as expected because of nature of layers

could you please elaborate on that, hate the cleanup code, will happily use any mechanism to get rid of it.

@alexanderilyin
Copy link
Contributor Author

@anton-povarov I will update PR to use multi-stage Dockerfile as soon as I will be able to build it successfully. I thing I will have update in next few days on this.

@alexanderilyin
Copy link
Contributor Author

@anton-povarov I've updated PR, unfortunately, to make Automated Builds work on Docker Hub I had to move Dockerfile to the root directory. Here are the main instructions you have to looks at to get the idea:

FROM fedora:25 as builder
...
FROM fedora:25
...
COPY --from=builder /_src/pinba2/mysql_engine/.libs/libpinba_engine2.so /usr/lib64/mysql/plugin/libpinba_engine2.so
...

You can read about it more here:

Docker image from this PR is available on Docker Hub:

Problem is it still fails with error from #2:

AF6469:~ ailyin$ docker run  alexanderilyin/pinba2:fedora-25-docker_hub
...
ERROR 1126 (HY000) at line 1: Can't open shared library '/usr/lib64/mysql/plugin/libpinba_engine2.so' (errno: 13, undefined symbol: my_print_error_service)

Dockerfile Outdated
FROM fedora:25
MAINTAINER Anton Povarov "anton.povarov@gmail.com"

RUN dnf install -y file hostname mariadb-server
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@anton-povarov do you really need file for production instance? The same question is about hostname but IMHO it might be just missing dependencies for mariadb-server.

Dockerfile Outdated
mariadb-server

RUN git clone --branch master --single-branch --depth 1 https://github.com/anton-povarov/meow /_src/meow
RUN git clone --branch master --single-branch --depth 1 https://github.com/nanomsg/nanomsg /_src/nanomsg
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@anton-povarov I would recommend lock nanomsg to a specific release for example
https://github.com/nanomsg/nanomsg/releases/tag/1.1.5 and download & extract tar.gz using ADD.

Dockerfile Outdated
hostname \
mariadb-server

RUN git clone --branch master --single-branch --depth 1 https://github.com/anton-povarov/meow /_src/meow
Copy link
Contributor Author

@alexanderilyin alexanderilyin Oct 16, 2018

Choose a reason for hiding this comment

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

@anton-povarov It would be nice to create initial release so we could lock on it and use cur ... | tar ... as well.

Dockerfile Outdated
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh

ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
EXPOSE 30003
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@anton-povarov AFAIK Pinba could listen on TCP/UDP ports for writing and you have to use MySQL port for reading. It would be nice to explicitly set it in Dockerfile.

@alexanderilyin
Copy link
Contributor Author

I found out that Docker Cloud allows to set build context, so it will allow keeping Dockerfile in a directory other than root, I will research it later this week:

Another option is to use CircleCI for building from multiple base images, but it makes sense only after #2 is fixed.

Dockerfile Outdated
FROM fedora:25
MAINTAINER Anton Povarov "anton.povarov@gmail.com"

RUN dnf install -y file hostname mariadb-server
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@anton-povarov / @mkevac maybe it will be better to use official docker image as a base locked on a particular version rather than install latest available mariadb-server during build runtime, WDYT?

@alexanderilyin
Copy link
Contributor Author

@mkevac please take a look on this PR one more time. Docker Image should be available in 25 minutes here:

It's building right now:

screen shot 2018-11-02 at 1 31 15 am

Locally you can build & start image like this:

docker-compose build
docker-compose up

P. S.

If you can share your Docker Hub username I can add you to collaborators so you can take a look on configuration inside.

screen shot 2018-11-02 at 1 37 15 am

@mkevac mkevac merged commit 98edbb9 into badoo:master Nov 2, 2018
@mkevac
Copy link
Contributor

mkevac commented Nov 2, 2018

@alexanderilyin it's working great
thank you!

@alexanderilyin
Copy link
Contributor Author

@mkevac sweet. I just checked and the image was built automatically:

docker pull alexanderilyin/pinba2:fedora-25-docker_hub

The only problem that Docker Hub is extremely slow and it took 60+ minutes to build it remotely versus 25 minutes on MBP.

@alexanderilyin
Copy link
Contributor Author

@mkevac any chances that image could be available here?

@mkevac
Copy link
Contributor

mkevac commented Nov 3, 2018

@alexanderilyin we'll try

@anton-povarov
Copy link
Contributor

unsuccessful in finding owner as of now :(
@mkevac - found anybody ?

@mkevac
Copy link
Contributor

mkevac commented Dec 11, 2018

@anton-povarov nope, but I've just contacted my friend in Docker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants