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

MF-1342 - Use environment variables in docker-compose to use tagged version of image #1343

Merged
merged 13 commits into from
Feb 2, 2021

Conversation

mteodor
Copy link
Contributor

@mteodor mteodor commented Jan 28, 2021

Resolves #1342

@mteodor mteodor requested a review from a team as a code owner January 28, 2021 16:59
| MF_PROVISION_CERTS_CA_KEY | Mainflux CA cert private key | "" |
| MF_PROVISION_CERTS_RSA_BITS | Certificate RSA bits parameter | 4096 |
| MF_PROVISION_CERTS_HOURS_VALID | Number of days that certificate is valid | "2400h" |
| MF_RELEASE_TAG | Docker image version to be deployed | latest |
Copy link
Contributor

Choose a reason for hiding this comment

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

The last one :)

users/README.md Outdated
@@ -99,7 +100,12 @@ make users
make install

# set the environment variables and run the service
MF_USERS_LOG_LEVEL=[Users log level] MF_USERS_DB_HOST=[Database host address] MF_USERS_DB_PORT=[Database host port] MF_USERS_DB_USER=[Database user] MF_USERS_DB_PASS=[Database password] MF_USERS_DB=[Name of the database used by the service] MF_USERS_DB_SSL_MODE=[SSL mode to connect to the database with] MF_USERS_DB_SSL_CERT=[Path to the PEM encoded certificate file] MF_USERS_DB_SSL_KEY=[Path to the PEM encoded key file] MF_USERS_DB_SSL_ROOT_CERT=[Path to the PEM encoded root certificate file] MF_USERS_HTTP_PORT=[Service HTTP port] MF_USERS_SERVER_CERT=[Path to server certificate] MF_USERS_SERVER_KEY=[Path to server key] MF_JAEGER_URL=[Jaeger server URL] MF_EMAIL_DRIVER=[Mail server driver smtp] MF_EMAIL_HOST=[Mail server host] MF_EMAIL_PORT=[Mail server port] MF_EMAIL_USERNAME=[Mail server username] MF_EMAIL_PASSWORD=[Mail server password] MF_EMAIL_FROM_ADDRESS=[Email from address] MF_EMAIL_FROM_NAME=[Email from name] MF_EMAIL_TEMPLATE=[Email template file] MF_TOKEN_RESET_ENDPOINT=[Password reset token endpoint] $GOBIN/mainflux-users
MF_USERS_LOG_LEVEL=[Users log level] MF_USERS_DB_HOST=[Database host address] MF_USERS_DB_PORT=[Database host port] MF_USERS_DB_USER=[Database user] MF_USERS_DB_PASS=[Database password] \
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a new line for each envar:

MF_USERS_LOG_LEVEL=[Users log level] \
MF_USERS_DB_HOST=[Database host address] \
MF_USERS_DB_PORT=[Database host port] \
MF_USERS_DB_USER=[Database user] \
MF_USERS_DB_PASS=[Database password]

auth/README.md Outdated
@@ -56,6 +56,7 @@ default values.
| MF_AUTH_SERVER_KEY | Path to server key in pem format | |
| MF_AUTH_SECRET | String used for signing tokens | auth |
| MF_JAEGER_URL | Jaeger server URL | localhost:6831|
| MF_RELEASE_TAG | Docker image version to be deployed | latest |
Copy link
Contributor

Choose a reason for hiding this comment

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

space in last column

@mteodor mteodor changed the title MF-1342 - Use environment variables in docker-compose MF-1342 - Use environment variables in docker-compose to use tagged version of image Jan 29, 2021
auth/README.md Outdated
@@ -34,7 +34,7 @@ The following actions are supported:

## Configuration

The service is configured using the environment variables presented in the
The service is configured using the envir onment variables presented in the
Copy link
Contributor

Choose a reason for hiding this comment

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

envir onment

