Giter Site home page Giter Site logo

mkpostgres's Introduction

mkpostgres

Make a persistent postgres container PDQ!

Usage

Initialization or Temp use

make temp will make a temporary ephemeral fresh postgresql instance

make templogs to watch the postgresql process startup and initialize its databases

you now have a fresh postgres install to experiment with you can stop here and start playing with postgres IF you do not need persistent data

Persistent Data

when the initialization of the temp container finishes (not before) you can then make grab which will make a datadir in the current directory and copy out /var/lib/postgresql out of the temporary container to be used in a persistent setup

at this point you can move the datadir wherever you so desire, just be sure and update the POSTGRES_DATADIR file in this directory as that is how the makefile knows where to mount from

Removal of the temp container

make rmtemp will clean up our temporary container, but will not delete the datadir

Production

We are now set to start our persistent database

make prod will then use the datadir and start up our container in persistent mode

Import

alternative to make temp is the make import which will mount docker-entrypoint-initdb.d into the container, at which point entry-point.sh will execute everything in there that ends in .sh or .sql

Restart

restart the container with make rm followed by make prod

Migration

to migrate simply tar up this directory along with the datadir and move to the new docker host

mkpostgres's People

Contributors

joshuacox avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

mkpostgres's Issues

Name container may be better as an optional config

Not sure how much I care about the container names. I like the way Compose handles this {foldername}_{service_name}. For this I think it would be fine to just do the folder name. It would look something like this.

my_app/
Dockerfile.app <- my pthon image
my_app_db/
Dockerfile.db <- my db image

make temp should just attach to stdout

Another nit pick, but i'm personally ALWAYS typing make templogs after i run a make temp.

The use case of just spinning up a DB in the background can be handled by passing in a -d flag perhaps.

Script fails if docker host isn't reachable

Definitely a nit pick... but i'm on OSX and my docker host wasn't spun up, I did a $ make temp and got a big ol error... seems like this could be handled?

โžœ make temp
cat: postgresqlcid: No such file or directory
docker: "kill" requires a minimum of 1 argument.
See 'docker kill --help'.

Usage:  docker kill [OPTIONS] CONTAINER [CONTAINER...]

Kill a running container
make: [kill] Error 1 (ignored)
cat: postgresqlcid: No such file or directory
docker: "rm" requires a minimum of 1 argument.
See 'docker rm --help'.

Usage:  docker rm [OPTIONS] CONTAINER [CONTAINER...]

Remove one or more containers
make: [rm-image] Error 1 (ignored)
rm: postgresqlcid: No such file or directory
make: [rm-image] Error 1 (ignored)
docker run \
    --cidfile="postgresqltemp" \
    --name `cat NAME`-postgresqltemp \
    -e POSTGRES_ROOT_PASSWORD=`cat POSTGRES_PASS` \
    -d \
    postgres:9
docker: Cannot connect to the Docker daemon. Is the docker daemon running on this host?.
See 'docker run --help'.
make: *** [postgresqltemp] Error 125

Doesn't work until you do a make prod

Something is up with the makefile, it APPEARS that the file postgresqlcid is not being created. Trying to learn enougha bout make to submit a PR :) haha.


Enter the postgresql password you wish to associate with this container [POSTGRES_PASS]: nprima
nprima
Enter the name you wish to associate with this container [NAME]: nprimadb
nprimadb
------KEY ERROR --->  cat: postgresqlcid: No such file or directory*** <---- KEY ERROR ---
docker: "kill" requires a minimum of 1 argument.
See 'docker kill --help'.

Usage:  docker kill [OPTIONS] CONTAINER [CONTAINER...]

Kill a running container
make: [kill] Error 1 (ignored)
cat: postgresqlcid: No such file or directory
docker: "rm" requires a minimum of 1 argument.
See 'docker rm --help'.

Usage:  docker rm [OPTIONS] CONTAINER [CONTAINER...]

Remove one or more containers
make: [rm-image] Error 1 (ignored)
rm: postgresqlcid: No such file or directory
make: [rm-image] Error 1 (ignored)
docker run \
    --cidfile="postgresqltemp" \
    --name `cat NAME`-postgresqltemp \
    -e POSTGRES_ROOT_PASSWORD=`cat POSTGRES_PASS` \
    -d \
    postgres:9
6fc07cf4d75c706ae23c882b4dab385d3a26de2db82add4cfa9d578edd7d5f21

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.