Commit 951e8d13 authored by Daniel Dehennin's avatar Daniel Dehennin
Browse files

Import from all-in-one zephir repository

parent 8ffa76bc
####
#### Temporary layer to prepare installation
####
FROM postgres:alpine AS build
MAINTAINER EOLE <eole@ac-dijon.fr>
RUN apk add --no-cache curl
ARG CONTAINERPILOT_VERSION=3.4.3
ARG CONTAINERPILOT_CHECKSUM=e8258ed166bcb3de3e06638936dcc2cae32c7c58
RUN curl -Lso /tmp/containerpilot.tar.gz \
"https://github.com/joyent/containerpilot/releases/download/${CONTAINERPILOT_VERSION}/containerpilot-${CONTAINERPILOT_VERSION}.tar.gz" \
&& echo "${CONTAINERPILOT_CHECKSUM} /tmp/containerpilot.tar.gz" | sha1sum -c \
&& tar zxf /tmp/containerpilot.tar.gz -C /tmp
####
#### Target layer
####
FROM postgres:alpine
# Install tools from build layer
COPY --from=build /tmp/containerpilot /usr/local/bin
RUN chmod +x /usr/local/bin/*
# add ContainerPilot configuration file
COPY containerpilot.json5 /etc/containerpilot.json5
COPY docker-entrypoint-initdb.d /docker-entrypoint-initdb.d
RUN chmod +x /docker-entrypoint-initdb.d/*.sh
COPY docker-health.d/ /docker-health.d
RUN chmod +x /docker-health.d/*
CMD ["/usr/local/bin/containerpilot", "-config", "/etc/containerpilot.json5"]
{
consul: {
address: "consul:8500"
},
jobs: [
{
name: "postgres",
exec: ["/docker-entrypoint.sh", "postgres"],
port: 5432,
health: {
exec: ["run-parts", "--exit-on-error", "/docker-health.d"],
interval: 5,
ttl: 10,
},
tags: [
"database"
]
}
]
}
set -e
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL
CREATE USER keycloak;
CREATE DATABASE keycloak;
GRANT ALL PRIVILEGES ON DATABASE keycloak TO keycloak;
EOSQL
#!/bin/sh
# Check if PostgreSQL server is ready
pg_isready -qU postgres
#!/bin/sh
set -e
# Return “t” for “true” or “f” for “false”
get_create_privilege() {
local user=$1; shift
local database=$1;
psql -v ON_ERROR_STOP=1 --username postgres -qtA <<-EOSQL
SELECT * FROM has_database_privilege('$user', '$database', 'CREATE');
EOSQL
}
# exit code is the return code of the last statement
[ "t" = "$(get_create_privilege keycloak keycloak)" ]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment