Last active
August 29, 2015 14:26
-
-
Save gongo/531459a34e814b5c94bb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
FROM postgres:9.4 | |
ENV PGDATA /pgdata | |
COPY test.sql /docker-entrypoint-initdb.d/ | |
COPY restore.sh /restore.sh | |
RUN /restore.sh |
This file contains hidden or 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
FROM postgres:9.4 | |
ENV PGDATA /pgdata | |
COPY test.sql /docker-entrypoint-initdb.d/ | |
RUN /docker-entrypoint.sh postgres |
This file contains hidden or 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
#!/bin/bash | |
PIPEFILE="pipefile" | |
ENTRY_PID="" | |
[[ -p "$PIPEFILE" ]] || mkfifo "$PIPEFILE" | |
/docker-entrypoint.sh postgres > "$PIPEFILE" & ENTRY_PID="$!" | |
while read LINE ; do | |
echo $LINE | |
if [[ "$LINE" == *"ready for start up"* ]] ; then | |
sleep 3 | |
break | |
fi | |
done < "$PIPEFILE" | |
kill -s TERM "$ENTRY_PID" && wait "$ENTRY_PID" |
This file contains hidden or 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
CREATE DATABASE gongo; | |
\c gongo; | |
CREATE TABLE users ( | |
name text, | |
age integer | |
); | |
INSERT INTO users (name, age) VALUES ('gongo', 999), ('du', 666); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment