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

Add Dockerfile with multi-stage build #194

Merged
merged 2 commits into from
Jan 3, 2023
Merged

Add Dockerfile with multi-stage build #194

merged 2 commits into from
Jan 3, 2023

Conversation

nileger
Copy link

@nileger nileger commented Dec 21, 2022

Please ensure all items are complete before opening.

What

I found it extraordinarily difficult to build and run the mq_prometheus exporter using the provided Dockerfiles and shell scripts. The environment variables, paths, and copying files from and to the host make the entire process cumbersome.

Hence, I added a Dockerfile that enhances the build process. It uses multi-stage builds, which is the state-of-the-art and preferred way, compared to using multiple Dockerfiles and copying files from Docker container to host and vice versa.

Now, we must simply run one single command. All steps are executed irrespective of the underlying host. Hence, we do not need different scripts for Linux and Windows machines.

How

The Dockerfile consists of two stages. The first stage builds the Go application and copies the binary to the second stage, which builds a runtime for the Go application.

Testing

Run docker build -t {tag}:{version} . in the root folder of the repository. Then, start the Docker image, e.g., with ./scripts/docker-compose.yml.

Issues

This pull-request is not linked to any currently open issues.

@nileger
Copy link
Author

nileger commented Dec 21, 2022

@ibmmqmet
I haven't updated the CHANGELOG and the README yet because I'm not sure whether the two existing Dockerfiles and some of the shell scripts are required any longer. What do you think?

@tuunit tuunit mentioned this pull request Dec 27, 2022
@ibmmqmet
Copy link
Collaborator

ibmmqmet commented Jan 3, 2023

Thanks for this.

I'll probably leave the existing scripts and Dockerfiles alone for a while because they do demonstrate some varied ways in which you might want to actually run the programs - not everyone wants to execute in a container, though they might want to build that way. For example, if you want to run the collectors as MQ SERVICE programs locally you will need the actual binaries (and associated resources like config files) outside the container.

I'll update the README/CHANGELOG separately as part of the next update.

@ibmmqmet ibmmqmet merged commit 28e6cbf into ibm-messaging:master Jan 3, 2023
ibmmqmet added a commit that referenced this pull request Jan 10, 2023
* JSON exporter - consistent objecttype for qmgr, merge published and
  polled metrics (#188)
* JSON exporter - allow configuration (`recordmax`) for number of objects
  printed in a single JSON record (also #188)
* AWS exporter -correct interval processing (#192)
* Simplified build/run in a single Dockerfile (#194)
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

2 participants