Skip to content

Update Dockerfiles to add backend.enable option to Postgres#1492

Merged
AlvaroVega merged 1 commit into
telefonicaid:masterfrom
jason-fox:feature/postgres-cache-enable
Jun 5, 2018
Merged

Update Dockerfiles to add backend.enable option to Postgres#1492
AlvaroVega merged 1 commit into
telefonicaid:masterfrom
jason-fox:feature/postgres-cache-enable

Conversation

@jason-fox

@jason-fox jason-fox commented Jun 4, 2018

Copy link
Copy Markdown
Contributor

I have been attempting to run a Dockerized Cygnus to connect to a Postgres database. The changes in this PR enable me to do so.

Currently when I docker-compose using default values, I can't successfully add any data to Postgres since I get the #1467 issue. This is because the default value (postgresql-sink.backend.enable_cache = false ) causes a null pointer error since the cache is uninitialized.

A value for postgresql-sink.backend.enable_cache does not exist in the agent.conf which is copied over when the entrypoint point is run, and no environment variable exists to override it, therefore I'm stuck with the broken default value without creating my own custom Docker file.

This amendment adds the default value (false) to the Docker agent.conf and ensures that the dummy file agent.conf in the same folder as the Dockerfile gets copied into the image correctly. Note that agent.conf must be copied twice , since the docker-cygnus agent version is used if CYGNUS_MULTIAGENT is not set. The default value can be overwritten using an environment variable (CYGNUS_POSTGRESQL_ENABLE_CACHE)

The entrypoint has been amended to copy the external configuration files into the container using the Docker COPY command rather than copying the internal files from within the downloaded github repository using the bash cp command. This allows a user to more easily override the default dummy agent.conf with their own files regardless of whether CYGNUS_MULTIAGENT is set.

Using Docker COPY is preferred, since ordinary users won't have push rights to the git repo - see #1418 which proposes similar changes.

* Add default `postgresql-sink.backend.enable_cache = false` to `agent.conf` file
* Amend entrypoint to overwrite default if `CYGNUS_POSTGRESQL_ENABLE_CACHE` environment variable is set.
* Amend Dockerfile to use COPY rather than bash cp.

Note that `agent.conf` must be copied twice, since the docker-cygnus agent version is used if `CYGNUS_MULTIAGENT` is not set.

@AlvaroVega AlvaroVega left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM.

@AlvaroVega AlvaroVega merged commit 8b32b57 into telefonicaid:master Jun 5, 2018
@AlvaroVega

AlvaroVega commented Jun 5, 2018

Copy link
Copy Markdown
Member

Hi @jason-fox, It seems that your PR has introduced a failure in docker image creation:
https://hub.docker.com/r/telefonicaiot/fiware-cygnus/builds/b7ylztxzajv8ezyrsyod8de/

COPY: command not found

I guess that the problem is: COPY should be before RUN command.

Could you fix that? Thanks!

@jason-fox

Copy link
Copy Markdown
Contributor Author

Whoops - I'd left a line concatenation hanging on the committed Dockerfile it was therefore attempting to RUN the COPY command
Fixed in commit #784b28fd

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.

2 participants