-
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING feat(dbapi): switch to postgres
- Loading branch information
1 parent
149150c
commit 5c4b999
Showing
15 changed files
with
68 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
FROM mariadb:10.3 | ||
FROM postgres:12-alpine | ||
|
||
# Use random throw-away root password. Our init scripts switch authentication to socket logins only | ||
ENV MYSQL_RANDOM_ROOT_PASSWORD=yes | ||
RUN apk add --no-cache pwgen | ||
|
||
# install tools used in init script | ||
RUN set -ex && apt-get update && apt-get -y install gettext-base && apt-get clean && rm -rf /var/lib/apt/lists/* | ||
ADD docker-entrypoint-initdb.d /docker-entrypoint-initdb.d | ||
|
||
COPY initdb.d/* /docker-entrypoint-initdb.d/ | ||
RUN chown -R mysql:mysql /docker-entrypoint-initdb.d/ | ||
USER postgres | ||
|
||
# mountable storage | ||
VOLUME /var/lib/mysql | ||
VOLUME /var/lib/postgresql/data | ||
|
||
COPY entrypoint-wrapper.sh /usr/local/bin/ | ||
ENTRYPOINT ["entrypoint-wrapper.sh"] | ||
CMD ["postgres"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# Get the postgres user or set it to a default value | ||
if [ -n $POSTGRES_USER ]; then pg_user=$POSTGRES_USER; else pg_user="postgres"; fi | ||
# Get the postgres db or set it to a default value | ||
if [ -n $POSTGRES_DB ]; then pg_db=$POSTGRES_DB; else pg_db=$POSTGRES_USER; fi | ||
|
||
if [ -n "$POSTGRES_NON_ROOT_USER" ]; then | ||
psql -v ON_ERROR_STOP=1 --username "$pg_user" --dbname "$pg_db" <<-EOSQL | ||
CREATE USER $POSTGRES_NON_ROOT_USER with encrypted password '$POSTGRES_NON_ROOT_USER_PASSWORD'; | ||
GRANT CREATE, CONNECT ON DATABASE $pg_db TO $POSTGRES_NON_ROOT_USER; | ||
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT, UPDATE, INSERT, DELETE, REFERENCES ON TABLES TO $POSTGRES_NON_ROOT_USER; | ||
EOSQL | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env bash | ||
set -Eeo pipefail | ||
|
||
# This password is set for the postgres user when initializing the database. It is not needed and thus not printed. | ||
export POSTGRES_PASSWORD=$(pwgen -1 -s 32) | ||
/usr/local/bin/docker-entrypoint.sh "$@" |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# TYPE DATABASE USER ADDRESS METHOD | ||
|
||
# "local" is for Unix domain socket connections only | ||
local all all trust | ||
# IPv4 local connections: | ||
#host all all 127.0.0.1/32 scram-sha-256 | ||
# IPv6 local connections: | ||
#host all all ::1/128 scram-sha-256 | ||
# Allow replication connections from localhost, by a user with the | ||
# replication privilege. | ||
#local replication all trust | ||
#host replication all 127.0.0.1/32 scram-sha-256 | ||
#host replication all ::1/128 scram-sha-256 | ||
|
||
host desec desec all scram-sha-256 | ||
host all all all reject |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters