extracted from infraRasp repository

This commit is contained in:
RouxAntoine 2022-06-06 12:28:01 +02:00
parent 20e53d12af
commit 1f73f67270
Signed by: antoine
GPG Key ID: 098FB66FC0475E70
4 changed files with 49 additions and 0 deletions

11
Dockerfile Normal file
View File

@ -0,0 +1,11 @@
FROM postgres:14.1-bullseye
COPY initScript/*.sh /docker-entrypoint-initdb.d/
RUN localedef -i fr_FR -c -f UTF-8 -A /usr/share/locale/locale.alias fr_FR.UTF-8
ENV LANG fr_FR.utf8
ENTRYPOINT ["docker-entrypoint.sh"]
VOLUME /var/lib/postgresql/data/instance
EXPOSE 5432
CMD ["postgres"]

20
Makefile Normal file
View File

@ -0,0 +1,20 @@
.PHONY: imagePostgres
REGISTRY_IP=docker.registry
# linux/arm/v7
# linux/arm/v6
# linux/arm64
# linux/amd64
PLATFORM=linux/arm/v6
#VERBOSITY=info
VERBOSITY=debug
## build
imagePostgres:
$(shell docker-multi-arch-builder build -n postgres --platforms $(PLATFORM) -v $(VERBOSITY))
## management
status:
@curl -s $(REGISTRY_IP):5000/v2/_catalog | jq

15
initScript/init.sh Normal file
View File

@ -0,0 +1,15 @@
#!/bin/bash
set -e
app_password=$(cat "$POSTGRES_APP_PASSWORD_FILE")
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
CREATE USER docker WITH PASSWORD '$app_password';
CREATE DATABASE docker;
GRANT ALL PRIVILEGES ON DATABASE docker TO docker;
-- SELECT datname FROM pg_database WHERE datistemplate = false;
-- SELECT table_schema,table_name
-- FROM information_schema.tables
-- ORDER BY table_schema,table_name;
EOSQL

3
readme.md Normal file
View File

@ -0,0 +1,3 @@
## postgres docker image
build postgres container with custom sql init script use to create application database at startup