users/README.md Outdated
@@ -55,34 +55,34 @@ locally:
version: "3.7"
services:
users:
image: mainflux/users:[MF_RELEASE_TAG]
image: mainflux/users:[\MF_RELEASE_TAG]
Copy link
Contributor

Choose a reason for hiding this comment

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

\MF_RELEASE_TAG

users/README.md Outdated
Comment on lines 63 to 85
\MF_USERS_LOG_LEVEL: [Users log level]
\MF_USERS_DB_HOST: [Database host address]
\MF_USERS_DB_PORT: [Database host port]
\MF_USERS_DB_USER: [Database user]
\MF_USERS_DB_PASS: [Database password]
\MF_USERS_DB: [Name of the database used by the service]
\MF_USERS_DB_SSL_MODE: [SSL mode to connect to the database with]
\MF_USERS_DB_SSL_CERT: [Path to the PEM encoded certificate file]
\MF_USERS_DB_SSL_KEY: [Path to the PEM encoded key file]
\MF_USERS_DB_SSL_ROOT_CERT: [Path to the PEM encoded root certificate file]
\MF_USERS_HTTP_PORT: [Service HTTP port]
\MF_USERS_SERVER_CERT: [String path to server certificate in pem format]
\MF_USERS_SERVER_KEY: [String path to server key in pem format]
\MF_JAEGER_URL: [Jaeger server URL]
\MF_EMAIL_DRIVER: [Mail server driver smtp]
\MF_EMAIL_HOST: [\MF_EMAIL_HOST]
\MF_EMAIL_PORT: [\MF_EMAIL_PORT]
\MF_EMAIL_USERNAME: [\MF_EMAIL_USERNAME]
\MF_EMAIL_PASSWORD: [\MF_EMAIL_PASSWORD]
\MF_EMAIL_FROM_ADDRESS: [\MF_EMAIL_FROM_ADDRESS]
\MF_EMAIL_FROM_NAME: [\MF_EMAIL_FROM_NAME]
\MF_EMAIL_TEMPLATE: [\MF_EMAIL_TEMPLATE]
\MF_TOKEN_RESET_ENDPOINT: [\MF_TOKEN_RESET_ENDPOINT]
Copy link
Contributor

Choose a reason for hiding this comment

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

Looka like a wrong find a replace. Remove these \

users/README.md Outdated
```

If `MF_EMAIL_TEMPLATE` doesn't point to any file service will function but password reset functionality will not work.
If `\MF_EMAIL_TEMPLATE` doesn't point to any file service will function but password reset functionality will not work.
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

@codecov-io
Copy link

codecov-io commented Jan 29, 2021

Codecov Report

Merging #1343 (66899cc) into master (1bf485b) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1343   +/-   ##
=======================================
  Coverage   60.05%   60.05%           
=======================================
  Files         113      113           
  Lines        8904     8904           
=======================================
  Hits         5347     5347           
  Misses       3088     3088           
  Partials      469      469           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1bf485b...66899cc. Read the comment docs.

docker/README.md Outdated
@@ -21,3 +21,4 @@ docker-compose -f docker/docker-compose.yml up
docker-compose -f docker/addons/<path>/docker-compose.yml up
```

To start specific release you need to change the value of `MF_RELEASE_TAG` in `.env` before running these commands.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd use To pull docker images from a specific release...

auth/README.md Outdated
@@ -67,7 +68,7 @@ locally:
version: "3.7"
services:
auth:
image: mainflux/auth:[version]
image: mainflux/auth:[MF_RELEASE_TAG]
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't get this, why it's wrapped with those brackets [MF_RELEASE_TAG]? I was expecting the same syntax as in Yaml ${MF_RELEASE_TAG} or at least <MF_RELEASE_TAG> a syntax used for variables in doc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

or maybe [Docker image version tag specified by MF_RELEASE_TAG]

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would go with ${MF_RELEASE_TAG} because its env var and exact syntax. But yea, it's probably better because those brackets are everywhere.

dborovcanin
dborovcanin previously approved these changes Jan 29, 2021
MF_AUTH_SERVER_KEY: [String path to server key in pem format]
MF_JAEGER_URL: [Jaeger server URL]
```
The service itself is distributed as Docker container. Check the [`auth`](https://github.com/mainflux/mainflux/blob/master/docker/docker-compose.yml#L71-L94) service section in
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure about using section here. If we change the something in thee docker-compose this will be wrong.

manuio
manuio previously approved these changes Jan 30, 2021
Copy link
Contributor

@manuio manuio left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@drasko drasko left a comment

Choose a reason for hiding this comment

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

I am generally not convinced by this PR.

I do not like removing documentation about ENV vars from README files and adding just links to docker-compose. I know this would be easier to maintain, but on the other hand hinders readability and quick understanding of deployment.

I also do not support adding docker-compose tag as an ENV var, which can be misleading that it is a part of a service, somebody might even think of using it in the Kubernetes. It is not, it is used only in docker-compose, and docker-compose is used ONLY in development.

I do not really want to support people giving them the wrong idea that docker-compose can be used for running stable releases. If they want to do it, I would rather let them change version by hand. We keep latest for a reason - to demotivate people using docker-compose for production, where Kubernetes should be used.

@dborovcanin
Copy link
Collaborator

dborovcanin commented Jan 31, 2021

I do not like removing documentation about ENV vars from README files and adding just links to docker-compose. I know this would be easier to maintain, but on the other hand hinders readability and quick understanding of deployment.

I don't agree with this.
We did not remove the env var table with all the explanation, we just removed unnecessary and quite useless "docker-compose-like" sections that we need to maintain with no benefit whatsoever (it does not explain the meaning of the variables better than the table in README, nor it explains usage better than the real compose file).

I also do not support adding docker-compose tag as an ENV var, which can be misleading that it is a part of a service, somebody might even think of using it in the Kubernetes. It is not, it is used only in docker-compose, and docker-compose is used ONLY in development.

I do agree with this.
This env var can be misinterpreted as a service-related configuration, rather than deployment-related stuff. That's both dangerous and wrong. However, I don't see how providing a version for docker-compose in any way implies that it's production-ready.

@mteodor
Copy link
Contributor Author

mteodor commented Feb 1, 2021

I also do not support adding docker-compose tag as an ENV var, which can be misleading that it is a part of a service, somebody might even think of using it in the Kubernetes. It is not, it is used only in docker-compose, and docker-compose is used ONLY in development.

I dont think there is a place for confusion it just requires a basic knowledge of docker and kubernetes, it is clear that environment variables used for services are in the environment section of docker-compose.

People with such unclear knowledge of docker deployment will more likely checkout release, start it and be surprised that something isn't working as expected (since the services being deployed are latest rather than tagged release version ) and then ask for support, open an issue...

@mteodor
Copy link
Contributor Author

mteodor commented Feb 1, 2021

I do not really want to support people giving them the wrong idea that docker-compose can be used for running stable releases. If they want to do it, I would rather let them change version by hand. We keep latest for a reason - to demotivate people using docker-compose for production, where Kubernetes should be used. <

Latest stays on master, this is just for the people that are experimenting with releases, when they checkout the release tag .env will be populated with appropriate version tag to start appropriate docker versions

@nmarcetic
Copy link
Collaborator

I am generally not convinced by this PR.

I do not like removing documentation about ENV vars from README files and adding just links to docker-compose. I know this would be easier to maintain, but on the other hand hinders readability and quick understanding of deployment.

I also do not support adding docker-compose tag as an ENV var, which can be misleading that it is a part of a service, somebody might even think of using it in the Kubernetes. It is not, it is used only in docker-compose, and docker-compose is used ONLY in development.

I do not really want to support people giving them the wrong idea that docker-compose can be used for running stable releases. If they want to do it, I would rather let them change version by hand. We keep latest for a reason - to demotivate people using docker-compose for production, where Kubernetes should be used.

I also disagree, as its already really well-argued by @dusanb94 and @mteodor here and here I don't have much to add, except that both root README and documentation should be updated with note or section which will say that docker-compose is meant and designed to be used in development environments, even if Docker is aiming that can be used in production and clustered with Swarm, We highly recommend Kubernetes for production.
I didn't saw any notice/recommendation in our documentation or readme, more like Mainflux can be easily deployed on Kubernetes platform than Should be. People who still want to use it to run it in production (even if it's possible), ignoring doc, readme, and recommendations, should be ignored also.

IMHO this PR is a nice improvement and it elimitantes development pain.

@drasko
Copy link
Contributor

drasko commented Feb 1, 2021

OK, I see that majority is for this PR, and makes sense. I would just need one more thought to consider: do we leave MF_RELEASE_TAG in the ENV var table (in the README), or we move it in the sentence below, adding information that docker-compose can be manipulated with this?

This was we could remove ambiguity that this ENV var is related to what service really accepts (in the table) and what is used for deployment via docker-compose.

@nmarcetic @dusanb94 @mteodor please give your thoughts on this.

@nmarcetic
Copy link
Collaborator

OK, I see that majority is for this PR, and makes sense. I would just need one more thought to consider: do we leave MF_RELEASE_TAG in the ENV var table (in the README), or we move it in the sentence below, adding information that docker-compose can be manipulated with this?

This was we could remove ambiguity that this ENV var is related to what service really accepts (in the table) and what is used for deployment via docker-compose.

@nmarcetic @dusanb94 @mteodor please give your thoughts on this.

Service actually does accept MF_RELEASE_TAG which is a docker image tag. I would put this NOTE in root README.md, the section that explains how to run compose file (and here I will also mention with a bolded label at the section bottom that docker-compose is meant and designed to be used for development and testing environments, and Kubernetes for production, Linkedin to K8s section if official doc). Same for an official doc, running the Mainflux section.
IMHO this way, everything is super clear. Don't spare words, mention it everywhere where you are mentioning Running Mainflux.

@dborovcanin
Copy link
Collaborator

@drasko @nmarcetic I think that we should remove this env var from the service README because it's explained elsewhere and has nothing to do with the service configuration. Root README sounds like a good candidate.

@nmarcetic
Copy link
Collaborator

@drasko @nmarcetic I think that we should remove this env var from the service README because it's explained elsewhere and has nothing to do with the service configuration. Root README sounds like a good candidate.

Agree. Let's put it in the root, make a note label for compose and K8s.

@drasko
Copy link
Contributor

drasko commented Feb 1, 2021

OK, this makes sense - we can put it in the root README, under the Install section.

I am not sure if we need as an additional note in microservice READMEs (not in the table, but in a separate sentece). I think not, it is redundant - people will usually deploy looking at the Install section of central README (or by looking in the docker-compose and figuring out). I let @mteodor decide on this.

@drasko
Copy link
Contributor

drasko commented Feb 1, 2021

On a second though - better just put it in the root README, because this is Mainflux-wide setting, not per-service setting.

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
Copy link
Contributor

@manuio manuio left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@drasko drasko left a comment

Choose a reason for hiding this comment

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

LGTM

@drasko drasko merged commit 39a649c into absmach:master Feb 2, 2021
fbugarski pushed a commit to fbugarski/mainflux that referenced this pull request Mar 8, 2021
…ersion of image (absmach#1343)

* add MF_RELEASE_TAG

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* update readme file for MF_RELEASE_TAG

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* update readme file for MF_RELEASE_TAG

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* fix explanation, space

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* fix bad search/replace

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* fix bad search/replace

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* minor changes

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* fix readme

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* improve explanation for tag

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* replace snippet with link to code section

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* improve explanation for tag

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* replace snippet with link to code section

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* remove MF_RELEASE_TAG from service readme

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
@mteodor mteodor deleted the tagged-docker branch September 13, 2021 12:28
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.

Use environment variables in docker-compose to create composition aligned with released versions.
7 participants