Skip to content

Instantly share code, notes, and snippets.

@gongo
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gongo/531459a34e814b5c94bb to your computer and use it in GitHub Desktop.
Save gongo/531459a34e814b5c94bb to your computer and use it in GitHub Desktop.
FROM postgres:9.4
ENV PGDATA /pgdata
COPY test.sql /docker-entrypoint-initdb.d/
COPY restore.sh /restore.sh
RUN /restore.sh
FROM postgres:9.4
ENV PGDATA /pgdata
COPY test.sql /docker-entrypoint-initdb.d/
RUN /docker-entrypoint.sh postgres
#!/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"
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