Use CMD exec in Dockerfile

Without exec the `postgrest` process is not run with PID 1 (it
is a child process of the shell that starts it). This means
signals send to the docker (like `docker stop` or ^C) will
not be handled correctly.

However, Linux treats PID 1 as special and sets the SIGTERM
handler to ignore by default. It is also necessary to install
a SIGTERM handler.

This commit adds `exec` to resolve this problem, as per the
recommendation in the Dockerfile documentation:

https://docs.docker.com/engine/reference/builder/#shell-form-entrypoint-example
This commit is contained in:
Remco Bloemen
2016-03-07 18:30:40 +01:00
parent e5d420b2db
commit 82c74ed21f
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
## Unreleased ## Unreleased
### Fixed ### Fixed
- Terminate gracefully on SIGTERM - @recmo * Terminate gracefully on SIGTERM (for use in Docker) - @recmo
## [0.3.1.0] - 2016-02-28 ## [0.3.1.0] - 2016-02-28
+1 -1
View File
@@ -16,7 +16,7 @@ RUN wget http://github.com/begriffs/postgrest/releases/download/v${POSTGREST_VER
mv postgrest /usr/local/bin/postgrest && \ mv postgrest /usr/local/bin/postgrest && \
rm postgrest-${POSTGREST_VERSION}-ubuntu.tar.xz rm postgrest-${POSTGREST_VERSION}-ubuntu.tar.xz
CMD postgrest postgres://${PG_ENV_POSTGRES_USER}:${PG_ENV_POSTGRES_PASSWORD}@${PG_PORT_5432_TCP_ADDR}:${PG_PORT_5432_TCP_PORT}/${PG_ENV_POSTGRES_DB} \ CMD exec postgrest postgres://${PG_ENV_POSTGRES_USER}:${PG_ENV_POSTGRES_PASSWORD}@${PG_PORT_5432_TCP_ADDR}:${PG_PORT_5432_TCP_PORT}/${PG_ENV_POSTGRES_DB} \
--port 3000 \ --port 3000 \
--schema ${POSTGREST_SCHEMA} \ --schema ${POSTGREST_SCHEMA} \
--anonymous ${POSTGREST_ANONYMOUS} \ --anonymous ${POSTGREST_ANONYMOUS} \